EmJ
EmJ

Reputation: 4608

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

I have three classification models as follows where the labels of my data is 1 or 0.

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

Answers (1)

Mostafa Labib
Mostafa Labib

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

Related Questions