How does one use machine learning to identify/analyze the importance and impact of independent variables on dependent variables?

Let's say I have a data set with independent variables being: carbohydrates, fiber, fat, protein and dependent variable is: healthy. Independent variables are linear (grams consumed in the past week) and healthy is categorical.

With this data, imagine having person X walk in and asking what makes me healthy and what doesn't? How would you go about analyzing that question and responding in in a quantifiable answer?

  • $\begingroup$ There's this thing ML people tend to ignore called inferential statistics... Any stats book would be able to provide more info $\endgroup$
    – Jon
    Oct 12 '16 at 3:27
  • $\begingroup$ What do you mean by "dependent variables"? $\endgroup$ Oct 13 '16 at 13:55

Lets express your problem statement as the following relationship:

Healthy ~ carbohydrates + fiber + fat + protein

Since you've decided this should be posed as a classification problem, our first objective is to find out the decision boundary between healthy=1 and healthy=0. To do this, you could use a variety of popular machine learning algorithms such as Random Forest, Logistic Regression, Linear regression, Boosted trees, etc. Once you have built the best model using the data you have, you can then proceed to use it to identify which of the independent variables it considers most important.

Algorithm implementations such as Random Forest and Gradient Boosting Machines generate this "importance" listing as part of the model training process and you can easily extract these. But you may find out the the order of importance varies depending upon which algorithm you used to build the model. This is because each algorithm determines the classification boundary in a different way.

The random forest algorithm fits multiple trees, each tree in the forest is built by randomly selecting different features from the dataset. The nodes of each tree are built up by choosing and splitting to achieve maximum variance reduction. While predicting on the test dataset, the individual trees output is averaged to obtain the final output. Each variable is permuted among all trees and the difference in out-of-sample error of before and after permutation is calculated. The variables with highest difference are considered most important, and ones with lower values are less important.

A gradient boosted machine calculates a gain - this implies the relative contribution of the corresponding variable to the model calculated by taking each variable's contribution for each tree in the model. A higher value of this metric when compared to another variable implies it is more important for generating a prediction.

Variable importance is very different for a linear regression model as compared to a random forest or a GBM model. A popular approach for linear regression models is to decompose $R^2$ into contributions attributed to each variable. But variable importance is not straightforward in linear regression since variables might be correlated. Refer to the document describing the PMD method (Feldman, 2005) in the references below. Another popular approach is averaging over orderings (LMG, 1980). The LMG works like this:

  • Find the semi-partial correlation of each predictor in the model, e.g. for variable a we have: $SS_a/SS_{total}$. It implies how much would $R^2$ increase if variable $a$ were added to the model.
  • Calculate this value for each variable for each order in which the variable gets introduced into the model, i.e. {$a,b,c$} ; {$b,a,c$} ; {$b,c,a$}
  • Find the average of the semi-partial correlations for each of these orders. This is the average over orderings.

There isn't much consensus on the best method to determine relative importance of variables in logistic regression models. But for practical purposes (applying the same analogy as the linear regression model's $R^2$) , you could use adjusted $R^2$ to determine how much would $R^2$ increase if each particular variable were added to the model.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.