Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created March 16, 2020 11:16
Show Gist options
  • Save aniruddha27/196ca409e9f722f6a826553afceb5288 to your computer and use it in GitHub Desktop.
Save aniruddha27/196ca409e9f722f6a826553afceb5288 to your computer and use it in GitHub Desktop.
from sklearn.linear_model import Ridge
from sklearn.metrics import mean_squared_error
# different alpha values
alphas = [0.01, 0.1, 0.3, 1, 3, 5, 10, 15, 20]
for a in alphas:
lr = Ridge(alpha=a)
lr.fit(X_train,y_train)
rmse = np.sqrt(mean_squared_error(y_test,lr.predict(X_test)))
print('For Alpha = ',a,', RMSE = ',rmse)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment