<p dir="auto">Here is an example, when auc is calculated wrong:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
from sklearn.metrics import roc_curve, auc
p = np.array([3E-011, 5E-11, 2E-010, 1E-008, 2E-006, 1.29E-005, 0.0003, 0.1, 0.2, 0.3, 0.46])
p = np.expand_dims(p, axis=1)
y = np.array([0, 0,  0, 1,  0, 0, 1, 1, 1, 1, 1])
fpr, tpr, thresholds = roc_curve(y, p, pos_label=1)
roc_auc = auc(fpr, tpr)"><pre class="notranslate"><code class="notranslate">import numpy as np
from sklearn.metrics import roc_curve, auc
p = np.array([3E-011, 5E-11, 2E-010, 1E-008, 2E-006, 1.29E-005, 0.0003, 0.1, 0.2, 0.3, 0.46])
p = np.expand_dims(p, axis=1)
y = np.array([0, 0,  0, 1,  0, 0, 1, 1, 1, 1, 1])
fpr, tpr, thresholds = roc_curve(y, p, pos_label=1)
roc_auc = auc(fpr, tpr)
</code></pre></div>
<p dir="auto">with these values it should be 0.9333333 (I checked it in R), but sklearn gives 0.883333333333.<br>
If I rescale p with <code class="notranslate">MinMaxScaler()</code>, I get the right answer.<br>
I  also noticed that it has different number of  <code class="notranslate">n_thresholds</code>:<br>
in the first case <code class="notranslate">n_thresholds=8</code>, and  when I scale the probabilities <code class="notranslate">n_thresholds=9</code>.<br>
Thank you very much for considering this problem!</p>
<p dir="auto">pred=[1e-10, 0, 0]<br>
sol=[1, 0, 0]<br>
metrics.roc_auc_score(sol, pred) # 0.5, wrong, 1 is correct</p>
<p dir="auto">pred=[1, 0, 0]<br>
sol=[1, 0, 0]<br>
metrics.roc_auc_score(sol, pred) # 1 correct</p>