Chapter 5:

Decision Trees and Random Forests

Learning Objectives

By the end of this chapter, you will be able to:

  • Train a decision tree model in scikit-learn
  • Use Graphviz to visualize a trained decision tree model
  • Formulate the cost functions used to split nodes in a decision tree
  • Perform a hyperparameter grid search using cross-validation with scikit-learn functions
  • Train a random forest model in scikit-learn
  • Evaluate the most important features in a random forest model

This chapter introduces decision trees and random forests in scikit-learn in addition to describing the method to perform hyperparameter grid search.

Introduction

In the last two chapters, we have gained a thorough understanding of the workings of logistic regression. ...

Get Data Science Projects 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.