我试图用火花运行线性回归,但它给了我错误的预测:
该计划:
def linear_regression(data):
"""
Run the linear regression algorithm on the data to perform the prediction
"""
# Build the model
model = LinearRegressionWithSGD.train(data, iterations=100, step=0.1, intercept=True)
real_and_predicted = data.map(lambda p: (p.label, model.predict(p.features)))
real_and_predicted=real_and_predicted.collect()
return model, real_and_predicted
结果真的错了!我的代码中有问题吗?