为什么我在WEKA中获得早期EOF读取此ARFF文件?

时间:2014-12-10 18:37:11

标签: java machine-learning weka arff

这是我用于测试的简化版本,会产生以下错误

@RELATION documents

@ATTRIBUTE rnClass {r,n}
@ATTRIBUTE CONTAINS_EMAIL numeric
@ATTRIBUTE CONTAINS_PHONE numeric

@DATA
n,0.0,0.0
n,0.0,0.0
r,0.0,0.0
r,0.0,0.0
n,0.0,0.0
r,0.0,0.0
r,0.0,0.0


Caused by: java.io.IOException: premature end of file, read Token[EOF], line 1
    at weka.core.converters.ArffLoader$ArffReader.errorMessage(ArffLoader.java:258) ~[weka-dev-3.7.6.jar:na]
    at weka.core.converters.ArffLoader$ArffReader.readHeader(ArffLoader.java:678) ~[weka-dev-3.7.6.jar:na]
    at weka.core.converters.ArffLoader$ArffReader.<init>(ArffLoader.java:139) ~[weka-dev-3.7.6.jar:na]

然而,这个以前的版本似乎没有问题:

@RELATION documents

@ATTRIBUTE rnClass {r,n}
@ATTRIBUTE text String

@DATA
r,'blah blah blah...'
r,'\n\n\n\n\t\n\nblah blah blah\n\n...'
n,'\n\n   \n\n\n \nblah blah blah \n\n\nblah blah \n \n\n\n \'

2 个答案:

答案 0 :(得分:0)

我尝试用你的输入创建一个arff文件,它为我工作。可能是您的arff文件已损坏。你能创建一个新的arff文件并试试吗?

答案 1 :(得分:0)

尝试使用Notepad ++生成一些文件进行数据挖掘实验时,我遇到了这个问题。我怀疑这可能是一个编码问题,以某种方式破坏文件并使WEKA停止工作。您应该尝试更改文件编码配置:如果使用UTF-8编码创建文件,则应更改为ANSI或另一个。它奏效了。