酒店预订订单的分析与建模【决策树、xgboost】

该项目使用决策树和xgboost对酒店预订数据进行分析,包括数据预处理、探索性分析、模型参数调优和预测。通过特征如成人儿童数量、预定天数、客户需求等,研究预订取消与各因素的关系。最终,xgboost模型在五折交叉验证下表现优于决策树。
摘要由CSDN通过智能技术生成

酒店预订订单的分析与建模【决策树、xgboost】

本项目包含

1.数据处理
2.数据探索性分析
3.网格搜索对决策树、xgboost进行模型参数调优
4.基于五折交叉验证的决策树、xgboost模型预测

专栏和往期项目

👉往期文章可以关注我的专栏
下巴同学的数据加油小站

会不定期分享数据挖掘、机器学习、风控模型、深度学习、NLP等方向的学习项目,关注不一定能学到你想学的东西,但是可以学到我想学和正在学的东西😀

往期项目-数据分析建模方向

1.基于线性回归对男性体脂率的预测

2.大五人格测试数据集的探索【可视化+k-means聚类分析】

3.使用线性回归、LGBM对二手车价格进行预测
本文代码、数据点击下方链接可获取:
4.关于酒店预订数据集的探索【EDA+五折交叉验证决策树、xgboost预测】

数据与背景描述

背景描述

在线酒店预订渠道已经极大地改变了预订的可能性和客户的行为。
酒店预订取消的典型原因包括计划的改变、日程安排的冲突等,对酒店客人来说,因为可以选择免费或最好是低价从而更容易取消预订,但对酒店来说,这是一个不太理想的、可能会减少收入的因素,需要解决的问题。

数据说明

column 列名
Booking_ID 每个预订的唯一标识符
no_of_adults 成人的数量
no_of_children 儿童的数量
no_of_weekend_nights 客人入住或预订入住酒店的周末晚数(周六或周日)
no_of_week_nights 客人在酒店住宿或预订住宿的周晚数(周一至周五)
type_of_meal_plan 客户预订的膳食计划的类型
required_car_parking_space 顾客是否需要一个停车位?(0-不,1-是)
room_type_reserved 顾客预订的房间类型。这些值是由INN酒店集团加密(编码)的
lead_time 预订日期和抵达日期之间的天数
arrival_year 抵达日期的年份
arrival_month 抵达日期的月份
arrival_date 该月的日期
market_segment_type 市场部分的指定
repeated_guest 该客户是否为重复客人?(0 - 否, 1- 是)
no_of_previous_cancellations 在当前预订之前,客户取消的先前预订的数量
no_of_previous_bookings_not_canceled 在当前预订前未被客户取消的先前预订的数量
avg_price_per_room 每天预订的平均价格;房间的价格是动态的。(单位:欧元)
no_of_special_requests 客户提出的特殊要求的总数(例如,高楼层,从房间看风景等)
booking_status 表示预订是否被取消的标志

导入并检查数据

导入数据

import pandas as pd
df = pd.read_csv('/home/mw/input/data9304/Hotel Reservations.csv') 
df.head()

检查数据

数据无缺失,无重复

df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 36275 entries, 0 to 36274
Data columns (total 19 columns):
Booking_ID                              36275 non-null object
no_of_adults                            36275 non-null int64
no_of_children                          36275 non-null int64
no_of_weekend_nights                    36275 non-null int64
no_of_week_nights                       36275 non-null int64
type_of_meal_plan                       36275 non-null object
required_car_parking_space              36275 non-null int64
room_type_reserved                      36275 non-null object
lead_time                               36275 non-null int64
arrival_year                            36275 non-null int64
arrival_month                           36275 non-null int64
arrival_date                            36275 non-null int64
market_segment_type                     36275 non-null object
repeated_guest                          36275 non-null int64
no_of_previous_cancellations            36275 non-null int64
no_of_previous_bookings_not_canceled    36275 non-null int64
avg_price_per_room                      36275 non-null float64
no_of_special_requests                  36275 non-null int64
booking_status                          36275 non-null object
dtypes: float64(1), int64(13), object(5)
memory usage: 5.3+ MB
df.duplicated().sum()

0

EDA

数据含义与分析目的

数据含义

首先看看数据都有哪些
数据一共19列
预定ID,是唯一标识符,仅用于区分数据
顾客数量有两列:成人数量和儿童数量两列
顾客预定天数:分为工作日和周末两列
顾客需求类数据:用餐类型,停车位,房间类型,顾客特殊要求数量四列
日期、时间类型数据:预定与抵达日间隔天数,抵达日期年份、月份,抵达日期四列
预定方法(在线、离线)
是否为历史用户
本次前客户是否取消数目:取消数目、未取消数目两列
预定房价的平均价格
是否被取消(目标变量)

