weka的一些问题

本文介绍了在使用Weka时遇到的内存不足错误及其解决方案,即通过调整Java堆大小。还详细讲解了Weka的StringToWordVector类在中文文本分类中的应用,展示了如何将文本转换为数值型数据并生成ARFF格式,以及在处理过程中需要注意的数据预处理步骤。此外,提到了数据集的处理和分词方法,并提供了相关代码示例。
摘要由CSDN通过智能技术生成

第一个问题 Error Message

Not enough memory. Please load a smaller dataset or use larger heap size.

原因:

This error message appears when a user attempts to load or process a dataset that WEKA can not handle with the used heap size.

解决方案:

The Java heap size can be specified with the -Xmx option.

Let the classpath that contains a JAR file (weka.jar) be:

C:/Matlab/weka-3-5-7/

E.g., to use 256MB as heap size, the command line looks like this:

C:/Matlab/weka-3-5-7>java -Xmx256m -jar weka.jar

第二个问题 weka的StringToWordVector类解析

weka的StringToWordVector类可以将给定的文档格式的内容转换为vms模型的内容,而后者是文本分类必须的模块。按照weka要求,生成arff格式的文本:

 

Java代码   收藏代码
  1. @relation D__java_weka_data  
  2. @attribute text string  
  3. @attribute class {test1,test2,test3}  
  4. @data  
  5. 'here we go go go go to do ',test1  
  6. 'Mostly, I expect we are interested in indexing XPath queries',test1  
  7. 'so what do you think you can do anything?',test2  
  8. 'Sparse ARFF files are very similar to ARFF files',test3  
 

按照StringToWordVector类的命令格式,设定options:

 

Java代码   收藏代码
  1. String[] options = { "-C""-T""-i""data//train.arff""-o","data//res_train.arff""-c""last"};  

 

生成结果如下:

 

Java代码   收藏代码
  1. @relation 'D_java_weka_data-weka.filters.unsupervised.attribute.StringToWordVector-R1-W1000-prune-rate-1.0-C-T-N0-stemmerweka.core.stemmers.NullStemmer-M1-tokenizerweka.core.tokenizers.WordTokenizer -delimiters \" \\r\\n\\t.,;:\\\'\\\"()?!\"'  
  2.   
  3. @attribute class {test1,test2,test3}  
  4. @attribute I numeric  
  5. @attribute Mostly numeric  
  6. @attribute XPath numeric  
  7. @attribute are numeric  
  8. @attribute do numeric  
  9. @attribute expect numeric  
  10. @attribute go numeric  
  11. @attribute here numeric  
  12. @attribute in numeric  
  13. @attribute indexing numeric  
  14. @attribute interested numeric  
  15. @attribute queries numeric  
  16. @attribute to numeric  
  17. @attribute we numeric  
  18. @attribute anything numeric  
  19. @attribute can numeric  
  20. @attribute so numeric  
  21. @attribute think numeric  
  22. @attribute what numeric  
  23. @attribute you numeric  
  24. @attribute ARFF numeric  
  25. @attribute Sparse numeric  
  26. @attribute files numeric  
  27. @attribute similar numeric  
  28. @attribute very numeric  
  29.   
  30. @data  
  31.   
  32.   
  33. { 5 0.693147,7 1.609438,8 0.693147,13 0.693147,14 0.693147}  
  34.   
  35. { 1 0.693147,2 0.693147,3 0.693147,4 0.693147,6 0.693147,9 0.693147,10 0.693147,11 0.693147,12 0.693147,14 0.693147}  
  36.   
  37. { 0 test2,5 1.098612,15 0.693147,16 0.693147,17 0.693147,18 0.693147,19 0.693147,20 1.098612}  
  38.   
  39. { 0 test3,4 0.693147,13 0.693147,21 1.098612,22 0.693147,23 1.098612,24 0.693147,25 0.693147}  
第三个问题 

属性评估方法: 
CfsSubsetEval:根据属性子集中每一个特征的预测能力以及它们之间的关联性进行评估。 ChiSquaredAttributeEval:根据与分类有关的每一个属性的卡方值进行评估。 ClassifierSubsetEval:根据训练集或测试集之外的数据评估属性子集。 
ConsistencySubsetEval:根据利用属性子集进行分类时得到的分类值的一致性进行评价。 CostSensitiveAttributeEval:根据使其基础子集评估开销敏感性,变化选择子集评估方法。 CostSentitiveSubsetEval:方法同上。 
FilteresAttributeEval:运行在任意过滤器之后的数据上的任意属性评估。 FilteredSubsetEval:方法同上。 
GainRatioAttributeEval:根据与分类有关的每一个属性的增益比进行评估。 InfoGainAttributeEval:根据与分类有关的每一个属性的信息增益进行评估。 
LatenSemanticAnalysis:根据数据的潜在的语义分析和转换进行评估,与随机搜索结合。 OneRAttributeEval:根据OneR分类器评估属性。 
PrincipalComponents:根据数据的主要成分分析和转换进行评估。 
ReliefFAttributeEval:通过反复测试一个实例和其同类或不同类中最近的实例上的属性值进行评估。 
SignificanceAttributeEval:计算双向功能的概率意义评估属性值。 
SymmetricalUncertAtrributeEval:根据与分类有关的每一个属性的对称不稳定性进行评估。 SymmetricalUncertAtrributeSetEval:根据与其他属性集有关的每一个属性的对称不稳定性进行评估。 
WrapperSubsetEval:使用一种学习模式对属性集进行评估。  
注:Filter类型的评估方法关注每一个属性的预测能力(最优特征子集由预测能力最强的那些单个属性组成),其一般借鉴统计、信息论的思想,根据数据集内在特性来进行评估; Wrapper类型的评估方法是用后续的学习算法嵌入到特性选择方程中,通过测试特征子集在此算法上的预测性能来决定其优劣。  
搜索算法: 
BestFirst:可回溯的贪婪搜索扩张,最好优先原则。 ExhaustiveSearch:穷举搜索,从空集出发。 
FCBFSearch:基于相关性分析的特征选择方法。相关性匹配搜索。 GeneticSearch:Goldberg(1989)提出的简单遗传算法。 GreedyStepwise:向前或向后的单步搜索。 LinearForwardSelection:线性向前搜索。 
RaceSearch:比较特征子集的交叉验证错误情况。 RandomSearch:随机搜索。 Ranker:对属性值排序。 
RankSearch:选择一个评估器对属性进行排序。 ScatterSearchV1:离散搜索。 
SubsetSizeForwardSelection:按照特征子集大小向前线性搜索,这是线性搜索的扩展。 TabuSearch:禁忌搜索。

第四个问题 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值