Reputation: 4608
I have three classification models as follows where the labels of my data is 1
or 0
.
model.add(Dense(1, activation='sigmoid'))
) so my output is similar to [0.1, 0.1, 0.6, 0.9, ...]
traditional random forest
with features set 1 - I am using sklearn's predict_proba
: so my output is similar to [[0.9, 0.1], [0.8, 0.2], ...]
traditional random forest
with features set 2 - I am using sklearn's predict_proba
: so my output is similar to [[0.8, 0.2], [0.9, 0.1], ...]
I want to combine the predictions of my three models to get one probability list that reflects my classification. I searched this in SO, however the suggestions like bagging and stacking is not possible for me as I am also using a lstm model in to consideration.
I am wondering if there is any other way that I can use to combine these prediction probabilities in python.
I am happy to provide more details if needed.
Upvotes: 0
Views: 1391
Reputation: 809
You can do one of two solutions, but first you need to make the representation of the output the same for the three models so for the second and third models
pred_2 = [y[0] for y in pred_2]
to look like the first model. (y[0] or y[1] depending on the meaning of the probabilities in your first model).
The first solution is to make a majority voting by computing the average of the three lists
majority_voting = [v/3.0 for v in[sum(x) for x in zip(pred_1, pred_2, pred_3)]]
The second solution is a little bit harder as you can use another deep learning model to make it choose the best result between the three models. 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 just majority voting.
Upvotes: 3