我正在使用 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'
我发现的所有示例似乎都告诉我,我应该有能力使用已保存模型中的这些新数据进行预测,但我似乎错过了一步。