问题
I installed LibSVM in weka from package manager and it is successfully installed. But when I am running the following command-
java -cp ./weka.jar weka.classifiers.meta.FilteredClassifier -F weka.filters.unsupervised.attribute.RemoveType -W weka.classifiers.functions.LibSVM -t training.arff -no-cv -T testing.arff -v -o
it Shows that
Can't find class called: weka.classifiers.functions.LibSVM
But other classifiers like Naive Bayes
is working. Why it's not finding the class. I am using mac.
回答1:
Weka.jar does not contain LibSVM class. So, to use LibSVM, you have to provide LibSVM.jar in classpath along with weka.jar. You can download LibSVM.jar from
- www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gz (tar.gz)
www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+zip (Zip file)
You can provide LibSVM.jar in classpath as follows:
java -classpath $pathtoweka.jar/weka.jar:$pathtoLibSVM.jar/libsvm.jar weka.classifiers.meta.FilteredClassifier -t $pathtotrainfile -x 10 -c last -i -d $pathtomodel -F 'weka.filters.unsupervised.attribute.StringToWordVector -R 1 -W 3000 -N 0 -stemmer weka.core.stemmers.NullStemmer -T -I -M 1 -tokenizer weka.core.tokenizers.WordTokenizer -C' -W weka.classifiers.functions.LibSVM -- -B
Hope this helps.
来源:https://stackoverflow.com/questions/36390118/libsvm-class-not-found-in-weka