• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

Most machine learning algorithms require extensive data preparation: numerical features must be scaled to the same range, categorical features must be encoded, missing values must be imputed, and outliers must be handled. This preprocessing pipeline is time-consuming, error-prone, and can significantly impact model performance if done incorrectly.

Core Idea

Decision trees require minimal preprocessing because they make decisions based on feature thresholds rather than distance calculations or weighted sums. They naturally handle mixed data types (categorical and numerical), are invariant to feature scaling, and can handle missing values through surrogate splits.

How It Works

Why decision trees don’t need common preprocessing steps:

  1. No feature scaling needed: Since trees compare values to thresholds (e.g., “Income > 50K”), the absolute scale doesn’t matter. Doubling all income values would simply shift the threshold — the split logic remains identical.

  2. Natural categorical handling: Categorical attributes are split by creating one branch per category value. No one-hot encoding or label encoding is required.

  3. Monotonic transformations are irrelevant: Applying log, sqrt, or any monotonic function to a feature doesn’t change which threshold-based splits are possible — the relative ordering is preserved.

  4. Outlier tolerance: A single extreme value doesn’t distort the tree’s behavior the way it would in distance-based methods like k-NN or SVM.

The source explicitly lists “low preprocessing needs” as one of the reasons why “decision trees are widely used” — alongside interpretability and flexibility.

Visual Explanation

digraph decision_tree_preprocessing {
    rankdir=TB
    node [shape=box style=filled fontname="Helvetica" fontsize=11]
    edge [fontname="Helvetica" fontsize=10]
 
    raw [label="Raw Data\nMixed types, unscaled, missing" fillcolor="#e8e8e8"]
    tree [label="Decision Tree\n(Threshold-based splits)" fillcolor="#ffd700"]
    model [label="Trained Model\nNo preprocessing required" fillcolor="#d4edda"]
 
    scaling [label="NOT NEEDED:\n- Feature scaling\n- Normalization\n- One-hot encoding\n- Outlier removal" fillcolor="#ffcccc" shape=note]
 
    raw -> tree -> model
    tree -- scaling [style=dashed label="skips"]
}

Key Properties

  • Scale-invariant: Feature values can be in any range without affecting tree quality
  • Type-flexible: Handles numerical, categorical, and ordinal features natively
  • Robust to outliers: Extreme values don’t distort split decisions
  • Missing-value tolerant: Can use surrogate splits or majority routing for missing features

Connections

Edge Cases & Gotchas

  • Not zero preprocessing: Extremely noisy data or massive cardinality still benefit from preprocessing
  • High-cardinality categories: An attribute with 10,000 unique values can cause overfitting even in trees
  • Missing data handling varies: Not all tree implementations handle missing values — check your library
  • Still benefits from cleaning: Removing irrelevant features speeds up training and reduces overfitting