机器学习中的不平衡分类问题:从乳腺摄影到音素分类
1. 乳腺摄影数据集的预测
在处理不平衡的乳腺摄影癌症分类数据集时,我们可以使用最终模型对新数据进行预测。具体步骤如下:
1. 定义最终模型 :使用成本敏感的SVM模型,并在拟合模型和进行预测之前对数据进行幂变换。通过管道(Pipeline)确保对输入数据正确执行变换。
from sklearn.preprocessing import PowerTransformer
from sklearn.svm import SVC
from sklearn.pipeline import Pipeline
# define model to evaluate
model = SVC(gamma='scale', class_weight='balanced')
# power transform then fit model
pipeline = Pipeline(steps=[('t',PowerTransformer()), ('m',model)])
- 拟合模型 :将模型拟合到整个训练数据集上。
# fit the model
pipeline.fit(X, y)
- 进行预测 :使用
predict()
超级会员免费看
订阅专栏 解锁全文
1650

被折叠的 条评论
为什么被折叠?



