# How to document a Random Forest result (final model)?

Using Random Forest to predict dichotomous variables (for classification) I encountered the problem how to best document this model, i.e. I want the user to reproduce/use the final model I created on my computer. E.g. let's assume I want to proliferate the model (which I created in R) in a publication or to others how would you do this?

MWE: If I want to document this model how am I able to do this (without including the data):

data(iris)
iris.rf <- randomForest(Species ~ ., data=iris, importance=TRUE,
proximity=TRUE)


How can I include the model iris.rf in a publication so that others can use it to predict Species with new data?

I am looking for a way to make a forest reproducible for the reader/user (without having the data which was used for creating the forest necessarily). I was asking myself if there are other ways of publishing a RF without adding the source data.

• Can you clarify what you mean by "document" here? Do you need a reference to cite in a scientific publication that includes a RF model, or are you asking about how to write up a RF model in a paper, or are you talking about documentation / help files for end users of a RF model? – gung Mar 2 '15 at 14:57
• Sure. It's how to write up a RF model (in a paper), in order that the reader is able to use it (e.g. for predictions by her-/himself). – tnaake Mar 2 '15 at 15:01
• So something analogous to help files (eg ?randomForest) then? – gung Mar 2 '15 at 15:07
• Not quite. Something analously to a lm object: a model with coefficients (I know this doesn't exist for RF) to predict new values using e.g. the predict function in R. – tnaake Mar 2 '15 at 15:10

A Random Forest is a collection of decision trees. So you have a collection of, say, 500 decision tree models that are voting on the final answer, and each of these models can't be described any more succinctly than the decision trees themselves. So you're out of luck if you want a concise summary of your RF model.

You can talk about predictive power, you can use variable importance stats from the RF -- which can be biased in the case of categorical variables -- and you can draw pretty pictures, but that's about it.

You could set aside your RF and consider it (variable importance, etc) to be an exploratory tool which you then use to make a logistic regression. Then you'll have a nicely compact result: a glm which is much like lm, of course.

Oh, others have asked similar questions before:

Best way to present a random forest in a publication?

https://stackoverflow.com/questions/14996619/random-forest-output-interpretation

• Thanks! So, the best way would be then, to put the data on a publicly available source and include the code to reproduce the model? – tnaake Mar 3 '15 at 8:45
• And do you know about publications where this was done in an excellent way? – tnaake Mar 3 '15 at 8:51
• @tnaake: Your code and data on a public source is the best way to do things. Most people don't do that because they view their data as proprietary or they're embarrassed that their code is poor. I don't know of any publications that I could point you to. – Wayne Mar 3 '15 at 16:26