LogisticRegression#

Link to Algorithm description: Linear Model

class interpret.glassbox.LogisticRegression(feature_names=None, feature_types=None, linear_class=<class 'sklearn.linear_model._logistic.LogisticRegression'>, **kwargs)#

Logistic regression.

Currently wrapper around linear models in scikit-learn: scikit-learn/scikit-learn

Initializes class.

Parameters:
  • feature_names – List of feature names.

  • feature_types – List of feature types.

  • linear_class – A scikit-learn linear class.

  • **kwargs – Kwargs pass to linear class at initialization time.

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, visualizing feature-value pairs for each instance as horizontal bar charts.

fit(X, y)#

Fits model to provided instances.

Parameters:
  • X – Numpy array for training instances.

  • y – Numpy array as training labels.

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