Weka Linear regression ClassNotFoundException

2019-07-17 14:35发布

问题:

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/



标签: weka