module tools.model_info
#
Short summary#
module mlprodict.tools.model_info
Functions to help get more information about the models.
Functions#
function |
truncated documentation |
---|---|
Extract information from a tree. |
|
Extract information from a tree in a HistGradientBoosting. |
|
Get informations from and lightgbm trees. |
|
Get informations from and lightgbm trees. |
|
Produces agregates features. |
|
Returns informations, statistics about a model, its number of nodes, its size… |
|
Enumerates models with models. |
|
Sets all possible parameter random_state to 0. |
Documentation#
Functions to help get more information about the models.
- mlprodict.tools.model_info._analyse_tree(tree)#
Extract information from a tree.
- mlprodict.tools.model_info._analyse_tree_h(tree)#
Extract information from a tree in a HistGradientBoosting.
- mlprodict.tools.model_info._reduce_infos(infos)#
Produces agregates features.
- mlprodict.tools.model_info.analyze_model(model, simplify=True)#
Returns informations, statistics about a model, its number of nodes, its size…
- Parameters
model – any model
simplify – simplifies the tuple of length 1
- Returns
dictionary
Extract information from a model
The function
analyze_model
extracts global figures about a model, whatever it is.<<<
import pprint from sklearn.datasets import load_iris from sklearn.ensemble import RandomForestClassifier from mlprodict.tools.model_info import analyze_model data = load_iris() X, y = data.data, data.target model = RandomForestClassifier().fit(X, y) infos = analyze_model(model) pprint.pprint(infos)
>>>
/var/lib/jenkins/workspace/mlprodict/mlprodict_UT_39_std/_venv/lib/python3.9/site-packages/sklearn/utils/deprecation.py:103: FutureWarning: Attribute `n_features_` was deprecated in version 1.0 and will be removed in 1.2. Use `n_features_in_` instead. warnings.warn(msg, category=FutureWarning) /var/lib/jenkins/workspace/mlprodict/mlprodict_UT_39_std/_venv/lib/python3.9/site-packages/sklearn/utils/deprecation.py:103: FutureWarning: The attribute `n_features_` is deprecated in 1.0 and will be removed in 1.2. Use `n_features_in_` instead. warnings.warn(msg, category=FutureWarning) {'classes_.shape': 3, 'estimators_.classes_.shape': 3, 'estimators_.max|tree_.max_depth': 8, 'estimators_.n_classes_': 3, 'estimators_.n_features_': 4, 'estimators_.size': 100, 'estimators_.sum|tree_.leave_count': 858, 'estimators_.sum|tree_.node_count': 1616, 'n_classes_': 3, 'n_features_': 4}
- mlprodict.tools.model_info.enumerate_models(model)#
Enumerates models with models.
- Parameters
model – scikit-learn model
- Returns
enumerate models
- mlprodict.tools.model_info.set_random_state(model, value=0)#
Sets all possible parameter random_state to 0.
- Parameters
model – scikit-learn model
value – new value
- Returns
model (same one)