0

I am using Azure and Spark version is '2.1.1.2.6.2.3-1

I have saved my model using the following command:

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)

When I tried to use the model and reloaded it

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

The error I get is this:

'LinearRegression' object has no attribute 'transform'
Traceback (most recent call last):
AttributeError: 'LinearRegression' object has no attribute 'transform'

All the examples that I have found seemed to tell me that I should have the ability to predict using this new data from the saved model but I seemed to be missing a step..

E B
  • 1,073
  • 3
  • 23
  • 36

1 Answers1

0

There was a mistake. I should be saving the fit of the model and not just the LinearRegression Function

lr_model_save = lr_model.write().overwrite().save(lr_outpath)

E B
  • 1,073
  • 3
  • 23
  • 36