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 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)
print('Mean Absolute Error_lasso:', metrics.mean_absolute_error(y_test, y_pred).round(3))
print('Mean Squared Error_lasso:', metrics.mean_squared_error(y_test, y_pred).round(3))
print('Root Mean Squared Error_lasso:', np.sqrt(metrics.mean_squared_error(y_test, y_pred)).round(3))
print('r2_score_lasso:', r2_score(y_test, y_pred).round(3))