本文整理匯總了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)