带火花的线性回归:错误的预测

时间:2015-10-20 13:32:21

标签: apache-spark linear-regression pyspark prediction apache-spark-mllib

我试图用火花运行线性回归,但它给了我错误的预测:

数据来源: enter image description here

该计划:

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

结果: enter image description here

结果真的错了!我的代码中有问题吗?

0 个答案:

没有答案