0
votes

Trying to save my linear regression model to disk I receive this error: "TypeError: save() takes 2 positional arguments but 3 were given"

from pyspark import SparkConf, SparkContext

from pyspark.sql import SQLContext

from pyspark.ml.regression import LinearRegression

sc= SparkContext()

lr = LinearRegression(featuresCol = 'features', labelCol='NextOrderInDays', maxIter=10, regParam=0.3, elasticNetParam=0.8)

lr_model = lr.fit(train_df)

lr_model.save(sc, "lr_model.model")

Searching the web outputs something similar to what I wrote. What do I miss as 3rd argument?

Thanks

1

1 Answers

1
votes

You use the ml package not the mllib: from pyspark.ml.regression import LinearRegression.

So the save function has only one argument: the path (cf. documentation).