Calculation Result
Detailed calculation
No calculation has been completed.
Calculator Modes
Formula Used
Zero impurity means one class fills the node. Lower split impurity usually indicates a stronger decision rule. Larger Gini gain means the split removes more uncertainty.
How to Use
- Select the calculation mode matching your decision-tree task.
- Enter valid class counts, probabilities, splits, or dataset rows.
- Choose precision, weighting, missing-value, and threshold settings.
- Press the calculation button and review ranked results.
- Copy, print, or export the detailed calculation.
Example Data
| Scenario | Input | Expected meaning |
|---|---|---|
| Pure node | 50, 0 | Gini equals zero. |
| Balanced binary node | 50, 50 | Gini equals 0.5. |
| Balanced three-class node | 30, 30, 30 | Gini approaches 0.6667. |
| Useful split | Parent 50,50; children 40,10 and 10,40 | Weighted impurity decreases. |
Gini Impurity and Entropy
Both measures evaluate class mixing inside decision-tree nodes. Gini uses squared probabilities and avoids logarithms. Entropy often changes more sharply near rare classes.
| Measure | Formula | Typical use |
|---|---|---|
| Gini impurity | 1 − Σpᵢ² | CART classification trees |
| Entropy | −Σpᵢlog₂pᵢ | Information gain trees |
| Misclassification error | 1 − max(pᵢ) | Simple node error estimate |
Frequently Asked Questions
What does Gini impurity measure?
It measures class mixing within a classification node. Zero means every sample shares one class. Larger values indicate a more mixed node.
Is a lower Gini value better?
Lower impurity usually means a purer decision-tree node. Split comparisons should use weighted child impurity. The smallest valid value often wins.
What is the maximum binary Gini impurity?
The maximum binary value is 0.5. It occurs with equal class probabilities. Multiclass maximums can exceed this value.
How is Gini gain calculated?
Subtract weighted child impurity from parent impurity. Positive gain indicates improved class separation. Larger gains indicate stronger impurity reduction.
Can this calculator handle multiclass data?
Yes, node and split modes accept many classes. Dataset mode detects labels automatically. All detected probabilities contribute to impurity.
How are sample weights used?
Dataset weights change class totals and child sizes. Single-node class weights adjust effective class counts. Negative or zero weights are rejected.
How are missing feature values handled?
You can exclude or assign missing rows. Categorical analysis can keep a separate category. The chosen method affects every candidate split.
Why can two splits share the same Gini?
Different splits can create equivalent class proportions. Their weighted impurities will then match. Secondary rules may choose between them.
Does the best local split guarantee the best tree?
No, tree construction commonly uses greedy decisions. A strong local split may limit later branches. Validation and pruning remain important.