Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

Decision Trees and CART: How Splits Work and How to Prevent Overfitting

Decision trees turn feature questions into predictions. This guide explains CART's split selection, Gini versus entropy, CART and C4.5 differences, pruning, reproducibility, and practical scikit-learn controls.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A decision tree is a non-parametric supervised-learning model that predicts an outcome by asking a sequence of feature questions. CART (Classification and Regression Trees) builds the tree by testing feature-and-threshold pairs, selecting the split with the greatest impurity or loss reduction, and repeating that process on both child nodes. Classic CART produces a binary tree and supports both classification and regression.

What a decision tree is

A tree recursively partitions feature space into smaller regions. Internal nodes contain split rules, branches represent the outcomes of those rules, and leaves contain the final prediction.

As an Amazon Associate I earn from qualifying purchases.

  • Classification: a leaf predicts a class, usually the majority class among training samples that reach it. Class probabilities can be estimated from the class proportions in that leaf.
  • Regression: a leaf predicts a numeric value, commonly an average of the training targets in that region.

Because trees make no assumption that the relationship between a feature and target is linear, they are called non-parametric. They can represent interactions and abrupt changes, but an unrestricted tree can memorize training data.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How prediction works

To classify or estimate a new observation, start at the root and apply its split rule. Follow the matching branch, apply the next rule, and continue until reaching a leaf. The leaf’s stored class or numeric prediction is the output.

How CART chooses a split

At a node, CART evaluates candidate pairs consisting of a feature and a split point. For a numeric feature, a candidate might be “income ≤ 50,000.” The samples are divided into left and right child nodes, and the children receive a weighted impurity or loss score:

weighted score = (nleft/n) × scoreleft + (nright/n) × scoreright

CART selects the candidate with the lowest weighted score, equivalently the largest reduction from the parent node’s score. It then searches for another split independently in each child until a stopping rule prevents further growth.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Classification criteria

  • Gini impurity: 1 − Σ pk2, where pk is the proportion of class k in the node. It is zero when every sample belongs to one class.
  • Entropy (information gain): −Σ pk log(pk). A pure node has zero entropy. The split is selected by the reduction in entropy.
  • Log loss: evaluates the quality of predicted class probabilities rather than only class purity. Availability and behavior depend on the library and version.

Gini and entropy often produce similar trees, but they are not mathematically identical. Choose one based on the objective and the implementation’s validation results rather than assuming one is universally superior.

Regression criteria

For regression, the node score is a regression loss. Squared error is a common choice: a split is preferred when it reduces the weighted within-node squared deviations of target values. The exact set of regression criteria depends on the library version; check the estimator reference for the version you deploy.

Binary branching

Classic CART makes a two-way decision at every internal node. A multi-category feature is therefore represented through binary tests, depending on the implementation’s encoding and categorical-feature support. Binary structure keeps the search and resulting paths consistent, while a multiway method can sometimes express a categorical split in fewer levels.

Why trees overfit

If growth continues until leaves contain very few observations, the tree can model noise, outliers, and accidental training-set patterns. Training accuracy may keep improving while validation performance worsens. Deep trees also become harder to inspect and can be unstable: a small change in the data may change an early split and restructure many descendants.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Controls that limit tree complexity

Use validation or cross-validation to select complexity settings. No single value is optimal for every data set.

max_depth

Caps the number of edges from the root to the deepest leaf. A lower value gives a smaller, easier-to-explain model; a higher value allows more interactions but raises overfitting risk.

min_samples_split

Requires a node to contain at least a specified number of samples before it can be split. Increasing it prevents very small parent nodes from generating additional rules.

min_samples_leaf

Requires every resulting leaf to contain at least a specified number of samples. This is a direct way to keep predictions from depending on one or two observations and is especially useful with noisy targets.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

max_leaf_nodes

Limits the total number of leaves, providing a direct budget for the number of terminal regions.

min_impurity_decrease

Permits a split only when its weighted impurity reduction reaches the configured threshold. This removes weak splits even when depth and sample-count limits would allow them.

Minimal cost-complexity pruning

