Answered step by step
Verified Expert Solution
Link Copied!

Question

...
1 Approved Answer

Could you help me with TODO part? #TODO: fill in In the cell below complete the function that computes the average loss (empirical risk) for

Could you help me with TODO part?

#TODO: fill in

image text in transcribed
In the cell below complete the function that computes the average loss (empirical risk) for an a level test. : # TODO: complete the function def compute_alpha_average_loss (p_values, reality, alpha, factor_k) : Computes the observed average loss for an alpha level test. Inputs : p_values: array of floats, p-value[i] is the p-values associated with test subject i. reality: array of 0/1s alpha: float, threshold for rejecting the null hypothesis factor_k: float, quantifies the ratio of the negative consequences of false negatives compared to false positives Outputs : average_loss: float, average observed loss # HINT: Your code should take advantage of functions already defined in this notebook. average_loss = # TODO: fill in return average_loss : # Validation tests do not modify alpha_values = [0.05, 0.1, 0.2, 0.4] k_factors = [0, 10, 100] inputs = list(itertools . product (alpha_values, k_factors) ) outputs = [compute_alpha_average_loss (p_values, reality, *inp) for inp in inputs ] hash_list = ['8d0a5f87d0563079e709696527b22b2c', '1370c7dde8b12484elf9f3376ec72693', f106401ad5ceaala89d99bcc773f8db' , 'd92f2ab695c640d68b760f055704d892' , '066517035812371 facdef5f27ff5c7c9' , '91709ca4894f0586311f697527479564' '49f12f9c625759e7bb9e3f2fe5cee530' , '3888849642lef7c75527678fle718c19' , '701a4e33513e8e55f9leac027a42b6fe' , 'a6107b1736a62ac0clc79546cc4ec85f' , 'did940b705c4e66fc40cdealc2f7c57', 'a57699387860e7d6b6de25ea47201a0b' ] for i, inp in enumerate (inputs) : print ( 'At level alpha={} and k={} the average loss is {: .3f}' . format (*inp, outputs[i]) ) assert ( get_hash (outputs [i] )==hash_list[i] ) print ( 'Test passed! ' )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Quantitative Analysis For Management

Authors: Barry Render, Ralph M. Stair, Michael E. Hanna

11th Edition

162

Students also viewed these Mathematics questions