mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 10:46:29 +03:00
Auto-format
This commit is contained in:
parent
bd435faddd
commit
1f648ecb76
|
@ -338,7 +338,7 @@ class Scorer(object):
|
||||||
# c. Neither the name of the Scikit-learn Developers nor the names of
|
# c. Neither the name of the Scikit-learn Developers nor the names of
|
||||||
# its contributors may be used to endorse or promote products
|
# its contributors may be used to endorse or promote products
|
||||||
# derived from this software without specific prior written
|
# derived from this software without specific prior written
|
||||||
# permission.
|
# permission.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
@ -353,6 +353,7 @@ class Scorer(object):
|
||||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
# DAMAGE.
|
# DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
def _roc_auc_score(y_true, y_score):
|
def _roc_auc_score(y_true, y_score):
|
||||||
"""Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC)
|
"""Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC)
|
||||||
from prediction scores.
|
from prediction scores.
|
||||||
|
@ -490,19 +491,19 @@ def _binary_clf_curve(y_true, y_score):
|
||||||
thresholds : array, shape = [n_thresholds]
|
thresholds : array, shape = [n_thresholds]
|
||||||
Decreasing score values.
|
Decreasing score values.
|
||||||
"""
|
"""
|
||||||
pos_label = 1.
|
pos_label = 1.0
|
||||||
|
|
||||||
y_true = np.ravel(y_true)
|
y_true = np.ravel(y_true)
|
||||||
y_score = np.ravel(y_score)
|
y_score = np.ravel(y_score)
|
||||||
|
|
||||||
# make y_true a boolean vector
|
# make y_true a boolean vector
|
||||||
y_true = (y_true == pos_label)
|
y_true = y_true == pos_label
|
||||||
|
|
||||||
# sort scores and corresponding truth values
|
# sort scores and corresponding truth values
|
||||||
desc_score_indices = np.argsort(y_score, kind="mergesort")[::-1]
|
desc_score_indices = np.argsort(y_score, kind="mergesort")[::-1]
|
||||||
y_score = y_score[desc_score_indices]
|
y_score = y_score[desc_score_indices]
|
||||||
y_true = y_true[desc_score_indices]
|
y_true = y_true[desc_score_indices]
|
||||||
weight = 1.
|
weight = 1.0
|
||||||
|
|
||||||
# y_score typically has many tied values. Here we extract
|
# y_score typically has many tied values. Here we extract
|
||||||
# the indices associated with the distinct values. We also
|
# the indices associated with the distinct values. We also
|
||||||
|
@ -533,8 +534,11 @@ def _stable_cumsum(arr, axis=None, rtol=1e-05, atol=1e-08):
|
||||||
"""
|
"""
|
||||||
out = np.cumsum(arr, axis=axis, dtype=np.float64)
|
out = np.cumsum(arr, axis=axis, dtype=np.float64)
|
||||||
expected = np.sum(arr, axis=axis, dtype=np.float64)
|
expected = np.sum(arr, axis=axis, dtype=np.float64)
|
||||||
if not np.all(np.isclose(out.take(-1, axis=axis), expected, rtol=rtol,
|
if not np.all(
|
||||||
atol=atol, equal_nan=True)):
|
np.isclose(
|
||||||
|
out.take(-1, axis=axis), expected, rtol=rtol, atol=atol, equal_nan=True
|
||||||
|
)
|
||||||
|
):
|
||||||
raise ValueError(Errors.E163)
|
raise ValueError(Errors.E163)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user