get true negatives from confusion matrix

def perf_measure(y_actual, y_hat):
    TP = 0
    FP = 0
    TN = 0
    FN = 0

    for i in range(len(y_hat)): 
        if y_actual[i]==y_hat[i]==1:
           TP += 1
        if y_hat[i]==1 and y_actual[i]!=y_hat[i]:
           FP += 1
        if y_actual[i]==y_hat[i]==0:
           TN += 1
        if y_hat[i]==0 and y_actual[i]!=y_hat[i]:
           FN += 1

    return(TP, FP, TN, FN)

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
true positive and true negative confusion matrix code false negative rate confusion matrix how important is false negative values in confusion matrix confusion matrix false negative what is false positive and false negative in confusion matrix how to calculate false negative confusion matrix confusion matrix if true positive zer0 confusion matrix false positives false negative in confusion matrix sklearn what is false positive in confusion matrix how to calculate true positive from confusion matrix true negative means in confusion matrix get false negatives rows from confusion matrix python get false negatives rows from confusion matrix false positive false negative confusion matrix calculate true positive from confusion matrix how to find confusion matrix with true positive and true negative sklearn confusion matrix true negatives on top true negative false negative confusion matrix calculating true negatives from a 3*3 confusion matrix true positive and true negative confusion matrix python confusion matrix true negative confusion matrix false positive true positive rate in confusion matrix formula true positive rate in confusion matrix confusion matrix true positive true negative rate confusion matrix false positive confusion matrix definition plot confusion matrix with true positive and true negative code for calculating true positive from confusion matrix false negative confusion matrix get true positive from confusion matrix scikit learn true negative in confusion matrix false positive confusion matrix false positive in confusion matrix what is true positive in confusion matrix true positive confusion matrix true positive and true negative confusion matrix true positive in confusion matrix false positive rate python false positive rate test sklearn calculate true positive and true negative rate using python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source