python - 处理不平衡的类 SMOTE,仍然没有得到很好的结果
问题描述
我有一个目标变量分布的数据集:
类别=3,百分比=15.235%
类别=2,百分比= 2.471%
类别=1,百分比=42.964%
类别=0,百分比=39.330%
看到有一个不平衡的数据集,我决定使用 SMOTE 来平衡数据集。
cls = {0:.43, 1:.30, 2:.02,3:.20}
classifier = RandomForestClassifier
# build model with SMOTE imblearn
smote_pipeline = make_pipeline_imb(SMOTE(random_state=42), \
classifier(random_state=42, class_weight = cls))
smote_model = smote_pipeline.fit(X_train, Y_train)
smote_prediction = smote_model.predict(X_test)
#Showing the diference before and after the transformation used
print("normal data distribution: {}".format(Counter(y)))
oversample = SMOTE()
X_smote, y_smote = oversample.fit_resample(X, y)
print("SMOTE data distribution: {}".format(Counter(y_smote)))
print('accuracy %s' % accuracy_score(smote_prediction, Y_test))
print(classification_report(Y_test, smote_prediction))
问题:即使在执行了 Smote 并设置了类权重之后,结果似乎也不太准确。我犯了什么错误导致结果没有按预期执行?与 0 类和 1 类相比,2 类和 3 类主要是相当低的。
解决方案
推荐阅读
- javascript - 状态超时后的组件路由器
- docker - 在 Window 和 WSL 之间共享 docker 凭据
- java - 为什么我的横幅没有出现在 Linearlayout 中?
- javascript - 购物车数组未正确呈现,react.js
- javascript - 如何在 Angular 中获取文件哈希名称?
- sql-server - SQL Server SELECT * INTO 临时表是否保留确切的列数据类型?
- grails - 输入列表的 Grails 命令对象验证
- graph-databases - Amazon Neptune - 不等于谓词在使用 bothE() 时不适用于边缘标签
- xslt - 特定节点子集的 xslt 文本过滤器
- sharepoint - 在 dotnet core 中获取 SharepointOnline 的 AuthToken