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

lin_regressor=LinearRegression()
mse=cross_val_score(lin_regressor,X,y,scoring='neg_mean_squared_error',cv=5)
mean_mse=np.mean(mse)
print(mean_mse)
print(mse)<jupyter_output>[-12.46030057 -26.04862111 -33.07413798 -80.76237112 -33.31360656]<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,200,201]}
ridge_regression=GridSearchCV(ridge,parameters,scoring='neg_mean_squared_error',cv=5)
ridge_regression.fit(X,y)
print(ridge_regression.best_params_)
print(ridge_regression.best_score_)<jupyter_output>{'alpha': 200}
-29.82912428855541<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,200,201]}
lasso_regressor=GridSearchCV(lasso,parameters,scoring='neg_mean_squared_error',cv=5)
lasso_regressor.fit(X,y)
print(lasso_regressor.best_params_)
print(lasso_regressor.best_score_)
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=0)
prediction_lasso=lasso_regressor.predict(X_test)
prediction_ridge=ridge_regression.predict(X_test)
import seaborn as sns
sns.distplot(y_test-prediction_lasso)
sns.distplot(y_test-prediction_ridge)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12363636363636364, 'fraction_numerical': 0.09272727272727273, 'mean_word_length': 14.575471698113208, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '257956', 'license': 'MIT', 'n_tokens_mistral': 763, 'n_tokens_neox': 676, 'n_words': 61, 'path': 'Ridge and Lasso Regression.ipynb', 'repo_name': 'Manthan109/MachineLearning', 'size': '1650'}