Skip to content
Snippets Groups Projects
Commit decbabe4 authored by Olivier Grisel's avatar Olivier Grisel
Browse files

more PEP8

parent 297ccc43
Branches
No related tags found
No related merge requests found
"""Utilities to evaluate the predictive performance of models"""
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Mathieu Blondel <mathieu@mblondel.org>
# License: BSD Style.
import numpy as np
def confusion_matrix(y, y_):
"""Compute confusion matrix to evaluate the accuracy of a classification
......@@ -77,10 +80,12 @@ def roc_curve(y, probas_):
probas_ = probas_.ravel()
thresholds = np.sort(np.unique(probas_))[::-1]
n_thresholds = thresholds.size
tpr = np.empty(n_thresholds) # True positive rate
fpr = np.empty(n_thresholds) # False positive rate
n_pos = float(np.sum(y == 1)) # nb of true positive
n_neg = float(np.sum(y == 0)) # nb of true negative
for i, t in enumerate(thresholds):
tpr[i] = np.sum(y[probas_ >= t] == 1) / n_pos
fpr[i] = np.sum(y[probas_ >= t] == 0) / n_neg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment