Recall answers "of the real positives, how many did we find?". Specificity answers the mirror question for the negative class: "of the real negatives, how many did we correctly leave alone?". A spam filter with high recall and low specificity catches spam but buries legitimate mail.
Implement specificity(y_true, y_pred, positive=1). Treat positive as the positive class and everything else as negative. Return TN / (TN + FP).
0.0.ValueError.Open one at a time. Each gives away a little more than the last.
Negative rows are y_true != positive. Among them, a prediction counts as a true negative when it is also not positive.
np.mean(y_pred[neg] != positive) over the negative rows gives the same ratio directly.
No results yet
Run your code to check it against the examples, or submit to run every test.