August 2019
Intermediate to advanced
342 pages
9h 35m
English
In the following code, we can see an example of a calculation of ROC metrics, using scikit-learn's methods, such as precision_recall_curve(), average_precision_score(), recall_score(), and f1_score():
import numpy as npfrom sklearn import metricsfrom sklearn.metrics import precision_recall_curvefrom sklearn.metrics import average_precision_scorey_true = np.array([0, 1, 1, 1])y_pred = np.array([0.2, 0.7, 0.65, 0.9])prec, rec, thres = precision_recall_curve(y_true, y_pred)average_precision_score(y_true, y_pred)metrics.precision_score(y_true, y_pred)metrics.recall_score(y_true, y_pred)metrics.f1_score(y_true, y_pred)
Read now
Unlock full access