<jupyter_start><jupyter_text>Trying Different ML Models<jupyter_code>##Ridge Regression
from sklearn.linear_model import Ridge
from sklearn.model_selection import GridSearchCV
ridge=Ridge()  #Linear, Ridge all do standardization internally
parameters={'alpha':[1e-15,1e-10,1e-8,1e-3,1e-2,1,5,10,20,30,35,40]}
ridge_regressor=GridSearchCV(ridge,parameters,scoring='neg_mean_squared_error',cv=5)
ridge_regressor.fit(X_train,y_train)
print(ridge_regressor.best_params_)
print(ridge_regressor.best_score_)
predictions = ridge_regressor.predict(X_test)
predictions
y_test.shape
sns.set_style('whitegrid')
sns.distplot(y_test-predictions)
from sklearn import metrics
print('MAE:', metrics.mean_absolute_error(y_test,predictions))
print('MSE:', metrics.mean_squared_error(y_test,predictions))
print('RMSE:', np.sqrt(metrics.mean_squared_error(y_test,predictions)))
#Applying LASSO REGRESSION
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]}
lasso_regressor = GridSearchCV(lasso,parameters,scoring='neg_mean_squared_error',cv=5)

lasso_regressor.fit(X_train,y_train)
print(lasso_regressor.best_params_)
print(lasso_regressor.best_score_)
predictions = lasso_regressor.predict(X_test)
sns.set_style('whitegrid')
sns.distplot(y_test-predictions)
from sklearn import metrics
print('MAE:', metrics.mean_absolute_error(y_test,predictions))
print('MSE:', metrics.mean_squared_error(y_test,predictions))
print('RMSE:', np.sqrt(metrics.mean_squared_error(y_test,predictions)))
#Creating a pickle file for the classifier
filename = 'first-innings-score-lr-model.pkl'
pickle.dump(regressor,open(filename,'wb'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12814645308924486, 'fraction_numerical': 0.028604118993135013, 'mean_word_length': 11.860294117647058, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '387318', 'license': 'Apache-2.0', 'n_tokens_mistral': 685, 'n_tokens_neox': 643, 'n_words': 85, 'path': 'IPL Score predictions ( With Venue ).ipynb', 'repo_name': 'Divyang0601/IPL-WEBAPP', 'size': '1748'}