Estimating the output of an electric plant using CART

Previously, we used decision trees to classify our bank contact calls (refer to the Classifying calls with decision trees recipe from Chapter 3, Classification Techniques). Classification and regression trees are the equivalent methods applied to regression problems.

Getting ready

To execute this recipe, you need pandas and Scikit. No other prerequisites are required.

How to do it…

Estimating CART with Scikit is extremely easy (the regression_cart.py file):

import sklearn.tree as sk @hlp.timeit def regression_cart(x,y): ''' Estimate a CART regressor ''' # create the regressor object cart = sk.DecisionTreeRegressor(min_samples_split=80, max_features="auto", random_state=666666, max_depth=5) # estimate ...

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.