• +91 9723535972
  • info@interviewmaterial.com

Data Science Interview Questions and Answers

Question - Write a function that when called with a confusion matrix for a binary classification model returns a dictionary with its precision and recall.

Answer -

We can use the below for this purpose:

def calculate_precsion_and_recall(matrix):
  true_positive  = matrix[0][0]
  false_positive  = matrix[0][1]
  false_negative = matrix[1][0]
  return {
    'precision': (true_positive) / (true_positive + false_positive),
    'recall': (true_positive) / (true_positive + false_negative)
  }

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners