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:
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/08/64edd42b05cda_1693307945734.jpg)
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/08/64edd43457b82_1693307955734.jpg)
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...
-
Picture this. It's Sunday morning, a few hours before the annual company picnic. The wife, while ironing her dress, asks her husband, "Do we really have to go to the picnic today?" The husband...
-
Problem refer to functions f and g that satisfy f'(2) = 3 and g(2) = -1. In each problem, find h(2) for the indicated function h. h(x) = 4f(x)
-
2. Develop a schedule showing how available cash will be distributed to each class of claims, assuming that (a) the estimated realizable values are actually received and (b) the trustee and other...
-
During 2010, Howard Company purchased land for $375,000. It paid $125,000 in cash and signed a $250,000 mortgage for the rest. The company also sold for $95,000 cash a building that originally cost...
-
Check my work On January 1, 2021, the general ledger of TNT Fireworks includes the following account balances Credit Dahit $ 60,500 28,600 $ 4,000 Account Cash Accounts Receivable Allowance for...
-
Let f(x) be a pdf and let a be a number such that, for all > 0, f(a + ) = f(a - ). Such a pdf is said to be symmetric about the point a. (a) Give three examples of symmetric pdfs. (b) Show that if X...
-
9) Find the tangent line approximation T to the graph of f at the given point. Then complete the table. (Round your answer to four decimal places.) f ( x ) = 5/x^2, (5,1/5) T ( x ) = x 4.9 4.99 5...
-
Once the largest professional services firm in the world and arguably the most respected, Arthur Andersen LLP (AA) has disappeared. The Big 5 accounting firms are now the Big 4. Why did this happen?...
-
Fill in the Blank. Piezoelectric transducers generate electrical ______________ when subjected to mechanical stress.
-
A clockwise variable torque is applied to a flywheel at time \(t=0\) causing its clockwise angular acceleration to decrease linearly with angular displacement \(\theta\) during 20 revolutions of the...
-
With neat block diagram, explain open-loop and closed-loop control systems.
-
Market-Tech, a market research firm, had the following transactions in June, its first month of operations. 1 \( \mathrm{~J}\). Witson invested \(\$ 28,000\) of personal funds in the firm in exchange...
-
***managerial accounting*** PROBLEM 4 (6 pts.) Colt and Company is an online seller of baked goods offering three distinct products. Recent data are: Sales VC Cookie boxes $ 330,000 150,000 $ 180,000...
-
Listed below are common types of current liabilities, contingencies, and commitments: a. Accounts payable b. Bank loans and commercial paper c. Notes payable d. Dividends payable e. Sales and excise...
-
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...
-
Purchased debt instrument with impairment LO9, 11, 13, 14 On 1 January 2019, Biko Banking Ltd purchases a debt instrument with a 5-year term for its fair value of $1000 million (including...
-
Applying accounting theory LO6, 8, 13, 14 Tropical Tours Ltd needs to raise $500 000 to finance the acquisition of a new tour bus. It approached an investment bank that proposed the following...
-
Various financial assets and financial liabilities LO12, 13 Great Adventure Ltd has entered into a number of contracts that are financial instruments as follows. (a) On 1 July 2018, the company...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App