Decision Tree Learning: A Flowchart for Your Data
Decision tree learning builds a predictive flowchart from your data. It's used for classification (like spam vs. not spam) or regression (like predicting price). The main footgun is overfitting: creating a tree so specific it can't handle new data.
WHY IT EXISTS Many machine learning models are 'black boxes,' making it hard to see why they made a certain prediction. Decision tree learning was developed to create predictive models that are inherently easy for humans to understand, visualize, and explain. It provides a clear, rule-based path to a conclusion.
THE MENTAL MODEL Think of a decision tree as playing a game of '20 Questions' with your data. The algorithm learns the best questions to ask in order to arrive at a conclusion as efficiently as possible. The final model is a simple flowchart of these questions, where following a path down the chart based on an observation's features leads to a specific prediction.
HOW IT WORKS As a supervised learning approach, it starts with labeled data—a set of observations where the outcome is already known. The algorithm examines all features and finds the one that, when split, best separates the data into distinct outcome groups. For example, it might find that splitting customers by 'age < 30' is the most informative first step. This process is repeated for each new subgroup, creating branches and nodes. The tree stops growing when a rule is met, like reaching a maximum depth or having too few samples left to split. The resulting tree is the predictive model.
WHEN TO USE IT Use decision trees when model interpretability is critical. If you need to explain the 'why' behind a prediction to a manager, regulator, or customer, a decision tree is an excellent choice. It works well for both classification (predicting a category) and regression (predicting a number) and can handle mixed data types without much pre-processing.
WHEN NOT TO USE IT Avoid using a single, deep decision tree for mission-critical predictions. They are highly prone to overfitting, meaning they learn the noise in the training data and fail to generalize to new, unseen data. They can also be unstable; small changes in the input data can result in a completely different tree. For higher accuracy, ensembles of trees like Random Forests or Gradient Boosted Trees are usually better.
ONE CANONICAL EXAMPLE A bank wants to predict if a loan applicant will default. Using historical data, the algorithm might learn a first rule: 'Is income less than $50,000?'. If yes, it might then ask, 'Does the applicant have other outstanding debt?'. By following this path of questions for a new applicant, the model arrives at a final prediction: 'Default' or 'No Default'.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.