Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve application classpath diagnostics #17

Closed
yashwanthmadaka24 opened this issue Mar 19, 2019 · 5 comments
Closed

Improve application classpath diagnostics #17

yashwanthmadaka24 opened this issue Mar 19, 2019 · 5 comments

Comments

@yashwanthmadaka24
Copy link

df = spark.read.format('com.databricks.spark.csv').options(header='true', inferschema='true').load(input_dir+'stroke_100K_1.csv')
classifier = DecisionTreeClassifier(labelCol="label", featuresCol="features", maxDepth=25, minInstancesPerNode=30, impurity="gini")
pipeline = Pipeline(stages = [classifier])
pipelineModel = pipeline.fit(trainingData)


from pyspark2pmml import PMMLBuilder
pmmlBuilder = PMMLBuilder(sc, trainingData, pipelineModel) \
	.putOption(classifier, "compact", True)
pmmlBuilder.buildFile("DecisionTree.pmml")``

the following code is throwing an error which says:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-66-a6260012e861> in <module>()
      1 from pyspark2pmml import PMMLBuilder
      2 
----> 3 pmmlBuilder = PMMLBuilder(spark, trainingData, pipelineModel)   .putOption(classifier, "compact", True)
      4 
      5 pmmlBuilder.buildFile("DecisionTreeIris.pmml")

~/.local/lib/python3.6/site-packages/pyspark2pmml/__init__.py in __init__(self, sc, df, pipelineModel)
     10                 javaSchema = javaDf.schema.__call__()
     11                 javaPipelineModel = pipelineModel._to_java()
---> 12                 javaPmmlBuilder = sc._jvm.org.jpmml.sparkml.PMMLBuilder(javaSchema, javaPipelineModel)
     13                 if(not isinstance(javaPmmlBuilder, JavaObject)):
     14                         raise RuntimeError("JPMML-SparkML not found on classpath")

TypeError: 'JavaPackage' object is not callable
@vruusmann
Copy link
Member

You probably don't have the JPMML-SparkML library on your Apache Spark application's classpath - see the README file.

What is your PySpark/Apache Spark version? It's strange that the execution doesn't reach the next line, which would throw a nice "JPMML-SparkML not found on classpath" exception.

@vruusmann vruusmann changed the title TypeError: 'JavaPackage' object is not callable Improve application classpath diagnostics Mar 19, 2019
@yashwanthmadaka24
Copy link
Author

@vruusmann My pyspark version is 2.4.0

@yashwanthmadaka24
Copy link
Author

I am having difficulties adding jar file into my sparks application classpath. What steps should I follow in order for it to reflect them to my jupyter notebook.

@yashwanthmadaka24
Copy link
Author

This blog was helpful to solve my problem.
https://blog.sicara.com/get-started-pyspark-jupyter-guide-tutorial-ae2fe84f594f

@wiwengweng
Copy link

if you're using spark and pyspark, I recommend that you add the jar to spark jars directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants