Model.classification_report

In [ ]:
Model.classification_report(cutoff = [],
                            labels: list = [])

Computes a classification report using multiple metrics to evaluate the model (AUC, accuracy, PRC AUC, F1...). In case of multiclass classification, it will consider each category as positive and switch to the next one during the computation.

Parameters

Name Type Optional Description
cutoff
float / list
✓
Cutoff for which the tested category will be accepted as prediction. In case of multiclass classification, each tested category becomes the positives and the others are merged into the negatives. The list will represent the classes threshold. If it is empty or invalid, the best cutoff will be used.
labels
list
✓
List of the different labels to be used during the computation.

Returns

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

Example

In [49]:
# 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")
# Multiclass Classification: Using a fixed cutoff
model.classification_report(cutoff = 0.33)
Iris-setosa
Iris-versicolor
Iris-virginica
auc1.00.99700000000000020.9972000000000002
prc_auc1.00.99426422871300480.9945555192416813
accuracy1.00.97333333333333340.96
log_loss0.00800712240766840.03044764266191680.0292307724947753
precision1.00.960.9074074074074074
recall1.00.960.98
f1_score1.00.96989690721649480.9647668393782383
mcc1.00.940.9133462590326239
informedness1.00.940.9299999999999999
markedness1.00.940.8969907407407409
csi1.00.92307692307692310.8909090909090909
cutoff0.330.330.33
Out[49]:

In [50]:
# Multiclass Classification: Using automatic cutoffs
model.classification_report()
Iris-setosa
Iris-versicolor
Iris-virginica
auc1.00.99700000000000020.9972000000000002
prc_auc1.00.99426422871300480.9945555192416813
accuracy1.00.97333333333333340.9666666666666667
log_loss0.00800712240766840.03044764266191680.0292307724947753
precision1.00.960.9090909090909091
recall1.00.961.0
f1_score1.00.96989690721649480.9743589743589743
mcc1.00.940.929320377284585
informedness1.00.940.95
markedness1.00.940.9090909090909092
csi1.00.92307692307692310.9090909090909091
cutoff0.8510.3820.284
Out[50]:

In [41]:
# Multiclass Classification: Customized Cutoffs
model.classification_report(cutoff = [0.8, 0.4, 0.2])
Iris-setosaIris-versicolorIris-virginica
auc1.00.9960.9960000000000001
prc_auc1.00.99252387996411740.9921025338869698
accuracy1.00.94666666666666670.9666666666666667
log_loss0.009937900556465460.03756150535421120.0344348556530513
precision1.00.8750.9090909090909091
recall1.00.981.0
f1_score1.00.95434554973821980.9743589743589743
mcc1.00.88688733722844990.929320377284585
informedness1.00.91000000000000010.95
markedness1.00.86436170212765970.9090909090909092
csi1.00.85964912280701760.9090909090909091
cutoff0.80.40.2
Out[41]:

In [42]:
# Multiclass Classification: Choosing the categories
model.classification_report(labels = ["Iris-versicolor", "Iris-virginica"])
Iris-versicolorIris-virginica
auc0.9960.9960000000000001
prc_auc0.99252387996411740.9921025338869698
accuracy0.95333333333333340.9666666666666667
log_loss0.03756150535421120.0344348556530513
precision0.87719298245614030.9090909090909091
recall1.01.0
f1_score0.96373056994818650.9743589743589743
mcc0.90321064745950070.929320377284585
informedness0.93000000000000020.95
markedness0.87719298245614040.9090909090909092
csi0.87719298245614030.9090909090909091
cutoff0.3230.23
Out[42]: