Model.features_importance

In [ ]:
Model.features_importance(ax=None,
                          tree_id: int = None, 
                          show: bool = True, 
                          **style_kwds,)

Computes the importance of the features of the model.

Parameters

Name Type Optional Description
ax
Matplotlib axes object
The axes to plot on.
tree_id
int
Tree ID in case of Tree Based models.
show
bool
If set to True, draw the features importance.
**style_kwds
any
Any optional parameter to pass to the Matplotlib functions.

Returns

tablesample : An object containing the result. For more information, see utilities.tablesample.

Example

In [4]:
from verticapy.learn.ensemble import RandomForestClassifier
model = RandomForestClassifier(name = "public.RF_iris",
                               n_estimators = 20,
                               max_features = "auto",
                               max_leaf_nodes = 32, 
                               sample = 0.7,
                               max_depth = 3,
                               min_samples_leaf = 5,
                               min_info_gain = 0.0,
                               nbins = 32)
model.drop()
model.fit("public.iris", 
          ["PetalLengthCm", "PetalWidthCm", "SepalWidthCm", "SepalLengthCm"], 
          "Species")
model.features_importance()
Out[4]:
importance
sign
petalwidthcm52.11
petallengthcm40.991
sepallengthcm6.911
sepalwidthcm0.00
Rows: 1-4 | Columns: 3