Damien Goor
Damien Goor

Reputation: 91

Error saving a linear regression model with MLLib

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

Upvotes: 0

Views: 469

Answers (1)

pcc
pcc

Reputation: 61

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).

Upvotes: 1

Related Questions