-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chuvalniy
committed
Feb 13, 2024
1 parent
90cf485
commit b3c76a6
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.54 KB
tests/metrics/classifciation/__pycache__/test_roc_auc_score.cpython-311-pytest-7.4.4.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import numpy as np | ||
|
||
from src.metrics import roc_auc_score | ||
|
||
|
||
def test_roc_auc_identical_labels(): | ||
y_true = np.array([1, 0, 1, 0, 1]) | ||
y_pred = np.array([1, 0, 1, 0, 1]) | ||
|
||
expected_roc_auc = 1.0 | ||
roc_auc = roc_auc_score(y_true, y_pred) | ||
|
||
assert np.isclose(expected_roc_auc, roc_auc, atol=1e-5, rtol=1e-5) | ||
|
||
|
||
def test_roc_auc_reversed_labels(): | ||
y_true = np.array([1, 0, 1, 0, 1]) | ||
y_pred = np.array([0, 1, 0, 1, 0]) | ||
|
||
expected_roc_auc = 0.0 | ||
roc_auc = roc_auc_score(y_true, y_pred) | ||
|
||
assert np.isclose(expected_roc_auc, roc_auc, atol=1e-5, rtol=1e-5) | ||
|
||
|
||
def test_roc_auc_all_true(): | ||
y_true = np.array([1, 0, 0, 0, 1]) | ||
y_pred = np.array([1, 1, 1, 1, 1]) | ||
|
||
expected_roc_auc = 0.5 | ||
roc_auc = roc_auc_score(y_true, y_pred) | ||
|
||
np.isclose(expected_roc_auc, roc_auc, atol=1e-5, rtol=1e-5) | ||
|
||
|
||
def test_roc_auc_equal_prob(): | ||
y_true = np.array([1, 0, 0, 0, 1]) | ||
y_pred = np.array([0.5, 0.5, 0.5, 0.5, 0.5]) | ||
|
||
expected_roc_auc = 0.5 | ||
roc_auc = roc_auc_score(y_true, y_pred) | ||
|
||
np.isclose(expected_roc_auc, roc_auc, atol=1e-5, rtol=1e-5) | ||
|
||
|
||
def test_roc_auc_close_to_target(): | ||
y_true = np.array([1, 0, 0, 0, 1]) | ||
y_pred = np.array([0.9, 0.1, 0.1, 0.1, 0.9]) | ||
|
||
expected_roc_auc = 1.0 | ||
roc_auc = roc_auc_score(y_true, y_pred) | ||
|
||
np.isclose(expected_roc_auc, roc_auc, atol=1e-5, rtol=1e-5) |