本文整理汇总了Python中pyprepbuddy.rdds.transformable_rdd.TransformableRDD.smooth方法的典型用法代码示例。如果您正苦于以下问题:Python TransformableRDD.smooth方法的具体用法?Python TransformableRDD.smooth怎么用?Python TransformableRDD.smooth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyprepbuddy.rdds.transformable_rdd.TransformableRDD
的用法示例。
在下文中一共展示了TransformableRDD.smooth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_smooth_data_by_Simple_Moving_Average
# 需要导入模块: from pyprepbuddy.rdds.transformable_rdd import TransformableRDD [as 别名]
# 或者: from pyprepbuddy.rdds.transformable_rdd.TransformableRDD import smooth [as 别名]
def test_should_smooth_data_by_Simple_Moving_Average(self):
initial_dataset = self.sc.parallelize(
["52,3,53", "23,4,64", "23,5,64", "23,6,64", "23,7,64", "23,8,64", "23,9,64"], 3)
transformable_rdd = TransformableRDD(initial_dataset, "csv")
transformed = transformable_rdd.smooth(1, SimpleMovingAverage(3))
excepted = 4.0
self.assertEquals(excepted, transformed.first())
示例2: test_should_smooth_data_by_Weighted_Moving_Average
# 需要导入模块: from pyprepbuddy.rdds.transformable_rdd import TransformableRDD [as 别名]
# 或者: from pyprepbuddy.rdds.transformable_rdd.TransformableRDD import smooth [as 别名]
def test_should_smooth_data_by_Weighted_Moving_Average(self):
initial_dataset = self.sc.parallelize(["10", "12", "16", "13", "17", "19", "15", "20", "22", "19", "21", "19"],
3)
transformable_rdd = TransformableRDD(initial_dataset, "csv")
weights = Weights(3)
weights.add(0.166)
weights.add(0.333)
weights.add(0.5)
moving_average = WeightedMovingAverage(3, weights)
rdd = transformable_rdd.smooth(0, moving_average)
expected = 13.656
actual = rdd.first()
self.assertEquals(expected, actual)