问题
String filePath = new File("").getAbsolutePath();
DataSource source = new DataSource(filePath + "\\src\\data\\data.arff");
Instances dataset = source.getDataSet();
// set class
dataset.setClassIndex(0);
// build model
**LinearRegression lr = new LinearRegression();**
lr.buildClassifier(dataset);
System.out.println(lr);
Right after LinearRegression instantiation I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: no/uib/cipr/matrix/Matrix at weka_prediction.Main_LinearRegression.main(Main_LinearRegression.java:22) Caused by: java.lang.ClassNotFoundException: no.uib.cipr.matrix.Matrix at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more
I am using weka 3.8.
any ideas? thanks in advance
回答1:
There is a problem with loading weka.core. You just need to go to the weka repository and download and add the following jars:
- mtj.jar
- arpack_combined_all.jar
- core.jar
See more details here:
回答2:
Solved! instead of 3.8, I am now using 3.6 from here: http://grepcode.com/project/repo1.maven.org/maven2/nz.ac.waikato.cms.weka/weka-stable/
来源:https://stackoverflow.com/questions/42178995/weka-linear-regression-classnotfoundexception