Question: 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

solve using python Calculate 8 evaluation metrics out of the previous results

stored in the "res" object, using the ground truth label Ytest and

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!