旅馆预订的数据分析练习

该博客通过EDA探讨了旅馆预订数据,包括顾客来源、预订人群、房间价格、预订表现、顾客居住天数和取消预订情况。接着,使用逻辑回归模型预测预订取消,最终模型在训练和测试集上达到了81%的准确率。
摘要由CSDN通过智能技术生成

内容

本次数据分析练习的数据集来自于kaggle。数据集中包含两种类型的旅馆,Resort Hotel和City Hotel。
下面的内容包括数据的探索性分析和建模预测。
探索性分析部分涉及两种旅店的顾客国家构成、人员构成、房间的价格分布、各月份的预订情况、顾客居住时长、预订被取消的情况等。
建模预测旨在预测预订是否会被取消这一问题。

(一)EDA

初步了解下数据集的情况

hotel.info()
hotel.isnull().sum()/len(hotel)

该数据集一共包含32个变量,近12万条记录。
数据维度
数据详细记录了旅店预订的各种信息
(1) 用户特征
children,adults,babies,country,
(2) 旅店特征
hotel,
(3)时间特征
lead_time,arrival_date_year,arrival_date_month,arrival_date_week_number,arrival_date_day_of_month,stays_in_weekend_nights,stayed or booked to stay at the hotel,stays_in_week_nights,booked to stay at the hotel,days_in_waiting_list
(4)其它订单特征
is_canceled,meal,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,customer_type,adr,required_car_parking_spaces,total_of_special_requests,reservation_status,reservation_status_date

  • 缺失值占比情况
    children:0.0034%
    country:0.4087%
    agent:13.6862%
    company:94.3069%

1 旅馆预订的顾客来自于哪些国家

分别分析两类旅馆的国家占比情况,筛选出占比在3%以上的国家,低于3%的国家合并为“other”

hotel['country'].fillna('unknown',inplace=True)
country_info = pd.DataFrame(hotel.groupby(['hotel'])['country'].value_counts())
country_info = country_info.rename(columns={'country':'number'}).reset_index()

CH_country = country_info[country_info['hotel']=='City Hotel'][['country','number']]
CH_country['rate'] = CH_country.number/CH_country.number.sum()
CH_country.loc[CH_country['rate']<0.03,'country'] = 'other'
CH_country=CH_country.groupby(['country']).sum().sort_values('rate',ascending=False).reset_index()
plt.pie(CH_country['rate'],labels=CH_country['country'], autopct='%.2f%%',pctdistance=0.8,startangle=90,radius=1.5,counterclock=False)
plt.show()

RH_country = country_info[country_info['hotel']=='Resort Hotel'][['country','number']]
RH_country['rate'] = RH_country.number/RH_country.number.sum()
RH_country.loc[RH_country['rate']<0.03,'country'] = 'other'
RH_country=RH_country.groupby(['country']).sum().sort_values('rate',ascending=False).reset_index()
plt.pie(RH_country['rate'],labels=RH_country['country'], autopct='%.2f%%',pctdistance=0.85,startangle=90,radius=1.5,counterclock=False)
plt.show()

City Hotel

在这里插入图片描述
City Hotel的预订中占比最高的国家来自于PRT,达到了39%,其次是FRA、DEU、GBR、ESP。

Resort Hotel

在这里插入图片描述
Resort Hotel的预订中占比最高的国家来自于PRT,达到了44%,其次是GBR、ESP、IRL、FRA、DEU。

2 预订信息中各类人群的情况

预订信息中包括三类人群:adults,children,babies

2.1 children

考虑到children中缺失值较少,直接删除

hotel_clean = hotel.dropna(subset=['children'])

children中人数分布情况:人数集中在3个以内,有约93%均为0个;仅有1个10人的记录,作为异常值删除

hotel_clean.children.value_counts()
hotel_clean = hotel_clean[hotel_clean['children']<=3]

2.2 adults

adults中人数分布情况:人数集中在4个以内,有超过9

评论提供了有关酒店的大量信息。这个数据可用于许多nlp项目:推荐系统,情绪分析,同类酒店的图网,基于评论的酒店细分。该数据集包含25个城市的酒店列表和评论。 file/opensearch/documents/92885/hotelReviewsInAustin__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInBali__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInBangkok__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInBarcelona__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInBombay__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInChicago__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInDubai__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInHong Kong__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInIstanbul__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInLondon__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInMiami__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInMilan__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInNew York__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInOsaka__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInParis__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInPhuket__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInPrague__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInRome__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInSan Francisco__en2019100120191005.csv file/opensearch/documents/92885/hotelReviewsInSantorini__en2019100120191005.csv file/opense
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值