reiinakano / scikit-plot

An intuitive library to add plotting functionality to scikit-learn objects.
MIT License
2.43k stars 284 forks source link

Is there a [problem in precision_recall_curve? #99

Open Cbanyungong opened 5 years ago

Cbanyungong commented 5 years ago

Dear sir Thanks for your excellent work in the scikit-plot. I am confused in the function of precision_recall_curve. As we all know,the PR curve goes through two points:(0,1) and(1,0).But I used the test code to draw the curve and found that the curve does not goes the point of (1,0).I used the below code and get the curve.

import scikitplot as skplt rf = GaussianNB () rf = rf.fit(X_train, y_train) y_pred = rf.predict(X_test) skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True) plt.show()

lugq1990 commented 5 years ago

I'm sorry I can't get your question idea. You want to plot the precision_recall curve, but your code is just using plot_confusion_matrix for confusion matrix. In fact, if you want to use plot_precision_recall_curve, you have to make your prediction probability based on your test data, just like this: prob = rf.predict_proba(X_test) skplt.metrics.plot_precision_recall_curve(y_test, prob) plt.show()