How to optimize precision recall curve instead of AUC-ROC curve in python scikit-learn?

I ask the following question proposed in a previous post - Good ROC curve, but poor accuracy recall curve . I am using the default setting with Python scikit-learn. It seems like optimization on AUC-ROC, but I'm more interested in optimizing recall accuracy. Below are my codes.

# Get ROC 
y_score = classifierUsed2.decision_function(X_test)
false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_score)
roc_auc = auc(false_positive_rate, true_positive_rate)
print 'AUC-'+ethnicity_tar+'=',roc_auc
# Plotting
ax1.plot(false_positive_rate, true_positive_rate, c=color, label=('AUC-'+ethnicity_tar+'= %0.2f'%roc_auc))
ax1.plot([0,1],[0,1], color='lightgrey', linestyle='--')
ax1.legend(loc='lower right', prop={'size':8})

# Get P-R pairs
precision, recall, prThreshold = precision_recall_curve(y_test, y_score)
# Plotting
ax2.plot(recall, precision, c=color, label=ethnicity_tar)
ax2.legend(loc='upper right', prop={'size':8})

Where and how do I embed python codes to change a setting so that I can optimize accuracy feedback?

+4
source share
1 answer

There are actually two questions:

  • , ?
  • , ?

:

1. . ( -) .

2. , . GridSearchCV, scoring='average_precision'. - .

, ( ), . . SVM, .

+1

All Articles