WEKA:CUI 和我的 java 代码之间的 StringToWordVector 结果不同
我在 GUI 和 JAVA 中使用此设置:
-R
last
-W
1000
-prune-rate
-1.0
-C
-I
-N
0
-S
-stemmer
weka.core.stemmers.NullStemmer
-M
20
-tokenizer
weka.core.tokenizers.WordTokenizer -delimiters " \r\n\t.,;:\'\"()?!"
JAVA:
@relation 'testing2-weka.filters.unsupervised.attribute.StringToWordVector-R2-W1000-prune-rate-1.0-C-I-N0-S-stemmerweka.core.stemmers.NullStemmer-M20-tokenizerweka.core.tokenizers.WordTokenizer -delimiters \" \\r\\n\\t.,;:\\\'\\\"()?!\"'
GUI:
weka.filters.unsupervised.attribute.StringToWordVector-R2-W1000-prune-rate-1.0-C-I-N0-S-stemmerweka.core.stemmers.NullStemmer-M20-tokenizerweka.core.tokenizers.WordTokenizer -delimiters " \r\n\t.,;:\'\"()?!"
不幸的是,我得到了不同的结果:我在 GUI 中获得的属性数量是 (86),而 JAVA 中的属性数量约为 (300)。
对于相同的关系数据集。
这是我使用的代码:
BufferedReader reader = new BufferedReader(new FileReader("newTemp.arff"));
Instances dataRaw = new Instances(reader);
reader.close();
StringToWordVector filter = new StringToWordVector();
filter.setInputFormat(dataRaw);
filter.setAttributeIndices("last");
filter.setDoNotOperateOnPerClassBasis(false);
filter.setOutputWordCounts(true);
filter.setWordsToKeep(1000);
filter.setUseStoplist(true);
filter.setIDFTransform(true);
filter.setMinTermFreq(20);
filter.setDoNotOperateOnPerClassBasis(false);
filter.setPeriodicPruning(-1);
String[] options = filter.getOptions();
for(int i=0;i<options.length;i++) {
if (options[i].length() > 0)
System.out.println(options[i]);
}
Instances dataFiltered = Filter.useFilter(dataRaw, filter);
System.out.println("\n\n=====> Filtered data:<===\n\n" + dataFiltered.toString());
我不知道出了什么问题。请帮助我即将下沉。
I am using this setting in GUI and JAVA:
-R
last
-W
1000
-prune-rate
-1.0
-C
-I
-N
0
-S
-stemmer
weka.core.stemmers.NullStemmer
-M
20
-tokenizer
weka.core.tokenizers.WordTokenizer -delimiters " \r\n\t.,;:\'\"()?!"
JAVA:
@relation 'testing2-weka.filters.unsupervised.attribute.StringToWordVector-R2-W1000-prune-rate-1.0-C-I-N0-S-stemmerweka.core.stemmers.NullStemmer-M20-tokenizerweka.core.tokenizers.WordTokenizer -delimiters \" \\r\\n\\t.,;:\\\'\\\"()?!\"'
GUI:
weka.filters.unsupervised.attribute.StringToWordVector-R2-W1000-prune-rate-1.0-C-I-N0-S-stemmerweka.core.stemmers.NullStemmer-M20-tokenizerweka.core.tokenizers.WordTokenizer -delimiters " \r\n\t.,;:\'\"()?!"
And unfortunately am getting different results: the number of attributes I got in GUI is (86) and number of attributes in JAVA is around (300).
For same relation data-set.
This is the code i used:
BufferedReader reader = new BufferedReader(new FileReader("newTemp.arff"));
Instances dataRaw = new Instances(reader);
reader.close();
StringToWordVector filter = new StringToWordVector();
filter.setInputFormat(dataRaw);
filter.setAttributeIndices("last");
filter.setDoNotOperateOnPerClassBasis(false);
filter.setOutputWordCounts(true);
filter.setWordsToKeep(1000);
filter.setUseStoplist(true);
filter.setIDFTransform(true);
filter.setMinTermFreq(20);
filter.setDoNotOperateOnPerClassBasis(false);
filter.setPeriodicPruning(-1);
String[] options = filter.getOptions();
for(int i=0;i<options.length;i++) {
if (options[i].length() > 0)
System.out.println(options[i]);
}
Instances dataFiltered = Filter.useFilter(dataRaw, filter);
System.out.println("\n\n=====> Filtered data:<===\n\n" + dataFiltered.toString());
I don't know what is wrong. please help am coming sinking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论