How trees work

Now that we know how it works, let's talk at a high level about how it produces these rules. Essentially, trees produce their predictions by partitioning the feature space into rectangular regions. In the case of classification, it finds those splits that make the regions as homogeneous as possible. The method commonly used is called recursive binary splitting. Suppose we have two categories, purple and yellow, that we would like to classify. Let's say that we have two features and you would like to split one of them such that the space is divided into two regions. The goal is to make the two regions as "pure" or homogeneous as possible; you have to answer two questions:

  1. Which feature should you split?
  2. At which point should ...

Get Hands-On Predictive Analytics with Python 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.