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

  • SEARCH
  • Home
  • 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 6110183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:29:12+00:00 2026-05-23T14:29:12+00:00

I have a dataframe. first column contains my the predictive score (range from 0

  • 0

I have a dataframe. first column contains my the predictive score (range from 0 to 100, smaller values is expected to be in class A, larger values is expected to be in class B) for my model, 2nd column contains the real classification of the entries (either “class A” or “class B”).

How to get confusion matrix with R for different cut off values, as I cannot decide where I should define values < 20 or < 50 as class A yet?

How to do this comparison efficiently with R?

  • 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-23T14:29:12+00:00Added an answer on May 23, 2026 at 2:29 pm

    There’s a number of ways to do this, a reproducible example with your data would have been desirable:

    set.seed(12345)
    test <- data.frame(pred=c(runif(50,0,75),runif(50,25,100)), group=c(rep("A",50), rep("B",50)) )
    table(test$pred<50,test$group)
    

    gives

             A  B
      FALSE 18 34
      TRUE  32 16
    

    So this says 32 A’s were under 50 and 34 B’s were over 50, while 18 A’s were over 50 (wrongly classified) and 16 B’s were under 50 (wrongly classified)

    set.seed(12345)
    test <- data.frame(pred=c(runif(50,0,60),runif(50,40,100)), group=c(rep("A",50), rep("B",50)) )
    table(test$pred<50,test$group)
    

    gives

             A  B
      FALSE  8 40
      TRUE  42 10
    

    In this example, cause of the chosen sampling, your classification is much better.

    The ’50’ in this can then be changed to anything you want, 20, 30, etc.

    table(test$pred<50,test$group)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame with two columns. First column contains categories such as
I have a dataframe with a column of integers that I would like to
Assuming in R, I have a data.frame with the first column representing the time
I have a dataframe where one of the columns contains a set of names.
I have two dataframes and I wish to insert the values of one dataframe
I have a data frame with 22239 rows & 200 columns. The first column
I have a dataframe with approximately 500,000 rows and four columns. The dataframe contains
I have dataframe that was created from the fusion of two dataframes. Both spanned
I have a dataframe in R that I want to randomize, keeping the first
I have a dataframe with numeric entries like this one test <- data.frame(x =

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.