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)
>>>
{'classes_.shape': 3, 'estimators_.classes_.shape': 3, 'estimators_.max|tree_.max_depth': 10, 'estimators_.n_classes_': 3, 'estimators_.size': 100, 'estimators_.sum|tree_.leave_count': 877, 'estimators_.sum|tree_.node_count': 1654, 'n_classes_': 3}
- 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)