mlnext.score.point_adjust_metrics#

mlnext.score.point_adjust_metrics(*, y_hat: ndarray, y: ndarray) DataFrame[source]#

Calculates the performance metrics for various k in [0, 100].

Parameters:
  • y_hat (np.ndarray) – Label predictions.

  • y (np.ndarray) – Ground truth.

Returns:

Returns a dataframe with the k as index and the corresponding metrics for each k.

Return type:

pd.DataFrame

See also

:meth:mlnext.plot.plot_point_adjust_metrics: For plotting the results.

Example

>>> import mlnext
>>> import numpy as np
>>> point_adjust_metrics(
...   np.array([0, 1, 1, 0]), np.array([0, 1, 1, 1]))
     accuracy  precision    recall   f1   roc_auc
0        1.00        1.0  1.000000  1.0  1.000000
1        1.00        1.0  1.000000  1.0  1.000000
2        1.00        1.0  1.000000  1.0  1.000000
3        1.00        1.0  1.000000  1.0  1.000000
4        1.00        1.0  1.000000  1.0  1.000000
5        1.00        1.0  1.000000  1.0  1.000000
10       1.00        1.0  1.000000  1.0  1.000000
15       1.00        1.0  1.000000  1.0  1.000000
20       1.00        1.0  1.000000  1.0  1.000000
25       1.00        1.0  1.000000  1.0  1.000000
30       1.00        1.0  1.000000  1.0  1.000000
35       1.00        1.0  1.000000  1.0  1.000000
40       1.00        1.0  1.000000  1.0  1.000000
45       1.00        1.0  1.000000  1.0  1.000000
50       1.00        1.0  1.000000  1.0  1.000000
55       1.00        1.0  1.000000  1.0  1.000000
60       1.00        1.0  1.000000  1.0  1.000000
65       1.00        1.0  1.000000  1.0  1.000000
70       0.75        1.0  0.666667  0.8  0.833333
75       0.75        1.0  0.666667  0.8  0.833333
80       0.75        1.0  0.666667  0.8  0.833333
85       0.75        1.0  0.666667  0.8  0.833333
90       0.75        1.0  0.666667  0.8  0.833333
95       0.75        1.0  0.666667  0.8  0.833333
100      0.75        1.0  0.666667  0.8  0.833333