Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Calculate 8 evaluation metrics out of the previous results stored in the res object, using the ground truth label Ytest and the predictions on
Calculate 8 evaluation metrics out of the previous results stored in the "res" object, using the ground truth label Ytest and the predictions on Ytest, which is stored in res['Y_pred_test']. NOTE: We assumte that label y = 1 is positive, and y = 0 is negative. # Task 7. # Calculate TP, FP, TN, FN, Accuracy, Precision, Recall, and F-1 score # We assume that Label y = 1 is positive, and y = e is negativel def calc_metrics (Y_test, Y_pred_test): Calculate metrics Args: Y test test label Y_pred_test-predictions on test data. Return: metrics a dict object assert (Y_test.shape ==Y_pred_test.shape) ##### START YOUR CODE ##### TP = None FP None TN= None FN= None Accuracy None Precision = None None Recall F1 = None ##### END YOUR CODE ##### metrics = { } 'TP': TP, 'FP': FP, 'TN': IN, 'FN': FN, 'Accuracy': Accuracy, 'Precision': Precision, 'Recall': Recall, 'F1': F1 authe nt, you erver #### DO NOT CHANGE THE CODE BELOW #### # Evaluate Task 7 m = calc_metrics (Y_test, res['Y_pred_test']) print('TP = {}, FP = {}, TN = {}, FN = {}, Accuracy = {}, Precision = {}, Recall = {}, F1 {}, F1 = {}'.format( m['TP'], m['FP'], m['TN'], m['FN'], m['Accuracy'], m['Precision'], m['Recall'], m['F1'] )) Expected output TP = 59 | FP = 11 | TN = 51 | FN = 4 Accuracy = 0.88 | Precision = 0.8428571428571429 | Recall = 0.9365079365079365 | F1 = 0.887218045112782
Step by Step Solution
★★★★★
3.41 Rating (173 Votes )
There are 3 Steps involved in it
Step: 1
The following code calculates the 8 evaluation metrics PYTHON def calcmetricsYtest Ypredtest Calc...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started