1

I am trying to save the model in PySpark 1.4.2. but getting below error

model.save(sc, modelpath)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'LinearRegressionModel' object has no attribute 'save'

Can you let me know where I am going wrong? Cannot figure out even in the Apache Spark 1.4.1 example

Below is my code,

>>> from pyspark.mllib.linalg import Vectors
>>> df = sqlContext.createDataFrame([
...     (1.0, Vectors.dense(1.0)),
...     (0.0, Vectors.sparse(1, [], []))], ["label", "features"])
>>> lr = LinearRegression(maxIter=5, regParam=0.0)
>>> model = lr.fit(df)
>>> model.transform(test0).head().prediction
-1.0
>>> model.weights
DenseVector([1.0])
>>> model.intercept
0.0
>>> model.save("path")
>>>model.save(sc, modelpath) --tried both got same error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'LinearRegressionModel' object has no attribute 'save'
>>> modl = LinearRegression.load(path)

Last 2 lines are not working.

TMichel
  • 4,336
  • 9
  • 44
  • 67

0 Answers0