明确目的

然后明确数据探索性分析的目的:我们想找出是否取消预定与上述其他特征是否存在一定的关系。
所以我们可以进行对比分析,这里只进行简单的分析,变量间关系暂不分析

成人、儿童数目的分析

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
plt.figure(figsize = (16, 12))
plt.suptitle("成人、儿童顾客的数目",fontweight="bold", fontsize=30)

plt.subplot(2,2,1)
plt.gca().set_title('成人数目对比分布')
sns.countplot(x = 'booking_status', hue = 'no_of_adults',  edgecolor="black", alpha=0.7, data = df)

plt.subplot(2,2,2)
plt.gca().set_title('成人数目总分布')
sns.countplot(x = 'no_of_adults', edgecolor="black", alpha=0.7,data = df)

plt.subplot(2,2,3)
plt.gca().set_title('儿童数目对比分布')
sns.countplot(x = 'booking_status', hue = 'no_of_children',  edgecolor="black", alpha=0.7, data = df)

plt.subplot(2,2,4)
plt.gca().set_title('儿童总数目分布')
sns.countplot(x = 'no_of_children',   edgecolor="black", alpha=0.7,data = df)

在这里插入图片描述

顾客预定天数的分布

plt.figure(figsize = (16, 12))
plt.suptitle("顾客预定天数的分布",fontweight="bold", fontsize=30)
plt.subplot(2,2,1)
plt.gca().set_title('工作日预定天数对比')
sns.countplot(x = 'booking_status', hue = 'no_of_week_nights',  edgecolor="
1. 功能需求分析 用户管理:添加用户,修改用户密码。 客户管理:添加客户,查询,修改,删除客户信息。 客房管理:添加客房,查询,修改,删除客房信息。 客房类型管理:添加客房类型,修改客房类型。 订房预订客房,取消预订房间。 客房登记信息管理:查看客房登记信息。 2. 概念设计 用户实体ER图 客户信息实体ER图 客房信息实体ER图 客房类型ER图 登记记录ER图 总ER图 3. 逻辑结构设计 1. 客人信息表:tbclient "字段名 "数据类型 "空/非空 "约束条件 "其他说明 " "clientId "int "not null "IDENTITY(1"客户ID " " " " ",1) " " " " " "PRIMARY " " " " " "KEY " " "name "varchar(20)"not null " "客户姓名 " "sex "varchar(2) "not null " "性别 " "identityCar"varchar(30)"not null " "证件号 " "d " " " " " "phone "varchar(20)"not null " "联系电话 " 2. 登录信息表:tbemployee "字段名 "数据类型 "空/非空 "约束条件 "其他说明 " "employeeId "int "not null "IDENTITY(1"用户编号 " " " " ",1) " " " " " "PRIMARY " " " " " "KEY " " "userName "varchar(20)"not null " "用户名 " "password "varchar(20)"not null " "密码 " "per "int "not null " "权限 " 3. 房间类型表:tbtype "字段名 "数据类型 "空/非空 "约束条件 "其他说明 " "typeId "int "not null "IDENTITY(1"类型编号 " " " " ",1) " " " " " "PRIMARY " " " " " "KEY " " "typeName "varchar(20)"not null " "类型名 " "price "int "not null " "价格 " 4. 房间信息表:tbroom "字段名 "数据类型 "空/非空 "约束条件 "其他说明 " "roomId "int "not null "IDENTITY(1"房间ID " " " " ",1) " " " " " "PRIMARY " " " " " "KEY " " "roomNum "int "not null " "房间号 " "typeId "int "not null "foreign "房间类型I" " " " "key "D " " " " "REFERENCES" " " " " "tbtype(typ" " " " " "eId) " " "status "varhar(10) "not null " "房间状态 " 5. 客户住房登记信息表:tbcheckin "字段名 "数据类型 "空/非空 "约束条件 "其他说明" "checkId "int "not null"IDENTITY(1,1) "登记ID " " " " "PRIMARY KEY " " "roomNum "int "not null"foreign key "房间号 " " " " "REFERENCES " " " " " "tbroom(roomNum" " " " " ") " " "clientId "int "not null"foreign key "客户ID " " " " "REFERENCES " " " " " "tbclient(clent" " " " " "Id) " " "startDate "date "not null" "预订入住" " " " " "日期 " "lastDate "date "not null" "退房日期" "spe "varchar(50" " "描述 " " ") " " " " ----------------------- 酒店订房系统数据库设计全文共4页,当前为第1页。 酒店订房系统数据库设计全文共4页,当前为第2页。 酒店订房系统数据库设计全文共4页,当前为第3页。 酒店订房系统数据库设计全文共4页,当前为第4页。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱挠静香的下巴

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值