Home > OS >  how we load machine learning Model .sav file with spark
how we load machine learning Model .sav file with spark

Time:11-21

I want to load Machine Learning model already saved as .sav file in spark i used

val loaded_model = Pipeline.load("model_final.sav")    

or

val loaded_model = PipelineModel.load("model_final.sav")

i meet exception

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64)
Caused by: java.lang.NoClassDefFoundError: org/apache/spark/ml/Pipeline$
    at migration2$.main(migration2.scala:61)
    at migration2.main(migration2.scala)
    ... 5 more
Caused by: java.lang.ClassNotFoundException: org.apache.spark.ml.Pipeline$
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 7 more

CodePudding user response:

Delete provided from your dependency. So the following:

libraryDependencies  = "org.apache.spark" %% "spark-mllib" % "2.1.0" % "provided"

Should be changed to:

libraryDependencies  = "org.apache.spark" %% "spark-mllib" % "2.1.0"
  • Related