wildboar.base#

Base classes for all estimators.

Module Contents#

Classes#

BaseEstimator

Base estimator for all Wildboar estimators.

CounterfactualMixin

Mixin class for counterfactual explainer.

ExplainerMixin

Mixin class for all explainers in wildboar.

Functions#

is_counterfactual(estimator)

Check if estimator is a counterfactual explainer.

is_explainer(estimator)

Check if estimator is an explainer.

class wildboar.base.BaseEstimator[source]#

Base estimator for all Wildboar estimators.

get_metadata_routing()[source]#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)[source]#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

set_params(**params)[source]#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

class wildboar.base.CounterfactualMixin[source]#

Mixin class for counterfactual explainer.

score(x, y)[source]#

Score the counterfactual explainer in terms of closeness of fit.

Parameters:
xarray-like of shape (n_samples, n_timestep)

The samples.

yarray-like of shape (n_samples, )

The desired counterfactal label.

Returns:
scorefloat

The closensess of fit.

class wildboar.base.ExplainerMixin[source]#

Mixin class for all explainers in wildboar.

fit_explain(estimator, x=None, y=None, **kwargs)[source]#

Fit and return the explanation.

Parameters:
estimatorEstimator

The estimator to explain.

xtime-series, optional

The input time series.

yarray-like of shape (n_samples, ), optional

The labels.

**kwargs

Optional extra arguments.

Returns:
ndarray

The explanation.

plot(x=None, y=None, ax=None)[source]#

Plot the explanation.

Returns:
axAxes

The axes object

wildboar.base.is_counterfactual(estimator)[source]#

Check if estimator is a counterfactual explainer.

Parameters:
estimatorobject

The estimator

Returns:
bool

True if the estimator probably is a counterfactual explainer

wildboar.base.is_explainer(estimator)[source]#

Check if estimator is an explainer.

Parameters:
estimatorobject

The estimator

Returns:
bool

True if the estimator probably is an explainer