<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;PR AUC  AUC- https://developers.google.com/machine-learning/crash-course/classification/roc-and-auc- http://www.chioka.in/differences-between-roc-auc-and-pr-auc/<jupyter_code>import pandas as pd 
import numpy as np 
import matplotlib.pyplot as plt

from sklearn.metrics import roc_auc_score
from sklearn.metrics import precision_recall_curve
import matplotlib.pyplot as plt
from sklearn.metrics import auc
from sklearn.metrics import average_precision_score,roc_curve
# 30 examples 
y = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1]
y_pred = np.arange(0, 1.0, 1/30)
print(roc_auc_score(y, y_pred))
print(average_precision_score(y, y_pred))
fpr, tpr, threshold = roc_curve(y,y_pred)
t = pd.DataFrame(np.concatenate((fpr.reshape(-1,1), tpr.reshape(-1,1), threshold.reshape(-1,1)),axis=1),columns=['fpr','tpr','threshold'])
t
roc_auc = auc(fpr, tpr)
roc_auc
plt.title('Receiver Operating Characteristic')
plt.plot(fpr, tpr, 'b', label = 'AUC = %0.2f' % roc_auc)
plt.legend(loc = 'lower right')
plt.plot([0, 1], [0, 1],'r--')
plt.xlim([0, 1])
plt.ylim([0, 1])
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
plt.show()<jupyter_output><empty_output><jupyter_text>PR AUChttp://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html<jupyter_code>from sklearn.metrics import precision_recall_curve
import matplotlib.pyplot as plt
average_precision = average_precision_score(y, y_pred)

precision, recall, _ = precision_recall_curve(y, y_pred)

plt.step(recall, precision, color='b', alpha=0.2,
         where='post')
plt.fill_between(recall, precision, step='post', alpha=0.2,
                 color='b')

plt.xlabel('Recall')
plt.ylabel('Precision')
plt.ylim([0.0, 1.05])
plt.xlim([0.0, 1.0])
plt.title('2-class Precision-Recall curve: AP={0:0.2f}'.format(
          average_precision))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16485225505443235, 'fraction_numerical': 0.03784344219803007, 'mean_word_length': 6.228464419475656, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '222372', 'license': 'MIT', 'n_tokens_mistral': 823, 'n_tokens_neox': 767, 'n_words': 127, 'path': '*Performance_Measuring/Area_Under_Curve/PR_ROC_AUC.ipynb', 'repo_name': 'jasjung/Machine_Learnin', 'size': '1929'}