text_plain_output_1.png
from sklearn import metrics

from sklearn.linear_model import Lasso

from sklearn.linear_model import LinearRegression

from sklearn.linear_model import Ridge

from sklearn.metrics import r2_score

from sklearn.model_selection import GridSearchCV

from sklearn.model_selection import GridSearchCV

from sklearn.model_selection import GridSearchCV

from sklearn.model_selection import train_test_split

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pandas as pd
data = pd.read_csv('../input/hotel-booking-demand/hotel_bookings.csv')

data = data.drop(['company'], axis=1)
data = data.dropna(axis=0)

data1 = data.copy()

X = data.drop(['previous_cancellations'], axis=1)
y = data['previous_cancellations']

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
regressor = LinearRegression()
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)

ridge = Ridge(alpha=1.0)
ridge.fit(X_train, y_train)
y_pred = ridge.predict(X_test)

clf = Lasso(alpha=0.1)
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)

from sklearn.model_selection import GridSearchCV
parameters = {'alpha': [50, 75, 100, 200, 230, 250], 'random_state': [5, 10, 20, 50], 'max_iter': [0.1, 0.5, 1, 2, 3, 5]}
grid = GridSearchCV(ridge, parameters, cv=5)
grid.fit(X_train, y_train)

from sklearn.model_selection import GridSearchCV
parameters = {'alpha': [200, 230, 250, 265, 270, 275, 290, 300], 'random_state': [2, 5, 10, 20, 50], 'max_iter': [5, 10, 15, 20, 30, 50, 100]}
grid = GridSearchCV(clf, parameters, cv=5)
grid.fit(X_train, y_train)
print('Best_Score_Lasso : ', grid.best_score_)
print('best_para_Lasso:', grid.best_params_)