我想在我的 java 代码中使用带有 Weka 包装器的 LibLINEAR。我的部分代码如下:
import weka.classifiers.functions.LibLINEAR;
import weka.core.Instances;
.
.
.
public svmModel trainSVM(Instances trainInstances)
{
LibLINEAR libLsvm= new LibLINEAR();
libLsvm = new LibLINEAR();
String[] a = libLsvm.getOptions();
String svmOptions = "-S 0 -K 0 -D 3 -G 0.0 -R 0.0 -N 0.5 -M 40.0 -C 0.4 -E 0.011 -P 0.1 -H";
libLsvm.setOptions(weka.core.Utils.splitOptions(svmOptions));
libLsvm.buildClassifier(trainInstances);
}
但是我收到以下错误:
Exception in thread "main" java.lang.Exception: liblinear classes not in CLASSPATH!
at weka.classifiers.functions.LibLINEAR.buildClassifier(Unknown Source)
at opinionminingsvm.TrainSVMLibLinear.trainSVM(TrainSVMLibLinear.java:61)
at opinionminingsvm.LinearSVM_testing.main(LinearSVM_testing.java:42)
我在 NetBeans 中工作,并且已将liblinear-1.92.jar
文件添加到项目库中。jar 文件包含weka.classifiers.functions.LibLINEAR
. 但是,我仍然收到错误消息。