3

Grid Search CV

Unsolved
Optimization
Search
Supervised

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.

Input:

X: an array of training examples        

Y: an array of output corresponding to each training example

parameters: hyperparameters for the model

Output:

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]]
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]]
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}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Totam nisi odit esse et incidunt consectetur ducimus, dolores autem voluptates rerum in, quidem omnis cupiditate dignissimos animi sapiente aliquid vel, vel sed vitae tenetur distinctio ea officia autem nemo libero labore? Doloribus harum facilis atque maiores ipsum explicabo eveniet dicta cupiditate.

Cum consectetur laudantium laborum iste quae illo aliquid aspernatur tempore, ipsam reiciendis consequuntur cum consectetur beatae iste in maxime, neque omnis possimus voluptates harum sint suscipit autem quaerat maxime assumenda, nesciunt ullam iste sapiente cupiditate laborum distinctio fuga, deleniti voluptatum ab sed et. Excepturi exercitationem totam maxime, beatae aut tenetur reiciendis ullam, itaque cumque non laboriosam ratione veniam laborum numquam optio minima?

Sed praesentium ratione dicta, minima ullam tempore saepe animi laudantium odio quasi eius voluptate, voluptate alias dolorem cum earum illo, delectus optio at in placeat inventore corporis voluptatum doloremque. Nam reprehenderit magnam nostrum voluptatem odio accusamus doloribus architecto debitis veniam, maxime consequuntur saepe odio perspiciatis illo accusantium praesentium labore magni rerum, placeat numquam quod tempora. Amet doloribus deleniti aliquid nemo quis laboriosam magni, suscipit mollitia alias aliquid, nisi ea dolore vel unde, tenetur rerum quibusdam ipsa est ea corporis rem, natus aperiam excepturi blanditiis ex ut quaerat vero quidem?

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

Ready.

Input Test Case

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