threshold
Thresholding Metrics API
This module provides utility functions to threshold model predictions.
Functions:
-
get_predicted_threshold_indices
–Get prediction indices that are above threshold (confidence level)
-
threshold_predictions
–Get thresholded predictions
Functions
get_predicted_threshold_indices
get_predicted_threshold_indices(y_prob: npt.NDArray, y_pred: npt.NDArray, threshold: float = 0.5) -> npt.NDArray
Get prediction indices that are above threshold (confidence level). This is useful to remove weak predictions that can happen due to noisy data or poor model performance.
Parameters:
-
y_prob
(NDArray
) –Model output as probabilities
-
y_pred
(NDArray
) –Model predictions. Defaults to None.
-
threshold
(float
, default:0.5
) –Confidence level
Returns:
-
NDArray
–npt.NDArray: Indices of y_prob that satisfy threshold
Source code in neuralspot_edge/metrics/threshold.py
threshold_predictions
threshold_predictions(y_prob: npt.NDArray, y_pred: npt.NDArray, y_true: npt.NDArray, threshold: float = 0.5) -> tuple[npt.NDArray, npt.NDArray, npt.NDArray]
Get prediction indices that are above threshold (confidence level). This is useful to remove weak predictions that can happen due to noisy data or poor model performance.
Parameters:
-
y_prob
(NDArray
) –Model output as probabilities
-
y_pred
(NDArray
) –Model predictions. Defaults to None.
-
y_true
(NDArray
) –True labels
-
threshold
(float
, default:0.5
) –Confidence level. Defaults to 0.5.
Returns:
-
tuple[NDArray, NDArray, NDArray]
–tuple[npt.NDArray, npt.NDArray, npt.NDArray]: Thresholded predictions