今天才发现kaggle的Discussion和Kernel内容区别还挺大的。我原来一直在Kernel中找解决方案。其实很多都在Discussion版块给了自己解决方案描述并附加github。
Web Traffic Time Series Forcasting
该题目中提供了过去一年多时间的一些维基词语每天的访问情况,要求预测未来一年这些维基词语的访问情况。
通过对这道题各个solution的分析可以发现一个很神奇的现象:我们在前一篇文章中提到的方法ARIMA之类的并未被这些solution使用。包括facebook提供的用来做时间序列预估的库Prophet也被证明效果不好。
这里有个大家总体方案的讨论帖。Share your general approach?。
还有个兄弟的经验总结.Tips from the winning solutions .
都值得看下。
这里重点分析我们能看到的三个solution。
Baseline Solution 使用中位数
baseline solution
使用中位数预测
import numpy as np # linear algebraimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)train = pd.read_csv("../input/train_1.csv") train = train.fillna(0.)# I'm gong to share a solution that I found interesting with you.# The idea is to compute the median of the series in different window sizes at the end of the series,# and the window sizes are increasing exponentially with the base of golden ratio.# Then a median of these medians is taken as the estimate for the next 60 days.# This code's result has the score of around 44.9 on public leaderboard, but I could get upto 44.7 by playing with it.# r = 1.61803398875# Windows = np.round(r**np.arange(0,9) * 7)Windows = [6, 12, 18, 30, 48, 78, 126, 203, 329] n = train.shape[1] - 1 # 550Visits = np.zeros(train.shape[0])for i, row in train.iterrows(): M = [] start = row[1:].nonzero()[0] if len(start) == 0: continue if n - start[0] < Windows[0]: Visits[i] = row.iloc[start[0]+1:].median() continue for W in Windows: if W > n-start[0]: break M.append(row.iloc[-W:].median()) Visits[i] = np.median(M) Visits[np.where(Visits < 1)] = 0.train['Visits'] = Visits test = pd.read_csv("../input/key_1.csv") test['Page'] = test.Page.apply(lambda x: x[:-11]) test = test.merge(train[['Page','Visits']], on='Page', how='left') test[['Id','Visits']].to_csv('sub.csv', index=False)
原理解释如下:
就是对每一行(每个词从XX年XX月XX日到YY年Y月Y日每天的访问量)求非NAN值的中位数。
中位数求法如下:
对该行最后六天访问量求中位数,最后12天求中位数,最后18天求中位数。。。。按斐波那契数列的天数求出一个中位数数组。就是按数列[6, 12, 18, 30, 48, 78, 126, 203, 329]为求中位数的天数
对上面求出来的中位数数组再求一次中位数
以中位数值为预测结果
Solution 2 使用CNN ??(rank 2nd)
Solution 3 使用RNN seq2seq (rank 1st)
后面两个方案,等我撸完 < hands-on machine learning with scikit-learn and tensorflow > 再来分析
作者:墨家钜子
链接:https://www.jianshu.com/p/d122fc100d4a
共同学习,写下你的评论
评论加载中...
作者其他优质文章