ClassificationTree#

Link to Algorithm description: Decision Tree

class interpret.glassbox.ClassificationTree(feature_names=None, feature_types=None, max_depth=3, **kwargs)#

Classification tree with shallow depth.

Initializes tree with low depth.

Parameters:
  • feature_names โ€“ List of feature names.

  • feature_types โ€“ List of feature types.

  • max_depth โ€“ Max depth of tree.

  • **kwargs โ€“ Kwargs sent to __init__() method of tree.

explain_global(name=None)#

Provides global explanation for model.

Parameters:

name โ€“ User-defined explanation name.

Returns:

An explanation object, visualizing feature-value pairs as horizontal bar chart.

explain_local(X, y=None, name=None)#

Provides local explanations for provided instances.

Parameters:
  • X โ€“ Numpy array for X to explain.

  • y โ€“ Numpy vector for y to explain.

  • name โ€“ User-defined explanation name.

Returns:

An explanation object.

fit(X, y, sample_weight=None, check_input=True)#

Fits model to provided instances.

Parameters:
  • X โ€“ Numpy array for training instances.

  • y โ€“ Numpy array as training labels.

  • sample_weight (optional[np.ndarray]) โ€“ (n_samples,) Sample weights. If None (default), then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node.

  • check_input (bool) โ€“ default=True. Allow to bypass several input checking. Donโ€™t use this parameter unless you know what youโ€™re doing.

Returns:

Itself.

predict(X)#

Predicts on provided instances.

Parameters:

X โ€“ Numpy array for instances.

Returns:

Predicted class label per instance.

predict_proba(X)#

Probability estimates on provided instances.

Parameters:

X โ€“ Numpy array for instances.

Returns:

Probability estimate of instance for each class.

score(X, y, sample_weight=None)#

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters:
  • X (array-like of shape (n_samples, n_features)) โ€“ Test samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) โ€“ True labels for X.

  • sample_weight (array-like of shape (n_samples,), default=None) โ€“ Sample weights.

Returns:

score โ€“ Mean accuracy of self.predict(X) w.r.t. y.

Return type:

float