Skip to content
RWRui Wang / Ideas
← All notes

Learn

Decision Trees

Decision Trees cover
Hello everyone, in this chapter we will not talk about ML in Python. We will explain a fundamental concept in ML: Decision Trees.


The most notable use of Decision Trees is classification, and it is very easy to understand. Here I will put a picture for everyone to help explain this concept.


whatis-decision-tree

As shown in the picture, a simple decision tree looks like this. It somewhat reminds me of the b-search we learned in CSA, haha. Back to the topic: decision tree, abbreviated here as DT.


As its name suggests, the most important part is the decision. A basic decision has only two results, right and wrong. For example: is it green? Normally, this question has only two answers: yes/no.


A DT judges whether this token does or does not satisfy the condition in the question. In Python, it is very simple to implement and is very basic content; it is no more than writing a few if/else if statements. I will not put a code block here because it is very basic.


Here I will give a very simple example of a decision tree, as shown:


Fig 1-18e1a01b

This decision tree is about weather. For example, when the weather is "Sunny, High Humid," then it is not a sunny kind of weather, so we need another branch to solve this classification problem. In another example, "Cloudy" directly becomes "Yes," because there is no such distinction for cloudy weather: as long as there are clouds, the weather is cloudy, and there is no need for another branch to make a finer branch.