本文整理汇总了Python中pyspark.mllib.feature.StandardScaler.predict方法的典型用法代码示例。如果您正苦于以下问题:Python StandardScaler.predict方法的具体用法?Python StandardScaler.predict怎么用?Python StandardScaler.predict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyspark.mllib.feature.StandardScaler
的用法示例。
在下文中一共展示了StandardScaler.predict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LabeledPoint
# 需要导入模块: from pyspark.mllib.feature import StandardScaler [as 别名]
# 或者: from pyspark.mllib.feature.StandardScaler import predict [as 别名]
label = timeseries.map(lambda row: row[0])
labeled_data = label.zip(features_t)
final_data = labeled_data.map(lambda row: LabeledPoint(row[0], row[1]))
model = LinearRegressionWithSGD.train(final_data, 1000, .0000001, intercept=True)
#model = RidgeRegressionWithSGD.train(final_data, 1000, .00000001, intercept=True)
#model = LassoWithSGD.train(final_data, 1000, .00000001, intercept=True)
modelList.append(model)
#print ""
#print "Model1 weights " + str(model.weights)
#print ""
prediObserRDD = final_data.map(lambda row: (float(model.predict(row.features)), row.label))
metrics = RegressionMetrics(prediObserRDD)
print "1 R2 = " + str(metrics.r2)
print "1 Root mean squared error = " + str(metrics.rootMeanSquaredError)
'''print "Predicting model "
preds = final_data.map(lambda p: p.features)
values = final_data.map(lambda p: p.label)
print "Printing preds "
preds = model.predict(preds)
print preds.take(10)
print ""
print "Printing label "
print values.take(10)
print ""'''