我想在线性回归后可视化散射图实施我想使用Python熊猫数据帧(pydf)和ggplot创建一个线性回归图,以显示我使用的散射图和两个回归模型。
我有3个prédictor(原因、wt0、dbp0)和gfr0m作为预测值:# Import numpy, pandas, and ggplot
import numpy as np
from pandas import *
from ggplot import *
# Create Python DataFrame
cause = prepared_data.map(lambda p: (p.features[0])).collect()
dbp0 = prepared_data.map(lambda p: (p.features[0])).collect()
gfr0m = prepared_data.map(lambda p: (p.label)).collect()
predA = predictionsA.select("prediction").map(lambda r: r[0]).collect()
predB = predictionsB.select("prediction").map(lambda r: r[0]).collect()
pydf =
DataFrame({'cause':cause,'wt0':wt0,'dbp0':dbp0,'gfr0m':gfr0m,'predA':predA,
'predB':predB})
# Create scatter plot and two regression models (scaling exponential) using
ggplot
p = ggplot(pydf, aes('cause','wt0','dbp0','gfr0m')) +
geom_point(color='blue') +
geom_line(pydf, aes('cause','wt0','dbp0','predA'), color='red') +
geom_line(pydf, aes('cause','wt0','dbp0','predB'), color='green') +
scale_x_log10() + scale_y_log10()
display(p)
此代码不会执行其show me:“DataFrame”对象在添加.rdd时没有属性“map”Prefore.map它显示我为错误:org.apache.spark.SparkException:由于阶段失败而中止作业:阶段34.0中的任务0失败1次,最近的失败:阶段34.0中丢失的任务0.0(TID 34,localhost,执行人驱动程序:org.apache.spark.api.python.pythonexException:回溯(最近的调用最后一次):
如果有人能在这种情况下帮助我:)