我正在使用Azure,Spark版本为'2.1.1.2.6.2.3-1
我已使用以下命令保存了模型:
def fit_LR(training,testing,adl_root_path,location,modelName):
training.cache()
lr = LinearRegression(featuresCol = 'features',labelCol = 'ZZ_TIME',solver="auto",maxIter=100)
lr_model = lr.fit(training)
testing.cache()
lr_outpath = adl_root_path + "Model/Sprint6Results/RUN/" + str(location) + str(modelName)
lr_model_save = lr.write().overwrite().save(lr_outpath)
当我尝试使用模型并重新加载时
saved_model_path = adl_root_path + "Model/Sprint6Results/RUN/" + str(location) + str(modelName)
reloaded_model = LinearRegression.load(saved_model_path)
testing.cache()
reloaded_model.transform
我得到的错误是:
'LinearRegression' object has no attribute 'transform'
Traceback (most recent call last):
AttributeError: 'LinearRegression' object has no attribute 'transform'
我发现的所有示例似乎都告诉我,我应该能够使用已保存的模型中的新数据进行预测,但是我似乎缺少了一步。
答案 0 :(得分:0)
有一个错误。我应该保存模型的拟合度,而不仅仅是线性回归函数
lr_model_save = lr_model.write().overwrite().save(lr_outpath
)