# Ensemble Methods for Probabilities

I am currently trying to build a stacked algorithm in order to determine how many people in each region of a country will be likely to buy a product versus its competitors. I have some data from an online survey which collects user's demographics as well as their preferred product and I've weighted these so they reflect my customer base correctly.

I currently have three models that I am happy with (XGBoost, Random Forest and Multi-Layer Perceptron) - they give me probabilities that I can then use to poststratify to determine how many people in each region will buy each product.

I now want to stack these models together so I can get a better model that incorporates all of the predictions. I would like to do this so that at the end I get some distributions of how many people I might be able to target in each region, rather than just a point estimate. I have tried building a model in BRMS (R) which uses the predicted probabilities from each model and treats them linearly, e.g.

product ~ prob_A_XGB + prob_B_XGB + prob_A_RF + prob_B_RF + ...

where I have dropped one of my products to avoid multicollinearity in the model. Unfortunately, my meta model gives very different predictions to my base models. I have also tried building a model which uses a majority voting by using the predicted product from each model but this performs even worse.

Is there anyway to essentially take a "weighted" average of the class probabilities in my base models that will give me a distribution of the potential number of customers in each region?

• I have read your post twice, and am still confused. On the one hand, you seem to want a prediction of the number of people that buy your product. But on the other hand, you write about predicted probabilities. And you seem to be switching back and forth between the two... can you please clarify? Commented Mar 1 at 17:25
• I have a post stratification data frame which is in a long format which groups people together based on their age group , gender, income group and region. Each of these groups has a number of people in it. I have ran classifiers using my survey data to predict which product someone will buy based on their demogs (and info about their region). These models give me probabilities of buying a product based on demographics and regional info. I then run my post strat data frame through my models and use the predicted probs to estimate the number of people who will buy each product in each region. Commented Mar 1 at 17:30
• OK, thanks, that helps. Commented Mar 1 at 17:33

• If you have a group of size $n$, and each member has a probability $p$ of buying one unit, and if purchases are independent, the total number of purchases is binomially distributed with parameters $n$ and $p$. Commented Mar 2 at 12:16