# How to combine results of logistic regression and random forest?

I am new to machine learning. I applied logistic regression and random forest on a same dataset. So I get variable importance (absolute coefficient for logistic regression and variable importance for random forest). I am thinking to combine the two to get a final variable importance. Can anyone share his/her experience? I've checked bagging, boosting, ensemble modeling, but they are not what I need. They are more of combining information for the same model across replicates. What I am looking for is to combine result of multiple models.

• Ensemble modelling can also combine models. Look into majority voting for example. See also, stacking.
– pat
Jan 3, 2013 at 22:14
• Actually, using the size of coefficients is not a good way to determine "variable importance" in logistic regression. Even if you look at standardized coefficients, that's not a good method. Why? Remember that the coefficients are just estimates and there's an error associated with them. Picking coefficients by size means that you pick those for which you over-estimated the coefficient size and drop those for which you under-estimated the coefficient size. Jan 4, 2013 at 4:37

It probably depends on what you want to use variable importances for. Is it to be used as a criterion for feature selection for a third classification model? In that case you could try to compute a weighted average the variable importances (maybe after normalizing each individual variable importance vector to unit length) for various values and the averaging weight and then pickup the value that yields the best cross-validated score for the final model.

As for combining the outcome of the logistic regression model and the random forest model (without considering variable importances), the following blog post is very informative and demonstrates that a single averaging of the output is a simple yet very effective ensemble method for regression models.

• Thank you for your reply. The blog you mentioned is really interesting study. I think I got the idea. Only concern is his cross entropy formula. It seems different with the one I found online. His using: cross.entropy <- function(target, predicted) { predicted = pmax(1e-10, pmin(1-1e-10, predicted)) - sum(target * log(predicted) + (1 - target) * log(1 - predicted)) } Jan 4, 2013 at 20:01
• and when I applied the same idea to my own dataset, I used misclassification error as criteria, the plot is nothing similar. Random forest turns out much better than logistic regression. misclassification error of RF is 0.2, for LR is 0.4. At the same time, AUC for RF is 0.8, for LR is 0.73. Jan 4, 2013 at 20:04

(Commenting on above response and feedback)