Model.confusion_matrix¶
In [ ]:
Model.confusion_matrix(pos_label = None,
cutoff: float = -1)
Computes the model confusion matrix.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
pos_label | int / float / str | ✓ | Label to consider as positive. All the other classes will be merged and considered as negative in case of multi classification. |
cutoff | float | ✓ | Cutoff for which the tested category will be accepted as prediction. In case of multiclass classification, if the cutoff is not between 0 and 1, the entire confusion matrix will be drawn. |
Returns¶
tablesample : An object containing the result. For more information, see utilities.tablesample.
Example¶
In [45]:
# Multiclass Classification
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.fit("public.iris", ["PetalLengthCm", "PetalWidthCm"], "Species")
# Global Confusion Matrix
model.confusion_matrix()
Out[45]:
In [46]:
# Confusion matrix with Iris-versicolor as
# the positive class
model.confusion_matrix(pos_label = "Iris-versicolor",
cutoff = 0.33)
Out[46]: