我正在尝试一些使用 weka API for Java 的简单代码。在尝试查找 numberofAttributes 时,它会为任何 .data 文件触发错误。虽然它适用于 .arff 文件。已从UCI存储库下载文件
---Registering Weka Editors---
Trying to add database driver (JDBC): RmiJdbc.RJDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): org.gjt.mm.mysql.Driver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): com.mckoi.JDBCDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): org.hsqldb.jdbcDriver - Error, not in CLASSPATH?
java.io.IOException: premature end of line. Expected attribute type., read Token[EOL], line 5
at weka.core.converters.ConverterUtils.errms(ConverterUtils.java:912)
at weka.core.converters.C45Loader.readHeader(C45Loader.java:417)
at weka.core.converters.C45Loader.getStructure(C45Loader.java:211)
at weka.core.converters.C45Loader.getDataSet(C45Loader.java:234)
at weka.core.converters.ConverterUtils$DataSource.getDataSet(ConverterUtils.java:268)
at MetaFeatureStatistical.main(MetaFeatureStatistical.java:42)
Exception in thread "main" java.lang.NullPointerException
at MetaFeatureStatistical.main(MetaFeatureStatistical.java:43)
第 42 和 43 行如下:
instances=source.getDataSet();
instances.setClassIndex(instances.numAttributes()-1);