elphick.sklearn_viz.features.importance.FeatureImportance
- class elphick.sklearn_viz.features.importance.FeatureImportance(mdl, permute=False, pipeline_input_features=False, x_test=None, y_test=None, scorer=None)[source]
- __init__(mdl, permute=False, pipeline_input_features=False, x_test=None, y_test=None, scorer=None)[source]
- Parameters:
mdl – The scikit-learn model or pipeline.
permute (
bool
) – If True plot permutation importance. Better, but slower. Requires X_test and y_test to be provided.pipeline_input_features (
bool
) – If True, and a pipeline is provided, report the features provided as inputs to the pipeline. If False, reports the estimator (last pipeline step) input features. Requires permute = True.x_test (
Optional
[DataFrame
]) – X values provided to execute permuted importance.y_test (
Union
[DataFrame
,Series
,None
]) – y values provided to execute permuted importance.scorer (
Union
[str
,Callable
,None
]) – Optional callable scorer which the model will be fitted using
Methods
__init__
(mdl[, permute, ...])- type mdl:
plot
([sort, top_k, horizontal, title])- type sort:
bool
Attributes
data
- plot(sort=False, top_k=None, horizontal=False, title=None)[source]
- Parameters:
sort (
bool
) – If True, sort by decreasing importancetop_k (
Optional
[int
]) – Include only the top k features in the plot. Will ignore the sort argument.horizontal (
bool
) – If True plot horizontal bars, if False vertical bars. the pipeline. If False, reports the estimator (last pipeline step) input features. Requires permute = True.title (
Optional
[str
]) – title for the plot
- Return type:
Figure
- Returns:
a plotly GraphObjects.Figure