Hello,
if I understand your request correctly, you only want a line graph featuring the RSME for each model on the y-axis and the number of predictors on the right axis. Since you know that your predictor is increasing by 1 in every step, you can just create a data.frame
containing the columns number_of_predictors
(e.g. 1:20
) and RMSE
. If you collect your models res_enet_reg_test1
,...,res_enet_reg_test20
in a list and use lapply()
to extract just the value RMSE, you would have all you need for that.
It would be benefical to provide a minimal reprex, e.g. a tiny bit of (toy) data and all the libraries you need to run your models, wrapped inside a R
codechunk. You can do this via reprex::reprex()
or similar functions to provide a usable framework to work with.
In this case sample data and the first three models would be enough to provide some working code, but I am not familiar with all the prediction and/or machine learning packages out there so I don't know about the structure of output from your model etc.
If my hint from above is already enough, feel free to ignore the reprex advise on this one (but keep it in mind for later requests and consider reading this: FAQ: What's a reproducible example (`reprex`) and how do I create one?).
Kind regards