Calculate 8 evaluation metrics out of the previous results stored in the res object, using the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 = {}, \nAccuracy = {}, 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 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 = {}, \nAccuracy = {}, 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
Expert Answer:
Answer rating: 100% (QA)
The following code calculates the 8 evaluation metrics PYTHON def calcmetricsYtest Ypredtest Calc... View the full answer
Related Book For
Fundamentals of Cost Accounting
ISBN: 978-0077398194
3rd Edition
Authors: William Lanen, Shannon Anderson, Michael Maher
Posted Date:
Students also viewed these programming questions
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Log File Overview Log files (also spelled logfiles), are files used by computers to log events. Software programs, background processes, services, or transactions between services, including the...
-
How do items discussed in the critical audit matters section differ from items in an unqualified opinion with an emphasis-of-matter paragraph? Question 1: (20) A. On November 1, 2019. James Andersun...
-
An Add curved arrows to the following reactions to indicate the flow of electrons ineach: (a) H-CI D-CI = H. H. (b) -I CH CH CH
-
Safe Systems most recently reconciled its bank balance on April 30 and reported two checks outstanding at that time, No. 1771 for $781 and No. 1780 for $1,325.90. The following information is...
-
Two blocks of the same inertia \((10 \mathrm{~kg})\) but different sizes are falling freely. Compare the force exerted by the Earth on the two blocks.
-
Shelly Zumaya (2220 East Hennepin Avenue, Minneapolis, MN 55413) is the president and sole shareholder of Kiwi Corporation (stock basis of $400,000). Incorporated in 2004, Kiwi Corporation's sole...
-
Sketch a hand written a Enhanced ER diagram for this table and fix the error if there is Message cation D Notification UserNotif Password UserName UserID RoleID User D Phone User # Role securityID...
-
Consider the 2013 declined loan data from LendingClub titled RejectStatsB2013. Similar to the analysis done in the chapter, lets scrub the employment length. Because our analysis requires risk...
-
Below is an indifference curve map for a consumer who consumes two goods, X and Y. The consumer's initial optimal consumption bundle is point A. After a price change, the consumer's new optimal...
-
The FTCA applies to a. intentional torts committed by law enforcement officials. b. a federal employees acts that are considered discretionary. c. a federal employees acts that are part of a planning...
-
What types of activities constitute the unauthorized practice of law? a. Why is it important that attorneys review all of the work produced by their legal assistants? b. How does the relationship...
-
A client could be considered contributorily negligent if they a. fail to follow a doctors instructions. b. lie to their attorney. c. delay seeking medical attention. d. all of the above.
-
Activities carried out by water and gas utilities are considered ____________ functions of a local government.
-
Legal assistants a. should never discuss the status of a clients case. b. can shield attorneys from some of the interpersonal tasks with clients that are time-consuming. c. can listen to clients...
-
5. How much would you need to deposit in an account now in order to have $5,000 in the account in 5 years? Assume the account earns 2% interest compounded monthly. 10. You deposit $300 each month...
-
Below are various resources and activities for a social services agency that helps homeless people get housing. Required Indicate whether each of the following are likely to be unit-level or...
-
Ashland Corporation, a merchandising firm, is preparing its cash budget for October. The following information is available concerning its inventories: Inventories at beginning of October . . . . . ....
-
Hartman Companys Lucas plant manufactures thermostatic controls. Plant management has experienced fluctuating monthly overhead costs and wants to estimate overhead costs accurately to plan its...
-
What is the difference between an F+ and an Hfr strain? Which type of strain can transfer many bacterial genes to recipient cells?
-
What is the role of the origin of transfer during conjugation involving F+ and Hfr strains? What is the significance of the direction of transfer in Hfr conjugation?
-
What is the role of sex pili during conjugation?
Study smarter with the SolutionInn App