2017/07 -- 2017/09 天池智慧交通預測賽思路及模型總結(jié)(三)
前提回顧
前面兩篇的天池智慧交通預測賽思路及模型總結(jié)博客中總結(jié)了比賽中的數(shù)據(jù)處理毙死、特征選擇以及基本機器學習模型的使用税娜,而第二篇中主要介紹了我們基于數(shù)據(jù)分析而得到的一種Static的統(tǒng)計模型囤捻。
本片博客主要介紹比賽過程中使用到的BestMape模型(規(guī)則模型)驼唱。
1 BestMape
所謂的BestMape其實就是從問題的評價函數(shù)出發(fā)筒饰,我們期望通過以暴力遍歷的方法來遍歷預測出某時段的車輛旅行時間travel_time座泳,通過對各個月數(shù)據(jù)的可視化分析蛇损,測試集我們通過對前一小時的數(shù)據(jù)趨勢與前幾個月進行比對后,最終選擇使用3月4月的原始數(shù)據(jù)當作是bestMape模型的訓練集速兔。也就是說我們統(tǒng)計出這兩個月每條link對應預測時間段內(nèi)travle_time 的極大極小值墅拭,然后再以min值為起點,向上循環(huán)累加0.1的步長來分別計算每個預測值與該時間段內(nèi)多個真實值的Mape值涣狗,并最終選擇Mape值最小的那一個作為該時間段該link的預測值谍婉。
因為先前有較為自信的數(shù)據(jù)可視化依據(jù),因此我們認為這樣的統(tǒng)計值能夠在整體上帶來較好的Mape指標镀钓。
最終線上測試結(jié)果較好穗熬,相比于LGBM,該bestMape模型的預測效果更好丁溅。這樣的結(jié)果確實令我們驚訝而又驚喜唤蔗。因為這樣的模型不單單可以拿來直接作為模型進行預測,而且可以將預測值作為特征重新進行模型的訓練窟赏。
2 BestMape偽代碼
Input: travel_time List Link_id List
Output: The best travel_time with best Mape of each Link_id in every time phases
Global variables:
double bestMape = 100.0;
double bestTravelTime minValue maxValue = 0.0;
double step = 0.1;
ArrayList<Double> travel_time= new ArrayList<Double>();
ArrayList<String> linkIdList = new ArrayList<String>();
----START
maxValue = Collections.max(tmpList);
minValue = Collections.min(tmpList);
for var i to limit by step do
ArrayList<Double> tmpMapeList = new ArrayList<Double>();
double realData = 0.0;
double preData = 0.0;
double sum = 0.0;
double mapeTmp = 0.0;
for(int j=0;j<tmpList.size();j++){
tmpMapeList.add(i);
}
Double[] tmpMapeArray = new Double[tmpMapeList.size()]; //預測值
Double[] tmpListArray = new Double[tmpList.size()]; //真實值
for (int r=0;r<tmpList.size();r++){
realData = tmpList.toArray(tmpListArray)[r];
preData = tmpMapeList.toArray(tmpMapeArray)[r];
sum=sum+(Math.abs(Math.abs(realData)- Math.abs(preData))/Math.abs(realData));
}
mapeTmp = sum/tmpList.size();
if (mapeTmp < bestMape){
bestMape = mapeTmp;
bestTravelTime = i;
}
-----END
我的博客 : https://NingSM.github.io
轉(zhuǎn)載請注明原址妓柜,謝謝。