0

I'm currently doing a project on Fake News Detection, and trying to compare the accuracies of different algorithms that I have utilized. Now I have the ROC curves, which look like this:

enter image description here

So far what I have managed to code is this:

plt.figure(0).clf()

for model, name in [ (mn_count_clf, 'multinomial nb count'),
                     (mn_tfidf_clf, 'multinomial nb tfidf'),
                     (pa_tfidf_clf, 'passive aggressive'),
                     (svc_tfidf_clf, 'svc'),
                     (sgd_tfidf_clf, 'sgd')]:
    if 'count' in name:
        pred = model.predict_proba(count_test)[:,1]
    elif 'multinomial' in name:
        pred = model.predict_proba(tfidf_test)[:,1]
    else: 
        pred = model.decision_function(tfidf_test)
    fpr, tpr, thresh = metrics.roc_curve(y_test.values, pred, pos_label='REAL')
    plt.plot(fpr,tpr,label="{}".format(name))

plt.legend(loc=0)

which is in python, used from scikit-learn. The curves are of different colours, which is partially what I'd hoped for.

Now, what I'm trying to do, for the sake of clarity, is to change the styles of the different plots that are , i.e. use dotted lines, dashed lines and lines of different colours for different plots. Any help is appreciated.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • Look here for different styles you can pass into the `plot()` method:- https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html – Vivek Kumar Jan 19 '18 at 06:35
  • Use option `'r.'` for red dots, `'g--'` for green dashed line, `'b-'` for solid blue line etc... – Julien Jan 19 '18 at 06:36
  • I did as you suggested @Julien, but the implementation of your method applies to all the curves. For example, adding `g--` after fpr,tpr in the `plot()` method gives dashed lines and green colour to all the curves. I'm looking for different styles for each plot. – Yogesh Sudheer Modak Jan 19 '18 at 08:14
  • Thanks for marking this as duplicate @ImportanceOfBeingErnest. It led me to the correct answer. – Yogesh Sudheer Modak Jan 19 '18 at 08:28

0 Answers0