Skip to content

Instantly share code, notes, and snippets.

@Rahuls66
Last active August 1, 2021 21:07
Show Gist options
  • Save Rahuls66/2a667d6c0f3b05e5216711f294fc258b to your computer and use it in GitHub Desktop.
Save Rahuls66/2a667d6c0f3b05e5216711f294fc258b to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
from sklearn import metrics
from sklearn.model_selection import train_test_split
from sklearn.linear_model import Ridge
df = pd.read_csv('data.csv')
x =
y =
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.3, random_state = 66)
ridge = Ridge()
ridge.fit(x_train, y_train)
print("Ridge Train RMSE:", np.round(np.sqrt(metrics.mean_squared_error(y_train, ridge.predict(x_train))),5))
print("Ridge Test RMSE:", np.round(np.sqrt(metrics.mean_squared_error(y_test, ridge.predict(x_test))),5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment