Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.a: Compute average empirical loss Assume we have a sample of NV patients for which a test outputs the following confusion matrix: Decision = 0

image text in transcribed
1.a: Compute average empirical loss Assume we have a sample of NV patients for which a test outputs the following confusion matrix: Decision = 0 Decision = 1 Reality = 0 TN FP Reality = 1 FN TP Compute the average loss this procedure incurs by summing up the losses for every mis-diagnosis and then dividing by the total number of tests. [2] : # TODO: fill in def compute_average_loss (results_dictionary, factor_k) : Function that computes average loss for a given confusion matrix and a multiplicaltive k_factor that compares the consequences of false nagatives and false positives. Inputs : results_dictionary : a dictionary with the counts of TP, FP, TN and FN k_factor : float, quantifies the ratio of the negative consequences of false negatives compared to false positives Outputs : average_loss : float TP count = results_dictionary [ 'TP_count' ] FP_count = results_dictionary [ 'FP_count' ] IN count = results_dictionary [ 'TN_count' ] FN count = results_dictionary [ 'FN_count' ] average_loss return ( average_loss) [3] : # Running validation tests: Do not modify res_dict = {'TP_count' : 100, 'FP_count' : 20, 'TN_count' : 450, 'FN_count' : 30} k_factors = [0, 10, 100] hash_list = ['ab51c1986c756154d0e3feb4f5a5e829', '91f25a837f3db78306b0ad2ef0437ff9' , '3fc1803a77013426e67076041de152db' ] for i, k in enumerate (k_factors) : average_loss = compute_average_loss (res_dict, k) print ( "For k = {}, the average loss is {: .3f}". format (k, average_loss) ) assert hash_list [i] == get_hash (average_loss ) print ( 'Test passed! ' )

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_2

Step: 3

blur-text-image_3

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

Mathematical Analysis For Quantitative Finance

Authors: Daniele Ritelli, Giulia Spaletta

1st Edition

1351245104, 9781351245104

More Books

Students also viewed these Mathematics questions

Question

1. Avoid conflicts in the relationship

Answered: 1 week ago

Question

1. What will happen in the future

Answered: 1 week ago