alibi.explainers.anchors.anchor_tabular_distributed module
- class alibi.explainers.anchors.anchor_tabular_distributed.DistributedAnchorBaseBeam(samplers, **kwargs)[source]
Bases:
AnchorBaseBeam
- draw_samples(anchors, batch_size)[source]
Distributes sampling requests among processes running sampling tasks.
- Parameters:
anchors (
list
) – Seealibi.explainers.anchors.anchor_base.AnchorBaseBeam.draw_samples()
implementation.batch_size (
int
) – Seealibi.explainers.anchors.anchor_base.AnchorBaseBeam.draw_samples()
implementation.
- Return type:
Tuple
[ndarray
,ndarray
]- Returns:
See
alibi.explainers.anchors.anchor_base.AnchorBaseBeam.draw_samples()
implementation.
- class alibi.explainers.anchors.anchor_tabular_distributed.DistributedAnchorTabular(predictor, feature_names, categorical_names=None, dtype=<class 'numpy.float32'>, ohe=False, seed=None)[source]
Bases:
AnchorTabular
- explain(X, threshold=0.95, delta=0.1, tau=0.15, batch_size=100, coverage_samples=10000, beam_size=1, stop_on_first=False, max_anchor_size=None, min_samples_start=1, n_covered_ex=10, binary_cache_size=10000, cache_margin=1000, verbose=False, verbose_every=1, **kwargs)[source]
Explains the prediction made by a classifier on instance X. Sampling is done in parallel over a number of cores specified in kwargs[‘ncpu’].
- Parameters:
X (
ndarray
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.threshold (
float
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.delta (
float
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.tau (
float
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.batch_size (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.coverage_samples (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.beam_size (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.stop_on_first (
bool
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.max_anchor_size (
Optional
[int
]) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.min_samples_start (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.n_covered_ex (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.binary_cache_size (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.cache_margin (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.verbose (
bool
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.verbose_every (
int
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.**kwargs (
Any
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
.
- Return type:
- Returns:
See
alibi.explainers.anchors.anchor_tabular.AnchorTabular.explain()
superclass.
- fit(train_data, disc_perc=(25, 50, 75), **kwargs)[source]
Creates a list of handles to parallel processes handles that are used for submitting sampling tasks.
- Parameters:
train_data (
ndarray
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.fit()
superclass.disc_perc (
tuple
) – Seealibi.explainers.anchors.anchor_tabular.AnchorTabular.fit()
superclass.**kwargs – See
alibi.explainers.anchors.anchor_tabular.AnchorTabular.fit()
superclass.
- Return type:
- class alibi.explainers.anchors.anchor_tabular_distributed.RemoteSampler(*args)[source]
Bases:
object
A wrapper that facilitates the use of TabularSampler for distributed sampling.
- __call__(anchors_batch, num_samples, compute_labels=True)[source]
Wrapper around
alibi.explainers.anchors.anchor_tabular.TabularSampler.__call__()
. It allows sampling a batch of anchors in the same process, which can improve performance.- Parameters:
anchors_batch (
Union
[Tuple
[int
,tuple
],List
[Tuple
[int
,tuple
]]]) – A list of result tuples. Seealibi.explainers.anchors.anchor_tabular.TabularSampler.__call__()
for details.num_samples (
int
) – A list of result tuples. Seealibi.explainers.anchors.anchor_tabular.TabularSampler.__call__()
for details.compute_labels (
bool
) – A list of result tuples. Seealibi.explainers.anchors.anchor_tabular.TabularSampler.__call__()
for details.
- Return type:
- build_lookups(X)[source]
Wrapper around
alibi.explainers.anchors.anchor_tabular.TabularSampler.build_lookups()
.- Parameters:
X (
ndarray
) – Seealibi.explainers.anchors.anchor_tabular.TabularSampler.build_lookups()
.- Returns:
See
alibi.explainers.anchors.anchor_tabular.TabularSampler.build_lookups()
.