Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve using python Calculate 8 evaluation metrics out of the previous results stored in the res object, using the ground truth label Ytest and the

solve using python

image text in transcribed

image text in transcribed

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. H \# Task 7. \# Calculate TP, FP, TN, FN, Accuracy, Precision, Recall, and F-1 score \# We assume that label y=1 is positive, and y=0 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 Recall = None F1= None \#\#\#\# END YOUR CODE \#\#\#\#\# metrics ={ 'TP' : TP, 'FP': FP, 'TN' : TN, 'FN': FN, 'Accuracy' : Accuracy, 'Precision': Precision, 'Recall': Recall, 'F1': F1 \} return metrics Y \#\#\#\# DO NOT CHANGE THE CODE BELOW \#\#\#\# \# Evaluate Task 7 m= calc_metrics(Y_test, res['Y_pred_test']) print('TP ={},FP={},TN={},FN={},\ AAccuracy ={}, Precision ={},Recall={},F1={}.format( )) m[ 'TP' ],m[ 'FP' ],m[TN],m[FN '], m[ 'Accuracy'], m[ 'Precision'], m[ 'Recall'], m[ 'F1'] Expected output TP=59FP=11TN=51FN=4Accuracy=0.88Precision=0.8428571428571429Recall=0.9365079365079365F1=0.887218045112782

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

=+Can it illicit audience participation?

Answered: 1 week ago

Question

=+j Explain the essential nature of repatriation.

Answered: 1 week ago