plt xlabel ( '$ 'plt ylabel ( '$ ^{mathcal { }_p} {tau }( )$'plt legend (plots ,('data points ''true ','$ = $underfit ''$ = $correct ','$ = $overfit ')plt savefig ('polyfitpy pdf ',format ='pdf 'plt show (the last code snippet which imports the previous codegenerates the test data and plots the graph of the test lossas shown in figure polyreg py from polyreg import generate test data u_test y_test generate_data (beta sig nmse [x_test np ones (( )for in p_range if x_test np hstack (x_test u_test **( - ))y_hat x_test betahat [ppredictions mse append (np sum (y_test y_hat )** / )plt plot(p_range mse ' 'p_range mse 'bo'plt xticks ticks p_range plt xlabel ('number of parameters $ 'plt ylabel ('test loss ' tradeoffs in statistical learning the art of machine learning in the supervised case is to make the generalization risk ( or expected generalization risk ( as small as possiblewhile using as few computational resources as possible in pursuing this goala suitable class of prediction functions has to be chosen this choice is driven by various factorssuch as the complexity of the class ( is it rich enough to adequately approximateor even containthe optimal prediction function ?)the ease of training the learner via the optimization program ( )how accurately the training loss ( estimates the risk ( within class gthe feature types (categoricalcontinuousetc as resultthe choice of suitable function class usually involves tradeoff between conflicting factors for examplea learner from simple class can be trained very