Code
# 1️⃣ Load Data
import pandas as pd
df = pd.read_csv('../data/raw/hotel_bookings.csv')
# Preprocess date columns
df['reservation_status_date'] = pd.to_datetime(df['reservation_status_date'])# 3️⃣ Plot Demand Over Time
import matplotlib.pyplot as plt
bookings_by_date.set_index('reservation_status_date')['bookings'].plot(figsize=(12,6))
plt.title('Total Bookings Over Time')
plt.xlabel('Date')
plt.ylabel('Number of Bookings')
plt.show()
# 4️⃣ Prophet Model
from prophet import Prophet
# Prepare data for Prophet
df_prophet = bookings_by_date.rename(columns={'reservation_status_date': 'ds', 'bookings': 'y'})
# Initialize model
m = Prophet()
m.fit(df_prophet)
# Create future dataframe
future = m.make_future_dataframe(periods=60) # Forecast 60 days ahead
# Forecast
forecast = m.predict(future)
# Plot forecast
fig = m.plot(forecast)20:13:18 - cmdstanpy - INFO - Chain [1] start processing
20:13:19 - cmdstanpy - INFO - Chain [1] done processing

# 5️⃣ XGBoost Model (Optional / Advanced)
# Feature engineering for ML model
bookings_by_date['dayofweek'] = bookings_by_date['reservation_status_date'].dt.dayofweek
bookings_by_date['month'] = bookings_by_date['reservation_status_date'].dt.month
bookings_by_date['year'] = bookings_by_date['reservation_status_date'].dt.year
# Define features and target
features = ['dayofweek', 'month', 'year']
X = bookings_by_date[features]
y = bookings_by_date['bookings']
# Split data
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)
# Train XGBoost model
from xgboost import XGBRegressor
model = XGBRegressor()
model.fit(X_train, y_train)
# Predict
y_pred = model.predict(X_test)
# Plot predictions
plt.figure(figsize=(12,6))
plt.plot(y_test.values, label='Actual')
plt.plot(y_pred, label='Predicted')
plt.title('XGBoost Demand Forecast - Test Set')
plt.legend()
plt.show()