簡體   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