简体   繁体   English

在Spark之外加载Mllib模型

[英]Loading Mllib models outside Spark

I'm training a model in spark with mllib and saving it: 我正在用mllib训练一个火花模型并保存它:

val model = SVMWithSGD.train(training, numIterations)

model.save(sc, "~/model")

but I'm having trouble loading it from a java app without spark to make real time predictions. 但我无法从没有火花的Java应用程序加载它来进行实时预测。

SparkConf sconf = new SparkConf().setAppName("Application").setMaster("local");
SparkContext sc = new SparkContext(sconf);
SVMModel model = SVMModel.load(sc, "/model");

I'm getting: 我越来越:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/SparkConf
    at ModelUser$.main(ModelUser.scala:11)
    at ModelUser.main(ModelUser.scala)
    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:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.SparkConf

Is there a way to load the model in normal java app? 有没有办法在普通的Java应用程序中加载模型?

看看PMML模型在这里导出

PPML model export in spark is not being maintained anymore, and only the old RDD api support it. 火花中的PPML模型导出不再被维护,只有旧的RDD api支持它。 I've been using jpmml-sparkml to solve the problem. 我一直在使用jpmml-sparkml来解决这个问题。 It also has the java runtime for standalone model execution. 它还具有用于独立模型执行的java运行时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM