Question
Write a function glmnet_vanilla that fits a linear regression model from the glmnet library, and takes the following arguments as input: X_train: A numpy array
Write a function glmnet_vanilla that fits a linear regression model from the glmnet library, and takes the following arguments as input: X_train: A numpy array of the shape (N,d) where N is the number of training data points, and d is the data dimension. Do not assume anything about N or d other than being a positive integer. Y_train: A numpy array of the shape (N,) where N is the number of training data points. X_test: A numpy array of the shape (N_test,d) where N_test is the number of testing data points, and d is the data dimension. Your model should train on the training features and labels, and then predict on the test data. Your model should return the following two items: fitted_Y: The predicted values on the test data as a numpy array with a shape of (N_test,) where N_test is the number of testing data points. glmnet_model: The glmnet library's returned model stored as a python dictionary. Important Notes: Do not play with the default options unless you're instructed to. You may find this glmnet documentation helpful: https://github.com/bbalasub1/glmnet_python/blob/master/test/glmnet_examples.ipynb You may find it useful to read about the gaussian family in the first section, the functions glmnet and glmnetPredict, and their arguments. Do not perform any cross-validation for this task. Do not play with the regularization settings in the training call. For prediction on the test data, make sure that a regularization coefficient of 0 was used. You may need to choose the proper family variable when you're training the model. You may need to choose the proper ptype variable when you're predicting on the test data.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started