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

How does python calculate the auc indicator?

零下一度
零下一度Original
2017-07-19 23:27:042354browse

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
 <br>

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 ])

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!

Statement:
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