estimate the test loss using test set with the same sample size figure shows that there is some variation in the test lossesdue to the randomness in both the training and test sets to obtain an accurate estimate of the expected generalization risk ( )take the average of the test losses we see that for the estimate in figure is close to the true expected generalization risk test loss number of parameters figure independent estimates of the test loss show some variability cmctestloss py import numpy as np matplotlib pyplot as plt from numpy random import rand randn from numpy linalg import solve def generate_data (beta sig ) rand( ( *np arange ( )beta sig randn ( return uy beta np array ([[ - - ]] sig betahat {plt figure figsize =[ , ]totmse np zeros ( max_p p_range np arange ( max_p for in range ( , )