Cost-complexity pruning compares a subtree’s fit with a penalty for its number of leaves. A fully grown tree can be generated, then subtrees whose additional fit is not worth their complexity can be removed. Select the pruning strength with a validation set or cross-validation, not from training accuracy alone.

Gini impurity or entropy?

Both criteria are valid classification choices. Gini uses squared class proportions and is often a convenient default; entropy is information-theoretic and can be useful when probability separation is important. The practical difference is data-dependent, and neither criterion guarantees better generalization. Compare them under the same cross-validation splits, preprocessing, and complexity controls. If probability quality matters, evaluate a proper probability metric in addition to accuracy or a confusion matrix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CART versus C4.5

CART and C4.5 are closely related tree-induction methods, but their design priorities differ.

Axis Classic CART Classic C4.5
Targets Classification and numerical-target regression Primarily classification; regression support is not the defining feature
Tree shape Binary splits Can use multiway splits for categorical attributes
Split measure Impurity or loss reduction, such as Gini or squared error Information-based measures, including gain-related criteria
Rule sets Builds a tree; the scikit-learn guide describes CART as not computing rule sets Associated with generating rules from trees
Categorical features Support depends on the implementation and version Traditional implementations were designed to handle categorical attributes
Pruning Includes cost-complexity pruning in common implementations Uses its own pruning approach; details vary by implementation
Reproducibility Can be affected by feature-order randomization and tied split improvements Depends on the particular implementation

The official scikit-learn guide describes CART as “very similar to C4.5,” while highlighting numerical-target regression and the absence of rule-set generation as key differences. Treat categorical-feature claims as version-specific: scikit-learn’s 1.2 documentation stated that its tree implementation did not support categorical variables directly, so verify the exact version and estimator you use.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Using a decision tree in scikit-learn

The estimator names and accepted criteria should be checked against the scikit-learn version installed in your environment. A typical classification workflow looks like this:

  1. Split the data into training and validation portions, or define cross-validation folds.
  2. Fit DecisionTreeClassifier with a criterion such as "gini", "entropy", or, where supported, "log_loss".
  3. Search complexity settings such as max_depth, min_samples_leaf, and ccp_alpha using validation performance.
  4. Refit the selected configuration on the available training data and evaluate once on untouched test data.
from sklearn.tree import DecisionTreeClassifier

model = DecisionTreeClassifier(
    criterion="gini",
    max_depth=5,
    min_samples_leaf=10,
    random_state=42,
)
model.fit(X_train, y_train)
predictions = model.predict(X_test)

For a numeric target, use DecisionTreeRegressor and select a regression criterion supported by your installed version. The example values above are illustrative starting points, not universal recommendations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make fitting reproducible

The current classifier reference notes that features are randomly permuted at each split. When multiple candidate splits have the same improvement, the implementation may choose among them randomly. Set random_state when you need repeatable fitting, and record the library version, preprocessing, data split, and parameter configuration.

Strengths and limitations

Strengths

  • Predictions can be explained as a sequence of explicit rules.
  • They capture nonlinear effects and feature interactions without requiring a linear model specification.
  • They can be used for both classification and regression in the CART framework.
  • Feature scaling is generally not required for threshold-based splits.

Limitations

  • Unpruned trees can overfit badly.
  • Small data changes can produce a different structure.
  • Very deep trees become difficult to communicate and audit.
  • Class imbalance, missing values, and categorical variables require deliberate handling that varies by library.
  • A single tree may be less stable than an ensemble of trees, although ensembles trade away some direct interpretability.

A practical decision checklist

  • Confirm whether the target is categorical or numeric.
  • Check your library version’s supported criteria, missing-value behavior, and categorical-feature support.
  • Choose a baseline criterion, then compare alternatives with the same cross-validation procedure.
  • Set a complexity control before interpreting training performance.
  • Inspect leaf sizes, validation error, and the resulting paths for implausible rules.
  • Set random_state and record the complete fitting configuration when reproducibility matters.

Further reading

The foundational reference is Classification and Regression Trees by Leo Breiman, Jerome Friedman, Richard Olshen, and Charles Stone, published in 1984. For implementation details, consult the documentation for the exact tree estimator and version used in your project.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.