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