Get an Inspector

Get an appropriate inspector for your model

source

get_inspector

 get_inspector (model:sklearn.base.BaseEstimator,
                X:pandas.core.frame.DataFrame,
                y:pandas.core.series.Series)

Get an appropriate inspector for your model and data.

Parameters:

  • model: Fitted sklearn model
  • X: Matrix with the same features model was trained on
  • y: Series with same length as X and same meaning as target values model was trained on

Example:

import sklearn.datasets
from sklearn.tree import DecisionTreeRegressor
from model_inspector import get_inspector
X, y = sklearn.datasets.load_diabetes(return_X_y=True, as_frame=True)
dtr = DecisionTreeRegressor().fit(X, y)
inspector = get_inspector(dtr, X=X, y=y)
inspector
model_inspector.inspect.tree._TreeRegInspector(model=DecisionTreeRegressor())
inspector.methods
['permutation_importance',
 'plot_feature_clusters',
 'plot_partial_dependence',
 'plot_permutation_importance',
 'plot_pred_vs_act',
 'plot_residuals',
 'plot_tree',
 'show_correlation']
ax = inspector.plot_tree(max_depth=2)