# Can I use random forest and other machine learning models for inference?

I think the answer for this question is yes, but I'm still wondering how to do this.

Here's the thing, I have a dataset with several products, their characteristics and the price a customer paid for the product. I want to know which characteristic make the product more prone to be sold.

So, I would have something like this:

id        color        size          material        price    sold
A1        yellow       big           plastic         200      0
A2        yellow       medium        wood            30       1
C1        blue         medium        wood            200      0
B1        purple       small         plastic         10       1
D1        yellow       medium        plastic         110      0
C2        pueplw       big           wood            140      1
A3        yellow       small         wood            50       1
A1        yellow       medium        wood            100      1


And I want to know if the product being yellow increase the probability of selling it and if it does, if it's more important than the material.

Is that something I could do with random forest and other models? And is there anything I should look at that we usually don't look when running them for prediction?

I was wondering this because I'm used to work with these for prediction. Before that, I've only worked with logistic regression and IV models. I ran a random forest on this dataset and got the feature importance, but I'm not 100% sure about that.

• Look at the Boruta library in R. It uses permutation importance. – EngrStudent May 29 at 13:22
• You will want to spend some time learning about demand estimation and econometrics. To guide you, there are a few questions. Is there any variation in price (holding product characteristics fixed)? If there is, what is the source of this variation? It looks like you have repeated observations for some buyers? Is that the case? – Dimitriy V. Masterov May 29 at 21:39

## 2 Answers

... I want to know which characteristic make the product more prone to be sold.

...

And I want to know if the product being yellow increase the probability of selling it and if it does, if it's more important than the material.

Is that something I could do with random forest and other models? And is there anything I should look at that we usually don't look when running them for prediction?

It sound like you are generally interested in finding causal relationships and if present the relative strength of the effects of different variables on the probability of selling the product. If so, you should have a look at Is machine learning less useful for understanding causality, thus less interesting for social science?.

You may be able to finds such effects and compare them using random forest, a machine learning method, or a statistical model but this depend on the assumptions you make and the way that the data is collected.

Random Forest Regressor/Classifier is an appealing option, because:

1. It is very fast and easy to setup and train (especially with the Sklearn package).
2. It handles both categorical and numerical features.
3. The "feature importance" property provides a really nice analysis tool.
4. it requires less preprocessing than other supervised algorithms.

I am not saying it is the best model for your problem. I'm saying it's a good algorithm to start with.