Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6836065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:18:36+00:00 2026-05-26T23:18:36+00:00

I am using nltk with Python and I would like to plot the ROC

  • 0

I am using nltk with Python and I would like to plot the ROC curve of my classifier (Naive Bayes). Is there any function for plotting it or should I have to track the True Positive rate and False Positive rate ?

It would be great if someone would point me to some code already doing it…

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:18:37+00:00Added an answer on May 26, 2026 at 11:18 pm

    PyROC looks simple enough: tutorial, source code

    This is how it would work with the NLTK naive bayes classifier:

    # class labels are 0 and 1
    labeled_data = [
        (1, featureset_1),
        (0, featureset_2),
        (1, featureset_3),
        # ...
    ]
    
    # naive_bayes is your already trained classifier,
    # preferrably not on the data you're testing on :)
    
    from pyroc import ROCData
    
    roc_data = ROCData(
        (label, naive_bayes.prob_classify(featureset).prob(1))
        for label, featureset
        in labeled_data
    )
    roc_data.plot()
    

    Edits:

    • ROC is for binary classifiers only. If you have three classes, you can measure the performance of your positive and negative class separately (by counting the other two classes as 0, like you proposed).
    • The library expects the output of a decision function as the second value of each tuple. It then tries all possible thresholds, e.g. f(x) >= 0.8 => classify as 1, and plots a point for each threshold (that’s why you get a curve in the end). So if your classifier guesses class 0, you actually want a value closer to zero. That’s why I proposed .prob(1)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any python module (may be in nltk python) to remove internet slang/
I would like to find the relatedness (not similarity) between two words using Python.
I am new to python and am using it to use nltk in my
I am using Python and NLTK to build a language model as follows: from
I am building a spam filter using the NLTK in Python. I now check
I'm using the Natural Language Toolkit for python and in it there is a
Using Python and the NLTK I have written a regex to find words with
Using the adapter pattern, combined with IoC (specificly Unity), I would like to create
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.