Model.score

In [ ]:
Model.score(method: str = "accuracy",
            pos_label: Union[int, float, str] = None,
            cutoff: float = -1,
            nbins: int = 10000,)

Computes the model score.

Parameters

Name Type Optional Description
method
str
The method to use to compute the score.
  • accuracy : Accuracy
  • auc : Area Under the Curve (ROC)
  • best_cutoff : Cutoff which optimised the ROC Curve prediction.
  • bm : Informedness = tpr + tnr - 1
  • csi : Critical Success Index = tp / (tp + fn + fp)
  • f1 : F1 Score
  • logloss : Log Loss
  • mcc : Matthews Correlation Coefficient
  • mk : Markedness = ppv + npv - 1
  • npv : Negative Predictive Value = tn / (tn + fn)
  • prc_auc : Area Under the Curve (PRC)
  • precision : Precision = tp / (tp + fp)
  • specificity : Specificity = tn / (tn + fp)
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. If the parameter is not between 0 and 1, an automatic cutoff is computed.
nbins
int
[Only when method is set to auc|prc_auc|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 AUC, but can potentially decrease performance. The maximum value is 999,999. If negative, the maximum value is used.

Returns

float : score

Example

In [26]:
# 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")
# Logloss
model.score(method = "log_loss", pos_label = "Iris-virginica")
Out[26]:
0.037429015840143
In [27]:
# Global accuracy
model.score(method = "accuracy")
Out[27]:
0.946666666666667