<jupyter_start><jupyter_text>Linear Regression<jupyter_code>from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LinearRegression

reg=LinearRegression()
mse=cross_val_score(reg, X, y, scoring='neg_mean_squared_error', cv=5)
mean_mse = np.mean(mse)
print(mean_mse)<jupyter_output><empty_output><jupyter_text>Ridge Regression<jupyter_code>from sklearn.linear_model import Ridge
from sklearn.model_selection import GridSearchCV

ridge = Ridge()
parameters={'alpha':[1e-15,1e-10,1e-8,1e-3,1e-2,1,5,10,20,30,35,40,45,50,55,100]}
ridge_reg=GridSearchCV(ridge, parameters, scoring='neg_mean_squared_error', cv=5)
ridge_reg.fit(X, y)
print(ridge_reg.best_params_)
print(ridge_reg.best_score_)<jupyter_output>{'alpha': 100}
-29.90570194754033<jupyter_text>Lasso Regression<jupyter_code>from sklearn.linear_model import Lasso
from sklearn.model_selection import GridSearchCV

lasso = Lasso()
parameters={'alpha':[1e-15,1e-10,1e-8,1e-3,1e-2,1,5,10,20,30,35,40,45,50,55,100]}
lasso_reg = GridSearchCV(lasso, parameters, scoring='neg_mean_squared_error', cv=5)
lasso_reg.fit(X,y)
print(lasso_reg.best_params_)
print(lasso_reg.best_score_)
from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.3, random_state=0)
prediction_ridge = ridge_reg.predict(X_test)
prediction_lasso = lasso_reg.predict(X_test)
sns.distplot(y_test-prediction_lasso)
sns.distplot(y_test-prediction_ridge)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12550066755674233, 'fraction_numerical': 0.06074766355140187, 'mean_word_length': 11.491666666666667, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '238562', 'license': 'ISC', 'n_tokens_mistral': 652, 'n_tokens_neox': 608, 'n_words': 76, 'path': 'Boston Ridge & Lasso/Ridge & Lasso.ipynb', 'repo_name': 'N-liraj-khanna/Machine-Learning-Projects', 'size': '1498'}