参赛名称:一万年太久
第一赛季排名:147/4058
第二赛季排名:119/4058
成绩:0.08138495
简单记录自己了什么,以及学到了什么。首次参赛,大神请炮。
赛题链接:https://tianchi.aliyun.com/competition/information.htm?spm=5176.100067.5678.2.ciEKHX&raceId=231591
预测2000家商铺两周的客流量,商铺类型大致可分为三类美食、超市、其他,这些商铺分布在不同的城市。
-
大赛提供的数据是记录每小时的流量,由于业务需求,将流量转换成一天来计算更方便预测。
-
由于电脑内存有限,这里的处理方法是将2000家商铺分开后,再分别聚合每天的客流量,最后会生成2000张小表。如此对于后续的商家分别建模也做了准备工作。
stores = user_pay.groupby('商家id') for s_id in range(1,2001,1): store = stores.get_group(s_id) store.index = pd.to_datetime(store.index) flow = store['商家id'].groupby(store.index.date).count() flow.to_csv('../' + str(s_id) +'.csv')
-
-
时间特征
- 历史七天的客流量(flowLag1~7)、其统计量(平均数、中位数、标准差)以及其多项式交叉特征。
- 一个月前的当天流量值(flowLag30) # 这个特征由于十一长假并不是特别的理想
- 星期(weekday)、几号(dayOfMonth)、月(month)和年(year)
- 商店的歇业特征捕捉(closeEffect)
- 由于商店的历史客流量数据中有很多缺失值,这里判断空值代表商店歇业在closeEffect特征中用 -1 表示,并且当天的流量值也为零,其余值使用自然数累加填入。
- 节日特征捕捉(holidayEffect)
- 和商店歇业特征一样,若为节假日用 -1 表示,否则使用自然数填入。
-
商铺特征
-
商店id、商店类别、商店级别、商店评分、商店评论数、平均消费等
-
是否处于大城市中
-
有没有相邻店家(hasNeighbour)
-
- 基于规则 0.8642118
- 线性回归 0.0854122
- 随机森林 0.08673182
- xgboost 0.11569889
- 在最后两天才开始调试,评分不理想,估计过拟合严重,特征选择错误
参考kaggle上面的方法,并且实测使用调和平均数相较于使用算术平均数,成绩能略微提升。
调和平均数 = Hn=n/(1/a1+1/a2+...+1/an)
于是集成了规则、线性回归和随机森林的调和平均数评分到达0.08138495。