daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Oct 13th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. df = sqlc.read.format('com.databricks.spark.csv').
  2.     options(header='true', inferSchema='true', delimiter=',').load(my_file)
  3. assembler = VectorAssembler(inputCols=input_cols, outputCol="features")
  4. df = assembler.transform(df)
  5. rm_cols = [c for c in df.columns if c not in ['features', 'label']]
  6. df = df.drop(*rm_cols)
  7.    
  8. lr = LogisticRegression(maxIter=10, regParam=0.3, elasticNetParam=0.8)
  9. lr.fit(sdf)
  10.    
  11. ---------------------------------------------------------------------------
  12. Py4JJavaError                             Traceback (most recent call last)
  13. <ipython-input-63-1e9f885a2ebc> in <module>()
  14.       1 lr = LogisticRegression(maxIter=10, regParam=0.3, elasticNetParam=0.8)
  15. ----> 2 lr.fit(sdf)
  16.  
  17. /opt/spark/python/pyspark/ml/base.py in fit(self, dataset, params)
  18.      62                 return self.copy(params)._fit(dataset)
  19.      63             else:
  20. ---> 64                 return self._fit(dataset)
  21.      65         else:
  22.      66             raise ValueError("Params must be either a param map or a list/tuple of param maps, "
  23.  
  24. /opt/spark/python/pyspark/ml/wrapper.py in _fit(self, dataset)
  25.     263
  26.     264     def _fit(self, dataset):
  27. --> 265         java_model = self._fit_java(dataset)
  28.     266         return self._create_model(java_model)
  29.     267
  30.  
  31. /opt/spark/python/pyspark/ml/wrapper.py in _fit_java(self, dataset)
  32.     260         """
  33.     261         self._transfer_params_to_java()
  34. --> 262         return self._java_obj.fit(dataset._jdf)
  35.     263
  36.     264     def _fit(self, dataset):
  37.  
  38. /opt/spark/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py in __call__(self, *args)
  39.    1131         answer = self.gateway_client.send_command(command)
  40.    1132         return_value = get_return_value(
  41. -> 1133             answer, self.gateway_client, self.target_id, self.name)
  42.    1134
  43.    1135         for temp_arg in temp_args:
  44.  
  45. /opt/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
  46.      61     def deco(*a, **kw):
  47.      62         try:
  48. ---> 63             return f(*a, **kw)
  49.      64         except py4j.protocol.Py4JJavaError as e:
  50.      65             s = e.java_exception.toString()
  51.  
  52. /opt/spark/python/lib/py4j-0.10.4-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
  53.     317                 raise Py4JJavaError(
  54.     318                     "An error occurred while calling {0}{1}{2}.n".
  55. --> 319                     format(target_id, ".", name), value)
  56.     320             else:
  57.     321                 raise Py4JError(
  58.  
  59. Py4JJavaError: An error occurred while calling o1789.fit.
  60.  
  61.   [1]: https://i.stack.imgur.com/owwCX.png
RAW Paste Data
Top