Grid Search CV


Difficulty: 4 | Problem written by ankita
There are various hyperparameters used to train a model, and selecting the best hyperparameter plays an important role in getting the best output performance. So, to overcome such problems we use Grid Search.

Scikit-learn's GridSearchCV (where CV stands for Cross Validation) trains the model for different hyperparameters entered by the user and outputs the best-suited hyperparameter for the corresponding training data and the model.

You are required to use the ElasticNet Regression model.


X: an array of training examples        

Y: an array of output corresponding to each training example

parameters: hyperparameters for the model


Best suited hyperparameters for the model.


Sample Input:
<class 'list'>
X: [[62812.09301], [66646.89292], [53798.55112], [79370.03798], [59729.1513], [68499.85162], [39814.522], [51752.23445], [58139.2591], [53457.10132], [73348.70745], [55421.65733], [37336.3383], [68304.47298], [72776.00382], [64662.30061], [63259.87837], [52682.06401], [54503.14423], [55368.23716]]
<class 'list'>
y: [[35321.45877], [45115.52566], [42925.70921], [67422.36313], [55915.46248], [56611.99784], [28925.70549], [47434.98265], [48013.6141], [38189.50601], [59045.51309], [42288.81046], [28700.0334], [49258.87571], [49510.03356], [53017.26723], [41814.72067], [43901.71244], [44633.99241], [54827.52403]]
<class 'list'>
parameters: [{'alpha': [0.5, 0.1, 0.01, 0.001], 'l1_ratio': [0.25, 0.5, 0.75, 1]}]

Expected Output:
<class 'dict'>
{'alpha': 0.5, 'l1_ratio': 1}

This is a premium problem, to view more details of this problem please sign up for MLPro Premium. MLPro premium offers access to actual machine learning and data science interview questions and coding challenges commonly asked at tech companies all over the world

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Get access to Premium only exclusive educational content available to only Premium users.

Have an issue, the MLPro support team is available 24X7 to Premium users.

This is a premium feature.
To access this and other such features, click on upgrade below.

Log in to post a comment


Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)