Model.classification_report / report

In [ ]:
Model.report(cutoff = [],
             labels: list = [],
             nbins: int = 10000)

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.
nbins
int
[Used to compute ROC AUC, PRC AUC and the best cutoff] An integer value that determines the number of decision boundaries. Decision boundaries are set at equally spaced intervals between 0 and 1, inclusive. Greater values for nbins give more precise estimations of the metrics, but can potentially decrease performance. The maximum value is 999,999. If negative, the maximum value is used.

Returns

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

Example

In [6]:
from verticapy.datasets import load_iris
iris = load_iris()

# 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(iris, ["PetalLengthCm", "PetalWidthCm"], "Species")
# Multiclass Classification: Using a fixed cutoff
model.report(cutoff = 0.33)
Out[6]:
Iris-setosa
Iris-versicolor
Iris-virginica
auc1.00.99610000000000030.9963000000000002
prc_auc1.00.99255824912851120.9927773021392375
accuracy1.00.95333333333333340.9666666666666667
log_loss0.009182640301213290.03744887025847260.0364849953334055
precision1.00.87719298245614030.9411764705882353
recall1.01.00.96
f1_score1.00.93457943925233630.9504950495049505
mcc1.00.90321064745950070.9254762227411247
informedness1.00.93000000000000020.9299999999999999
markedness1.00.87719298245614040.9209744503862152
csi1.00.87719298245614030.9056603773584906
cutoff0.330.330.33
Rows: 1-12 | Columns: 4
In [7]:
# Multiclass Classification: Using automatic cutoffs
model.report()
Out[7]:
Iris-setosa
Iris-versicolor
Iris-virginica
auc1.00.99610000000000030.9963000000000002
prc_auc1.00.99255824912851120.9927773021392375
accuracy1.00.960.9666666666666667
log_loss0.009182640301213290.03744887025847260.0364849953334055
precision1.00.90740740740740740.9090909090909091
recall1.00.981.0
f1_score1.00.94230769230769240.9523809523809523
mcc1.00.91334625903262390.929320377284585
informedness1.00.92999999999999990.95
markedness1.00.89699074074074090.9090909090909092
csi1.00.89090909090909090.9090909090909091
cutoff0.90290.540.0881
Rows: 1-12 | Columns: 4
In [8]:
# Multiclass Classification: Customized Cutoffs
model.report(cutoff = [0.8, 0.4, 0.2])
Out[8]:
Iris-setosa
Iris-versicolor
Iris-virginica
auc1.00.99610000000000030.9963000000000002
prc_auc1.00.99255824912851120.9927773021392375
accuracy1.00.960.96
log_loss0.009182640301213290.03744887025847260.0364849953334055
precision1.00.90740740740740740.9074074074074074
recall1.00.980.98
f1_score1.00.94230769230769240.9423076923076924
mcc1.00.91334625903262390.9133462590326239
informedness1.00.92999999999999990.9299999999999999
markedness1.00.89699074074074090.8969907407407409
csi1.00.89090909090909090.8909090909090909
cutoff0.80.40.2
Rows: 1-12 | Columns: 4
In [9]:
# Multiclass Classification: Choosing the categories
model.report(labels = ["Iris-versicolor", "Iris-virginica"])
Out[9]:
Iris-versicolor
Iris-virginica
auc0.99610000000000030.9963000000000002
prc_auc0.99255824912851120.9927773021392375
accuracy0.960.9666666666666667
log_loss0.03744887025847260.0364849953334055
precision0.90740740740740740.9090909090909091
recall0.981.0
f1_score0.94230769230769240.9523809523809523
mcc0.91334625903262390.929320377284585
informedness0.92999999999999990.95
markedness0.89699074074074090.9090909090909092
csi0.89090909090909090.9090909090909091
cutoff0.540.0881
Rows: 1-12 | Columns: 3