Giter Club home page Giter Club logo

ijcai-2017-customer-flow's Introduction

口碑客流量预测

参赛名称:一万年太久

第一赛季排名: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。

ijcai-2017-customer-flow's People

Contributors

tzuwei93 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.