【问题标题】:Train and test-sets are not compatible error in wekaweka 中的训练集和测试集不兼容错误
【发布时间】:2016-03-20 10:15:53
【问题描述】:

我正在尝试在 Weka 中进行文本分类,但在让测试集正常工作时遇到了很多问题。这是我的训练集(它很短,因为我刚开始学习 weka!):

@relation sentiment
@attribute phrase string
@attribute value {pos, neg}
@data
'That was really unlucky', neg
'The car crashed horribly', neg
'The culpirit got away',neg
'Fortunally everyone made it out', pos
'She was glad noone was hurt',pos
'And the sun was at least shining',pos

然后我在集合上使用 StringToWordVector,然后应用 NumericToBinary。这是训练集的最终结果:

@relation 'sentiment-weka.filters.unsupervised.attribute.StringToWordVector-R1-W1000-prune-rate-1.0-N0-stemmerweka.core.stemmers.NullStemmer-M1-tokenizerweka.core.tokenizers.WordTokenizer -delimiters \" \\r\\n\\t.,;:\\\'\\\"()?!\"-weka.filters.unsupervised.attribute.NumericToBinary'

@attribute value {pos,neg}
@attribute And_binarized {0,1}
@attribute Fortunally_binarized {0,1}
@attribute She_binarized {0,1}
@attribute at_binarized {0,1}
@attribute everyone_binarized {0,1}
@attribute glad_binarized {0,1}
@attribute hurt_binarized {0,1}
@attribute it_binarized {0,1}
@attribute least_binarized {0,1}
@attribute made_binarized {0,1}
@attribute noone_binarized {0,1}
@attribute out_binarized {0,1}
@attribute shining_binarized {0,1}
@attribute sun_binarized {0,1}
@attribute the_binarized {0,1}
@attribute was_binarized {0,1}
@attribute That_binarized {0,1}
@attribute The_binarized {0,1}
@attribute away_binarized {0,1}
@attribute car_binarized {0,1}
@attribute crashed_binarized {0,1}
@attribute culpirit_binarized {0,1}
@attribute got_binarized {0,1}
@attribute horribly_binarized {0,1}
@attribute really_binarized {0,1}
@attribute unlucky numeric

@data
{0 neg,16 1,17 1,25 1,26 1}
{0 neg,18 1,20 1,21 1,24 1}
{0 neg,18 1,19 1,22 1,23 1}
{2 1,5 1,8 1,10 1,12 1}
{3 1,6 1,7 1,11 1,16 1}
{1 1,4 1,9 1,13 1,14 1,15 1,16 1}

我现在开始研究测试集,即:

@relation sentiment
@attribute phrase string
@data
'That was really unlucky'
'The car crashed horribly'
'The culpirit got away'

我希望 weka 可以将此文本归类为“否定”。为了使它们兼容,我使用了与训练集(StringToWordVector 和 NumericToBinary)相同的过滤器。这是测试集的最终结果:

@relation 'sentiment-weka.filters.unsupervised.attribute.StringToWordVector-R1-W1000-prune-rate-1.0-N0-stemmerweka.core.stemmers.NullStemmer-M1-O-tokenizerweka.core.tokenizers.WordTokenizer -delimiters \" \\r\\n\\t.,;:\\\'\\\"()?!\"-weka.filters.unsupervised.attribute.NumericToBinary'

@attribute That_binarized {0,1}
@attribute The_binarized {0,1}
@attribute away_binarized {0,1}
@attribute car_binarized {0,1}
@attribute crashed_binarized {0,1}
@attribute culpirit_binarized {0,1}
@attribute got_binarized {0,1}
@attribute horribly_binarized {0,1}
@attribute really_binarized {0,1}
@attribute unlucky_binarized {0,1}
@attribute was numeric

@data
{0 1,8 1,9 1,10 1}
{1 1,3 1,4 1,7 1}
{1 1,2 1,5 1,6 1}

但是,它给了我训练集和测试集不兼容的错误,我真的不知道为什么。这在直觉上似乎是 weka 应该理解的。

感谢您的帮助!

【问题讨论】:

    标签: weka


    【解决方案1】:

    您的训练和测试测试应该具有相同的标题。现在他们是不同的。

    阅读以下链接for an example for text classification.。这是另一个link,它展示了解决此问题的其他方法。

    【讨论】:

    • 谢谢。你拯救了我的一天!
    猜你喜欢
    • 2012-12-04
    • 2013-07-14
    • 2013-01-01
    • 2018-10-19
    • 2013-03-23
    • 2017-09-11
    • 2015-01-17
    • 2019-08-15
    • 2016-03-01
    相关资源
    最近更新 更多