import sklearn.datasets
from sklearn.tree import DecisionTreeRegressor
from model_inspector import get_inspector
Get an Inspector
Get an appropriate inspector for your model
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 modelX
: Matrix with the same featuresmodel
was trained ony
: Series with same length asX
and same meaning as target valuesmodel
was trained on
Example:
= sklearn.datasets.load_diabetes(return_X_y=True, as_frame=True) X, y
= DecisionTreeRegressor().fit(X, y) dtr
= get_inspector(dtr, X=X, y=y)
inspector 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']
= inspector.plot_tree(max_depth=2) ax