Answers for "what is the optimal value of alpha for ridge and lasso regression"

1

ridge regression implementation python

from sklearn.linear_model import Ridge
X_train, X_test, y_train, y_test = train_test_split(X_crime, y_crime,
                                                   random_state = 0)

linridge = Ridge(alpha=20.0).fit(X_train, y_train)
Posted by: Guest on April-27-2020
-1

lasso regression implementation python

from sklearn.linear_model import Lasso
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()

X_train, X_test, y_train, y_test = train_test_split(X_data, y_data,
                                                   random_state = 0)

X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

linlasso = Lasso(alpha=2.0, max_iter = 10000).fit(X_train_scaled, y_train)
Posted by: Guest on April-27-2020

Code answers related to "what is the optimal value of alpha for ridge and lasso regression"

Python Answers by Framework

Browse Popular Code Answers by Language