Predicting a Hotel Booking Demand | by Dimas Adnan | Towards Data Science

Here in this article, I want to write about how to build a prediction model using Python with Jupyter Notebook. The data that I am using for this experiment is the Hotel Booking Demand dataset from Kaggle.
In this article, I will only show you the modeling stage, with just the Logistic Regression model, but you can access the full document, including the Data Cleaning, Preprocessing, and Exploratory Data Analysis on my Github.
Without further ado, let’s do it.
Importing Libraries
Loading the Dataset
And here is how the dataset looks.
It has 32 columns, and the full version of it is:
['hotel', 'is_canceled', 'lead_time', 'arrival_date_year',       'arrival_date_month', 'arrival_date_week_number',       'arrival_date_day_of_month', 'stays_in_weekend_nights',       'stays_in_week_nights', 'adults', 'children', 'babies', 'meal',       'country', 'market_segment', 'distribution_channel',       'is_repeated_guest', 'previous_cancellations',       'previous_bookings_not_canceled', 'reserved_room_type',       'assigned_room_type', 'booking_changes', 'deposit_type', 'agent',       'company', 'days_in_waiting_list', 'customer_type', 'adr',       'required_car_parking_spaces', 'total_of_special_requests',       'reservation_status', 'reservation_status_date']
Based on the info that I have run on the notebook, the NaN values from the dataset can be found on three columns, which are ’country’, ’agent,’ and ’company.’
I replace the NaN value in ‘country’ with PRT (Portugal) based on the ‘lead_time’ feature based on the ‘lead_time’ column, where PRT is the most common country in which lead_time = 118.
I was trying to replace the NaN values on the ‘agent’ feature based on lead_time, arrival_date_month, and arrival_date_week_number, but most of them have ‘240’ as the most common agent. After I read the description and explanation of the dataset that can be found on the internet, the author(s) describe the ‘agent’ feature as “ID of the travel agency that made the bookings.” So, those who have ‘agent’ in the dataset are the only ones that made the book through a travel agency, and those who don’t have ‘agent’ or the value is Nan, are those who did not make the book through a travel agency. So, based on that, I think it is best to fill the NaN values with 0 other than fill them with the agent, which would make the dataset different from the original.
And last but not least, I choose to drop the entire ‘company’ feature because the NaN in that feature is about 96% of the data. If I decide to modify the data, it could make a massive difference to the data and could change the entire data, especially in the company feature.
Splitting the Dataset
I am trying to split the dataset based on the top 5 that have the most significant correlation to the target (is_canceled), which are required_car_parking_spaces’, ’lead_time’, ’booking_changes’, ’adr’, ’adults,’ and ‘is_canceled.’
Fitting the Model
model_LogReg_Asli is the original model that used Logistic Regression before using Hyperparameter Tuning, and here is the model prediction.
Model Performance
As you can see above, the Logistic Regression model has about 69.3 percent of accuracy.
Model Parameter
Logistic Regression with Randomized Search CV
model_LR_RS is the model that used Logistic Regression with Hyperparameter Tuning (Randomized).
As you can see in the above picture, the Logistic Regression model with Randomized Search CV has the exact same result as without it, which is 69.3 percent.
Logistic Regression with Grid Search CV
model_LR2_GS is the model that used Logistic Regression with Hyperparameter Tuning (Grid Search).
The image above shows that the Logistic Regression model with Grid Search CV has the exact same accuracy, which is 69.3 percent.
Evaluation Model
TN is True Negative, FN is False Negative, FP is False Positive, and TP is True Positive, while 0 is Not Canceled, and 1 is Canceled. Here below is the classification report for the model.
In this article, once again, I am only using Logistic Regression for the testing, but you can use other kinds of models like Random Forest, Decision Tree, and so on. On my Github, I have tried the Random Forest Classifier too, but the result is pretty similar.
That is all for this article. Thank you and have a nice day.