WeCodeAcademy

Decision Trees

A decision tree asks a chain of yes/no questions about the features, like a flowchart, until it reaches an answer. Trees are easy to read: export_text prints the questions it learned.

Examplepython
Open in editor »
Quick check

What can `max_depth` do for a tree?

Your turn: write the code

Print the number of levels (depth) of the fitted tree using get_depth().

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.