Solved – Use Random Forest model to make predictions from sensor data

caretr

say I have a sensor that measures temperature, pressure ++, and want to use this data to predict some quantity "A". If I use multivariate regression, I can simply implement a model of the form A=a0+a1x1+a2x2+…, and whenever I have new measurements I can use the model to make predictions.

If I on the other hand make a predictive model using random forests, I'm not really sure how to use it. I've used the caret package to split my data into training and test sets, and do automatic feature selection using random forest and cross-validation. I get good predictions on the test set, but have no idea how to implement these trees to use in say a digital signal processor. In R I just use the predict() function, but this is obviously not available outside of R.

This is probably a stupid questing, but it's the best I can do.

Any suggestions are welcome.

Best Answer

Linear regressions are great because you can implement prediction very simply in any program that can multiply and add.

Random forests, on the other hand, are much more complicated. They are made up individually of decision trees, which can basically be represented by a set of rules. However, a random forest may have hundreds or thousands of individual trees, which would be very tedious to implement by hand in another system.

Your best bet is probably going to be to find a random forest implementation for the system you wish to export the model to, and then use PMML to export the model. The RPMML package will let you convert your random forest to an XML file, which you should be able to import to any system that supports PMML.

Related Question