Home > Backend Development > Python Tutorial > How does python calculate the auc indicator?

How does python calculate the auc indicator?

零下一度
Release: 2017-07-19 23:27:04
Original
2344 people have browsed it

1. Install scikit-learn

1.1 Scikit-learn depends on

  • ##Python (>= 2.6 or >= 3.3) ,

  • NumPy (>= 1.6.1),

  • SciPy (>= 0.9).

Check the versions of the above three dependencies respectively,

python -V Result: Python 2.7.3

python -c 'import scipy; print scipy.version.version' scipy version result: 0.9.0
python -c "import numpy; print numpy.version.version" numpy result: 1.10.2
1.2 Scikit-learn installation
If you have installed NumPy, SciPy and python and all meet the requirements If the conditions required in 1.1 are met, you can directly run sudo
pip install -U scikit-learn Perform the installation.

2. Calculate auc indicator

   sklearn.metrics  y_true = np.array([0, 0, 1, 1 y_scores = np.array([0.1, 0.4, 0.35, 0.8 roc_auc_score(y_true, y_scores)

输出:0.75
Copy after login
 <br>
Copy after login

3. Calculate roc curve

   sklearn  y = np.array([1, 1, 2, 2 scores = np.array([0.1, 0.4, 0.35, 0.8 fpr, tpr, thresholds = metrics.roc_curve(y, scores, pos_label=2    thresholds

输出:
array([ 0. ,  0.5,  0.5,  1. ])
array([ 0.5,  0.5,  1. ,  1. ])
array([ 0.8 ,  0.4 ,  0.35,  0.1 ])
Copy after login

The above is the detailed content of How does python calculate the auc indicator?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template