稀有事件建模表现不佳

数据挖掘 分类 采样
2022-02-13 00:50:22

我正在研究稀有事件分类问题。我将 95% 的数据作为多数类,将 5% 的数据作为少数类。我使用分类树算法。我正在使用混淆矩阵来衡量模型的优劣。

由于我的少数类只有总数据的 5%,即使我对少数类的预测性能接近 70%,错误的总数也很高。

例如,这是我的混淆矩阵。0 1 0 213812 7008 1 29083 16877

虽然 Minority 类(class 1)正确预测了 16877 次(70%,而误分类率仅为 30%,但与正确预测的 minotriy 类(16877)相比,误分类的绝对值非常高(29083)。这使得该解决方案对业务的可用性较低。

在这种罕见的事件建模中处理这类问题有什么想法吗?

温馨提示:在应用分类树之前,我已经使用 SMOTE 算法平衡了目标变量。

1个回答

如果您愿意在 R 中使用 caret 包并使用随机森林,您可以使用以下博客文章中的方法对不平衡数据集进行下采样:http: //appliedpredictivemodeling.com/blog/2013/12/8/28rmc2lv96h8fw8700zm4nl50busep

基本上,您只需在火车呼叫中添加一条线路。以下是相关部分:

> rfDownsampled <- train(Class ~ ., data = training,
+                        method = "rf",
+                        ntree = 1500,
+                        tuneLength = 5,
+                        metric = "ROC",
+                        trControl = ctrl,
+                        ## Tell randomForest to sample by strata. Here, 
+                        ## that means within each class
+                        strata = training$Class,
+                        ## Now specify that the number of samples selected
+                        ## within each class should be the same
+                        sampsize = rep(nmin, 2))

在你这种情况下,我用这种方法取得了一些成功。

有关更多上下文,这里有一篇关于不平衡数据集实验的深入文章:http: //www.win-vector.com/blog/2015/02/does-balancing-classes-improve-classifier-performance/