AI学习

天池---智慧交通预测挑战赛总结(三)

2017-11-17  本文已影响163人  0过把火0

2017/07 -- 2017/09 天池智慧交通预测赛思路及模型总结(三)


前提回顾

前面两篇的天池智慧交通预测赛思路及模型总结博客中总结了比赛中的数据处理、特征选择以及基本机器学习模型的使用,而第二篇中主要介绍了我们基于数据分析而得到的一种Static的统计模型。

本片博客主要介绍比赛过程中使用到的BestMape模型(规则模型)。

1 BestMape

所谓的BestMape其实就是从问题的评价函数出发,我们期望通过以暴力遍历的方法来遍历预测出某时段的车辆旅行时间travel_time,通过对各个月数据的可视化分析,测试集我们通过对前一小时的数据趋势与前几个月进行比对后,最终选择使用3月4月的原始数据当作是bestMape模型的训练集。也就是说我们统计出这两个月每条link对应预测时间段内travle_time 的极大极小值,然后再以min值为起点,向上循环累加0.1的步长来分别计算每个预测值与该时间段内多个真实值的Mape值,并最终选择Mape值最小的那一个作为该时间段该link的预测值。

因为先前有较为自信的数据可视化依据,因此我们认为这样的统计值能够在整体上带来较好的Mape指标。

最终线上测试结果较好,相比于LGBM,该bestMape模型的预测效果更好。这样的结果确实令我们惊讶而又惊喜。因为这样的模型不单单可以拿来直接作为模型进行预测,而且可以将预测值作为特征重新进行模型的训练。

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

转载请注明原址,谢谢

上一篇 下一篇

猜你喜欢

热点阅读