ALSModel.load not working on pyspark 2.1.0

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

ALSModel.load not working on pyspark 2.1.0

This post has NOT been accepted by the mailing list yet.
This code is not working:

from import RegressionEvaluator
from import ALS, ALSModel
from pyspark.sql import Row

als = ALS(maxIter=10, regParam=0.01, userCol="user_id", itemCol="movie_id", ratingCol="rating")
model ="/models/als")

model2 = ALSModel.load("/models/als") # <-- error here

Gives rise to this error:
Py4JJavaError                             Traceback (most recent call last)
<ipython-input-24-c0454f47bb1d> in <module>()
----> 1 m2 = ALSModel.load("/models/als")

/usr/local/spark/python/pyspark/ml/ in load(cls, path)
    251     def load(cls, path):
    252         """Reads an ML instance from the input path, a shortcut of `read().load(path)`."""
--> 253         return

/usr/local/spark/python/pyspark/ml/ in load(self, path)
    192         if not isinstance(path, basestring):
    193             raise TypeError("path should be a basestring, got type %s" % type(path))
--> 194         java_obj = self._jread.load(path)
    195         if not hasattr(self._clazz, "_from_java"):
    196             raise NotImplementedError("This Java ML type cannot be loaded into Python currently: %r"

/usr/local/spark/python/lib/ in __call__(self, *args)
   1131         answer = self.gateway_client.send_command(command)
   1132         return_value = get_return_value(
-> 1133             answer, self.gateway_client, self.target_id,
   1135         for temp_arg in temp_args:

/usr/local/spark/python/pyspark/sql/ in deco(*a, **kw)
     61     def deco(*a, **kw):
     62         try:
---> 63             return f(*a, **kw)
     64         except py4j.protocol.Py4JJavaError as e:
     65             s = e.java_exception.toString()

/usr/local/spark/python/lib/ in get_return_value(answer, gateway_client, target_id, name)
    317                 raise Py4JJavaError(
    318                     "An error occurred while calling {0}{1}{2}.\n".
--> 319                     format(target_id, ".", name), value)
    320             else:
    321                 raise Py4JError(

Py4JJavaError: An error occurred while calling o337.load.
: java.lang.UnsupportedOperationException: empty collection
        at org.apache.spark.rdd.RDD$$anonfun$first$1.apply(RDD.scala:1370)
        at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
        at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
        at org.apache.spark.rdd.RDD.withScope(RDD.scala:362)
        at org.apache.spark.rdd.RDD.first(RDD.scala:1367)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at py4j.reflection.MethodInvoker.invoke(
        at py4j.reflection.ReflectionEngine.invoke(
        at py4j.Gateway.invoke(
        at py4j.commands.AbstractCommand.invokeMethod(
        at py4j.commands.CallCommand.execute(