Predicting subscribers with random tree forests

Random forests belong to a family of ensemble models. The ensemble models work on a premise that two brains are better than one; they combine the predictions of many weaker models (decision trees) to come up with a prediction that reflects a mode among these weaker models. For more, check https://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm.

Getting ready

To execute this recipe, you will need pandas and scikit-learn. No other prerequisites are required.

How to do it…

As in previous examples, Scikit provides an easy way of building a random forest classifier (the classification_randomForest.py file):

import sklearn.ensemble as en @hlp.timeit def fitRandomForest(data): ''' Build a random forest ...

Get Practical Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.