阿帕奇星火移动平均线 [英] Apache Spark Moving Average

查看:201
本文介绍了阿帕奇星火移动平均线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在有时间序列数据点(雅虎股票价格)HDFS一个巨大的文件。

I have a huge file in HDFS having Time Series data points (Yahoo Stock prices).

我要查找的时间序列的均线我怎么去写了Apache星火工作,做到这一点。

I want to find the moving average of the Time Series how do I go about writing the Apache Spark job to do that .

推荐答案

您可以使用来自MLLIB滑动功能,这可能做同样的事情作为丹尼尔的回答。你将不得不使用滑动功能之前,按时间对数据进行排序。

You can use the sliding function from MLLIB which probably does the same thing as Daniel's answer. You will have to sort the data by time before using the sliding function.

import org.apache.spark.mllib.rdd.RDDFunctions._

sc.parallelize(1 to 100, 10)
  .sliding(3)
  .map(curSlice => (curSlice.sum / curSlice.size))
  .collect()

这篇关于阿帕奇星火移动平均线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