我是weka的新手,我的分类项目使用它有问题。
我有一个包含1000个实例的训练数据集,其中一个用于测试。问题在于,当我尝试测试某些算法(如randomforest)的性能时,交叉验证和测试集给出的数字确实不同。
以下是交叉验证的示例
=== Run information ===
Scheme:weka.classifiers.trees.RandomForest -I 100 -K 0 -S 1
Relation: testData-weka.filters.unsupervised.attribute.StringToWordVector-R1-W10000000-prune-rate-1.0-T-I-N0-L-stemmerweka.core.stemmers.IteratedLovinsStemmer-M1-O-tokenizerweka.core.tokenizers.WordTokenizer -delimiters " \r\n\t.,;:\"\'()?!--+-í+*&#$\\/=<>[]_`@"-weka.filters.supervised.attribute.AttributeSelection-Eweka.attributeSelection.InfoGainAttributeEval-Sweka.attributeSelection.Ranker -T 0.0 -N -1
Instances: 1000
Attributes: 276
[list of attributes omitted]
Test mode:10-fold cross-validation
=== Classifier model (full training set) ===
Random forest of 100 trees, each constructed while considering 9 random features.
Out of bag error: 0.269
Time taken to build model: 4.9 seconds
=== Stratified cross-validation ===
=== Summary ===
Correctly Classified Instances 740 74 %
Incorrectly Classified Instances 260 26 %
Kappa statistic 0.5674
Mean absolute error 0.2554
Root mean squared error 0.3552
Relative absolute error 60.623 %
Root relative squared error 77.4053 %
Total Number of Instances 1000
=== Detailed Accuracy By Class ===
TP Rate FP Rate Precision Recall F-Measure ROC Area Class
0.479 0.083 0.723 0.479 0.576 0.795 I
0.941 0.352 0.707 0.941 0.808 0.894 E
0.673 0.023 0.889 0.673 0.766 0.964 R
Weighted Avg. 0.74 0.198 0.751 0.74 0.727 0.878
=== Confusion Matrix ===
a b c <-- classified as
149 148 14 | a = I
24 447 4 | b = E
33 37 144 | c = R
72.5%,这是......
但是现在如果我尝试使用200个实例的测试集......
=== Run information ===
Scheme:weka.classifiers.trees.RandomForest -I 100 -K 0 -S 1
Relation: testData-weka.filters.unsupervised.attribute.StringToWordVector-R1-W10000000-prune-rate-1.0-T-I-N0-L-stemmerweka.core.stemmers.IteratedLovinsStemmer-M1-O-tokenizerweka.core.tokenizers.WordTokenizer -delimiters " \r\n\t.,;:\"\'()?!--+-í+*&#$\\/=<>[]_`@"-weka.filters.supervised.attribute.AttributeSelection-Eweka.attributeSelection.InfoGainAttributeEval-Sweka.attributeSelection.Ranker -T 0.0 -N -1
Instances: 1000
Attributes: 276
[list of attributes omitted]
Test mode:user supplied test set: size unknown (reading incrementally)
=== Classifier model (full training set) ===
Random forest of 100 trees, each constructed while considering 9 random features.
Out of bag error: 0.269
Time taken to build model: 4.72 seconds
=== Evaluation on test set ===
=== Summary ===
Correctly Classified Instances 86 43 %
Incorrectly Classified Instances 114 57 %
Kappa statistic 0.2061
Mean absolute error 0.3829
Root mean squared error 0.4868
Relative absolute error 84.8628 %
Root relative squared error 99.2642 %
Total Number of Instances 200
=== Detailed Accuracy By Class ===
TP Rate FP Rate Precision Recall F-Measure ROC Area Class
0.17 0.071 0.652 0.17 0.27 0.596 I
0.941 0.711 0.312 0.941 0.468 0.796 E
0.377 0 1 0.377 0.548 0.958 R
Weighted Avg. 0.43 0.213 0.671 0.43 0.405 0.758
=== Confusion Matrix ===
a b c <-- classified as
15 73 0 | a = I
3 48 0 | b = E
5 33 23 | c = R
43%......显然,有些事情确实是错误的,我使用批量过滤和测试集
我做错了什么?我使用相同的标准手动分类测试和训练集,所以我发现差异很奇怪。
我认为我有CV背后的概念,但也许我错了。
由于
答案 0 :(得分:1)
从评论中可以看出,这是统计数据:
CV错误: 26%
测试错误: 57%
培训错误: 1.2%
低训练错误总是很可疑。如果出现低误差,首先要做的是检查CV错误或测试错误。如果训练和测试/ CV错误之间存在很大差异,则可能会过度拟合。这是一个非常好的健全性测试。当然,您还有其他方法,如学习曲线,以确认您的模型是否适合。 过度拟合意味着您的模型不能概括 - 它只知道训练数据,或者只适用于 训练数据,在< em> general 如果将此模型应用于未知数据,它将无法适应自己。
因此,回到您的问题 - 简历和测试可被视为测试模型的泛化容量的两个独立案例。如果你有一个过度拟合的模型,它将无法很好地概括。因此,在CV的情况下,它给出一个结果,而对于测试,它给你一个不同的结果。
希望有帮助吗?