Formula used
Classification formulas
Gini = 1 − Σ pᵢ² Entropy = −Σ pᵢ log₂(pᵢ) Misclassification error = 1 − max(pᵢ) Weighted child impurity = Σ (Wⱼ / W) × Iⱼ Information gain = Parent impurity − Weighted child impurity Gain ratio = Information gain / Split information
Regression formulas
Weighted mean = Σ(wᵢyᵢ) / Σwᵢ MSE = Σ[wᵢ(yᵢ − ȳ)²] / Σwᵢ MAE = Σ[wᵢ|yᵢ − median|] / Σwᵢ Weighted child loss = Σ (Wⱼ / W) × Lⱼ Variance reduction = Parent loss − Weighted child loss
How to use the calculator
- Select classification or regression mode.
- Choose a numerical or categorical feature.
- Select the impurity or regression loss criterion.
- Paste feature, target, and optional weight values.
- Choose automatic, custom, grouped, or multiway splitting.
- Configure missing-value handling and tree constraints.
- Submit the form to rank candidate splits.
- Review the best split, child summaries, and charts.
- Copy, export, print, or save the configuration.
Example data formats
| Problem | Feature | Target | Optional weight | Example row |
|---|---|---|---|---|
| Iris classification | Petal length | Flower class | Sample importance | 4.9,Versicolor,1 |
| Loan classification | Income band | Approved or denied | Class weight | High,Approved,1.5 |
| House regression | Floor area | Sale price | Observation weight | 1450,285000,1 |
| Missing feature | NA | Any valid target | Positive weight | NA,Approved,1 |
Understanding decision tree splits
What the calculator evaluates
A decision tree divides observations into increasingly focused groups. Each proposed split creates child nodes from one parent node. The calculator measures whether those children are more useful than the parent.
For numerical features, valid thresholds sit between distinct sorted values. Testing midpoint thresholds avoids duplicate partitions. A custom threshold remains useful for auditing an existing model rule.
Categorical features need a different search process. One-versus-rest testing is fast and easy to interpret. Exhaustive grouping can find stronger binary partitions when category counts remain manageable.
Classification criteria
Gini impurity measures how often a random label assignment would be incorrect. Entropy measures uncertainty using logarithms. Both become zero when a node contains one class.
Information gain subtracts weighted child impurity from parent impurity. Larger values indicate a cleaner separation. Gain ratio adjusts that improvement using the information created by branch sizes.
Misclassification error only considers the majority class proportion. It changes less smoothly than Gini or entropy. That makes it useful for interpretation but less sensitive during split search.
Regression criteria
Regression trees predict numeric targets inside each leaf. Mean squared error emphasises larger residuals. Mean absolute error is more resistant to unusually large target values.
Variance reduction compares parent dispersion with weighted child dispersion. A useful threshold creates child targets clustered around separate predictions. Weak thresholds leave nearly the same residual spread.
Sample weights affect node predictions and every loss calculation. Larger weights give selected observations more influence. This supports cost-sensitive training, survey weights, and duplicated-sample equivalents.
Constraints and overfitting
A mathematically strong split can still generalise poorly. Very small leaves often memorise noise. Minimum sample and weighted-leaf constraints reduce that risk.
Minimum impurity decrease rejects improvements too small to justify complexity. Maximum depth limits repeated partitioning. Imbalance controls can prevent almost every observation entering one branch.
Missing-value routing also changes the calculated winner. Skipping missing rows measures only known features. Dedicated branches preserve missingness as potentially useful predictive information.
Frequently asked questions
1. Which split criterion should I choose?
Gini and entropy are strong classification defaults. MSE is common for regression trees. Gain ratio helps reduce preference for highly fragmented splits.
2. Why are thresholds placed between values?
Any threshold inside the same gap creates an identical partition. Midpoints represent that gap clearly. They also avoid assigning a threshold directly to an observed value.
3. Does the calculator support sample weights?
Yes, the third CSV column supplies a positive weight. Weights affect class counts, predictions, impurity, losses, and branch proportions. Omitted weights default to one.
4. What happens with missing feature values?
You can ignore them, route them left, route them right, or create another branch. The selected rule is applied consistently to every candidate split.
5. Why was the highest-scoring split rejected?
A split can violate leaf size, weight, gain, imbalance, depth, or child-count requirements. Rejection reasons appear beside the displayed result.
6. How are categorical groups searched?
One-versus-rest tests each category individually. Exhaustive mode tests unique binary partitions for twelve categories or fewer. Custom mode evaluates your selected left group.
7. Can the calculator create multiway splits?
Yes, multiway mode creates one branch per known category. A separate missing branch may also appear. The maximum child-node setting still applies.
8. Is MAE prediction based on the median?
Yes, a median minimises absolute error inside a leaf. The calculator uses a weighted median when sample weights differ.
9. Can I reproduce a production tree exactly?
This tool explains single-feature split calculations. Production libraries may add histogram binning, surrogate rules, random feature selection, regularisation, or implementation-specific tie handling.