mlnext.score.PRCurve#
- class mlnext.score.PRCurve(tps: ndarray, fns: ndarray, tns: ndarray, fps: ndarray, das: ndarray, tas: ndarray, precision: ndarray, recall: ndarray, thresholds: ndarray)[source]#
Bases:
object
Container for the result of
pr_curve
. Additionally computes the F1-score for each threshold. Can be indexed and returns aConfusionMatrix
for the i-th threshold.- Parameters:
tps (np.ndarray) – An increasing count of true positives, at index i being the number of positive samples assigned a score >= thresholds[i].
fns (np.ndarray) – A count of false negatives, at index i being the number of positive samples assigned a score < thresholds[i].
tns (np.ndarray) – A count of true negatives, at index i being the number of negative samples assigned a score < thresholds[i].
fps (np.ndarray) – A count of false positives, at index i being the number of negative samples assigned a score >= thresholds[i].
das (np.ndarray) – A count of detected anomaly segments, at index i being the number of detected anomalies for a score >= thresholds[i].
tas (np.ndarray) – Total number of anomaly segments.
precision (np.ndarray) – Precision values such that element i is the precision of predictions with score >= thresholds[i].
recall (np.ndarray) – Decreasing recall values such that element i is the recall of predictions with score >= thresholds[i].
thresholds (np.ndarray) – Increasing thresholds on the decision function used to compute precision and recall.
Methods
Converts the container to keyword arguments for Tensorboard.
Attributes
Calculates the accuracy where at index i, the accuracy is the percentage of correctly assigned samples.
Calculates the area-under-curve (auc).
Calculates the F1-score.
Calculates the fraction of detected anomaly segments.
tps
fns
tns
fps
das
tas
precision
recall
thresholds
- property accuracy: ndarray#
Calculates the accuracy where at index i, the accuracy is the percentage of correctly assigned samples.
- Returns:
Returns the accuracy.
- Return type:
np.ndarray
- property auc: float#
Calculates the area-under-curve (auc).
- Returns:
Returns the area-under-curve (auc) for the precision-recall curve.
- Return type:
float
- property f1: ndarray#
Calculates the F1-score.
- Returns:
Returns the F1-score.
- Return type:
np.ndarray
- property recall_anomalies: ndarray#
Calculates the fraction of detected anomaly segments.
- Returns:
Returns the anomaly recall.
- Return type:
np.ndarray
- to_tensorboard() Dict[str, Any] [source]#
Converts the container to keyword arguments for Tensorboard. See https://github.com/tensorflow/tensorboard/blob/master/tensorboard/plugins/pr_curve/README.md.
- Returns:
Returns the pr-curve format expected for Tensorboard.
- Return type:
T.Dict[str, T.Any]