3
私はpython-weka-wrapper3を使用しています。python-weka-wrapper3 M5P return Java ERROr
Training M5P classifier on iris
===============================
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: no/uib/cipr/matrix/Matrix
at weka.classifiers.trees.m5.M5Base.getCapabilities(M5Base.java:433)
at weka.classifiers.trees.m5.M5Base.buildClassifier(M5Base.java:445)
Caused by: java.lang.ClassNotFoundException: no.uib.cipr.matrix.Matrix
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
Traceback (most recent call last):
File "classifiers.py", line 272, in <module>
main()
File "classifiers.py", line 83, in main
classifier.build_classifier(iris_data)
File "/home/v-yuan15/software/anaconda3/lib/python3.6/site-packages/weka/classifiers.py", line 82, in build_classifier
javabridge.call(self.jobject, "buildClassifier", "(Lweka/core/Instances;)V", data.jobject)
File "/home/v-yuan15/software/anaconda3/lib/python3.6/site-packages/javabridge/jutil.py", line 885, in call
result = fn(*nice_args)
File "/home/v-yuan15/software/anaconda3/lib/python3.6/site-packages/javabridge/jutil.py", line 852, in fn
raise JavaException(x)
javabridge.jutil.JavaException: no/uib/cipr/matrix/Matrix
私はちょうどコードhttps://github.com/fracpete/python-weka-wrapper3-examples/blob/master/src/wekaexamples/classifiers/classifiers.pyを使用してデータソースにbodyfat.arffしM5Pとデータセットに分類器を変更:分類器M5Pを実行しようとすると、私は次の例外を取得します。 私のコードは
# load a dataset
bodyfat_file = helper.get_data_dir() + os.sep + "bodyfat.arff"
helper.print_info("Loading dataset: " + bodyfat_file)
loader = Loader("weka.core.converters.ArffLoader")
bodyfat_data = loader.load_file(bodyfat_file)
bodyfat_data.class_is_last()
# classifier help
helper.print_title("Creating help string")
classifier = Classifier(classname="weka.classifiers.trees.M5P",options=["-M","4.0"])
print(classifier.to_help())
helper.print_title("Training M5P classifier on bodyfat")
# classifier = Classifier(classname="weka.classifiers.trees.J48")
# Instead of using 'options=["-C", "0.3"]' in the constructor, we can also set the "confidenceFactor"
# property of the J48 classifier itself. However, being of type float rather than double, we need
# to convert it to the correct type first using the double_to_float function:
# classifier.set_property("confidenceFactor", types.double_to_float(0.3))
# classifier.set_property("confidenceFactor", 0.3)
classifier.build_classifier(bodyfat_data)
print(classifier)
print(classifier.graph)
plot_graph.plot_dot_graph(classifier.graph)
で、私のJava環境は次のとおりです。
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-8u102-b14.1-1~bpo8+1-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)
echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-amd64
ご協力いただきありがとうございます。しかし、私は今、新たな問題を抱えていました。同じclassifier.pyコードの場合、pycharmでうまく実行できますが、jupyterで実行するとエラーが報告されます。私は同じPythonインタプリタを使用します。 RuntimeError(Java VMの起動に失敗しました) RuntimeError:Java VMの起動に失敗しました –
Jupiter内から試したことはありませんが、jvmプロセス内で一度だけ起動することができます。おそらくそれがあなたの問題です。 – fracpete