text_plain_output_1.png image_output_1.png
from imblearn.over_sampling import SMOTE

from sklearn.preprocessing import LabelEncoder

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

df = pd.read_csv('/kaggle/input/hotel-reservations-classification-dataset/Hotel Reservations.csv')

df = df.drop('Booking_ID', axis=1)
features = ['no_of_adults', 'no_of_children', 'no_of_weekend_nights', 'no_of_week_nights', 'type_of_meal_plan', 'required_car_parking_space', 'room_type_reserved', 'lead_time', 'arrival_year', 'arrival_month', 'arrival_date', 'market_segment_type', 'repeated_guest', 'no_of_previous_cancellations', 'no_of_previous_bookings_not_canceled', 'avg_price_per_room', 'no_of_special_requests']
target = 'booking_status'

le = LabelEncoder()
for col in df.columns:
    if df[col].dtype == 'object':
        df[col] = le.fit_transform(df[col])

for col in df.columns:
    df[col] = pd.to_numeric(df[col], downcast='unsigned')

plt.gcf().set_size_inches(20, 20)

sm = SMOTE(random_state=42)
X, y = sm.fit_resample(df[features], df[target])
sns.countplot(y)