预测模型预测提前一天 – 滑动窗口
发布时间:2020-12-14 05:34:12 所属栏目:Windows 来源:网络整理
导读:我遇到了一个问题.我正在使用SparkR进行时间序列预测,但这种情况也可以转移到正常的R环境.我不想使用ARIMA模型,而是使用回归模型,例如随机森林回归等来预测未来一天的负荷.我还读到了关于不同参数组合评估不同回归量的性能的滑动窗口方法.所以为了更好地理解
我遇到了一个问题.我正在使用SparkR进行时间序列预测,但这种情况也可以转移到正常的R环境.我不想使用ARIMA模型,而是使用回归模型,例如随机森林回归等来预测未来一天的负荷.我还读到了关于不同参数组合评估不同回归量的性能的滑动窗口方法.所以为了更好地理解这是我的数据集结构的一个例子:
Timestamp UsageCPU UsageMemory Indicator Delay 2014-01-03 21:50:00 3123 1231 1 123 2014-01-03 22:00:00 5123 2355 1 322 2014-01-03 22:10:00 3121 1233 2 321 2014-01-03 22:20:00 2111 1234 2 211 2014-01-03 22:30:00 1000 2222 2 0 2014-01-03 22:40:00 4754 1599 1 0 要使用任何类型的回归量,下一步是提取要素并将其转换为可读格式,因为这些回归无法读取时间戳: Year Month Day Hour Minute UsageCPU UsageMemory Indicator Delay 2014 1 3 21 50 3123 1231 1 123 2014 1 3 22 00 5123 2355 1 322 2014 1 3 22 10 3121 1233 2 321 2114 1 3 22 20 2111 1234 2 211 下一步是为模型创建培训和测试集. trainTest <-randomSplit(SparkDF,c(0.7,0.3),seed=42) train <- trainTest[[1]] test <- trainTest[[2]] 然后可以创建模型预测(randomForest的设置首先是不相关的): model <- spark.randomForest(train,UsageCPU ~ .,type = "regression",maxDepth = 5,maxBins = 16) predictions <- predict(model,test) 所以我知道所有这些步骤,并通过用实际数据绘制预测数据,看起来非常好.但这种回归模型并不是动态的,这意味着我无法提前一天预测.因为UsageCPU,UsageMemory等功能不存在,我想从历史值到第二天进行预测.如开头所述,滑动窗口方法可以在这里工作,但我不确定如何应用它(在整个数据集上,仅在训练或测试集上). 此实施是从shabbychef’s和mbq: slideMean<-function(x,windowsize=3,slide=2){ idx1<-seq(1,length(x),by=slide); idx1+windowsize->idx2; idx2[idx2>(length(x)+1)]<-length(x)+1; c(0,cumsum(x))->cx; return((cx[idx2]-cx[idx1])/windowsize); } 最后一个问题涉及窗口大小.我想以小时(00,01,02,03 ……)预测第二天,但时间戳的间隔为10分钟,因此在我的计算中,窗口的大小应为144(10 * 60 * 24) / 10). 如果有人可以帮助我会很好.谢谢! 解决方法
我对使用神经网络的时间序列预测也有同样的问题.我实现了很多模型,最好的模型是结合神经网络的滑动窗口.
我也向该领域的其他研究人员证实了这一点.由此我们得出结论,如果你想在一个步骤中提前一天预测(24个视野),那么训练将对系统提出要求.我们进行了以下工作: 1. We had a sliding window of 24 hours. e.g lets use [1,2,3] here 2. Then use ML model to predict the [4]. Meaning use value 4 as target. # As illustration we had x = [1,3] # then set target as y=[4]. # We had a function that returns the x=[1,3] and y =[4] and # shift the window in the next training step. 3.To the: x =[1,3] we can add further features that are important to the model. x=[1,3,feature_x] 4. Then we minimise error and shift the window to have: x = [2,4,feature_x] and y = [5]. 5. You could also predict two values ahead. e.g [4,5] . 6. Use a list to collect output and plot 7. Make prediction after the training. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows工作流程
- Windows环境下搭建Hadoop(2.6.0)+Hive(2.2.0)环境并连接Ke
- 如何在Windows上用Java读/写串口?
- Windows锁定时获取桌面的屏幕截图(Win L)
- 如何删除文件以及Windows上的所有硬链接?
- windows-server-2003 – 是否可以使用taskmgr在该月的最后一
- windows – 为什么这会阻止我安装MSI:系统管理员已设置策略
- 在Windows上固定处理器CPU隔离
- windows-server-2008-r2 – 在Windows Server 2008 R2下查看
- windows-phone-7 – 如何将SystemTray Progressbar绑定到选
推荐文章
站长推荐
热点阅读