from sklearn.linear_model import ElasticNet X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) param_grid = {'alpha': np.logspace(-4, -1, 10), 'l1_ratio': [0.01, .1, .5, .6, .7, .8, .9, .95, 1]} grid = GridSearchCV(ElasticNet(max_iter=10000, normalize=True), param_grid, cv=10) grid.fit(X_train, y_train) print(grid.best_params_) print(grid.best_score_)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter