繁体   English   中英

python中如何结合深度学习模型和传统机器学习模型的分类结果

[英]How to combine the classification results of deep learning models and traditional machine learning models in python

我有以下三个分类模型,其中我的数据标签是10

  • lstm model with some timeseries data that has one node as the output (ie model.add(Dense(1, activation='sigmoid')) ) so my output is similar to [0.1, 0.1, 0.6, 0.9, ...]
  • 具有特征集 1 的traditional random forest - 我正在使用 sklearn 的predict_proba :所以我的 output 类似于[[0.9, 0.1], [0.8, 0.2], ...]
  • 具有特征集 2 的traditional random forest - 我正在使用 sklearn 的predict_proba :所以我的 output 类似于[[0.8, 0.2], [0.9, 0.1], ...]

我想结合我的三个模型的预测得到一个反映我的分类的概率列表。 我在 SO 中搜索了这个,但是像装袋和堆叠这样的建议对我来说是不可能的,因为我也在考虑使用 lstm model。

我想知道是否有任何其他方法可以用来在 python 中组合这些预测概率。

如果需要,我很乐意提供更多详细信息。

您可以执行两种解决方案之一,但首先您需要使 output 的表示对于三个模型相同,因此对于第二个和第三个模型pred_2 = [y[0] for y in pred_2]看起来像第一个 model . (y[0] 或 y[1] 取决于您的第一个模型中概率的含义)。

第一个解决方案是通过计算三个列表的平均值来进行majority_voting = [v/3.0 for v in[sum(x) for x in zip(pred_1, pred_2, pred_3)]]投票

第二种解决方案有点困难,因为您可以使用另一个深度学习 model 使其在三个模型中选择最佳结果。 You need to prepare the data_x as list that has three columns a column for each model output and data_y the same labels for your original data, by doing so you are letting the model to learn how to use the three models to predict the output instead of只是多数投票。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM