introduction to machine learning and deep learning #create random data np linspace(- , , signal noise np random normal( signal noise x_train [ : y_train [ : train_rmse [test_rmse [degree #define range of values for lambda lambda_reg_values np linspace( , , for lambda_reg in lambda_reg_values#for each value of lambdacompute build model and compute performance for lambda_reg in lambda_reg_valuesx_train np column_stack([np power(x_train,ifor in range( ,degree)]model np dot(np dot(np linalg inv(np dot(x_train transpose(),x_trainlambda_reg np identity(degree))x_train transpose()),y_trainpredicted np dot(model[np power( ,ifor in range( ,degree)]train_rmse append(np sqrt(np sum(np dot( [ : predicted[ : ]y_train predicted[ : ])))test_rmse append(np sqrt(np sum(np dot( [ :predicted[ :] [ :predicted[ :])))#plot the performance over train and test dataset plt plot(lambda_reg_valuestrain_rmseplt plot(lambda_reg_valuestest_rmse