XGBoost Gain Calculator

Evaluate XGBoost decision-tree splits, compare candidate thresholds, inspect regularisation effects, calculate leaf weights, validate child nodes, and understand every gain calculation step clearly today.

Main split inputs

Enter parent, child, and missing-value statistics. Values may come from any custom objective.

Regularisation settings

Adjust XGBoost penalties and compare their effect on split quality.

Candidate split comparison

Add thresholds across one or many features.

Feature Threshold Parent G Parent H Left G Left H Right G Right H Missing G Missing H Auto right Actions

Import candidate data

Use CSV, JSON, or pasted tabular data. The table updates before calculation.

Expected columns: feature, threshold, parent_g, parent_h, left_g, left_h, right_g, right_h, missing_g, missing_h, auto_right.

Formula used

Soft threshold: T(G, α) = sign(G) × max(|G| − α, 0)

Node score: Score = T(G, α)² ÷ (H + λ)

Raw gain: ½ × [Score(left) + Score(right) − Score(parent)]

Final gain: Raw gain − γ

Leaf weight: w* = −T(G, α) ÷ (H + λ)

How to use

  1. Enter parent gradient and Hessian totals.
  2. Enter left, right, and missing statistics.
  3. Choose lambda, gamma, alpha, and minimum child weight.
  4. Add candidate thresholds for comparison.
  5. Select Calculate gain to rank every valid split.
  6. Review gain, weights, warnings, charts, and missing direction.
  7. Copy, print, or download the result.

Example data

Scenario Parent G Parent H Left G Left H Right G Right H Purpose
Binary classification -8 20 -6 8 -1 10 Compare a useful classification split.
Regression 14 30 11 12 3 18 Measure squared-error objective improvement.
Rejected split 2 15 1 7 1 8 Show a low-gain candidate.
Strong regularisation -25 40 -18 19 -7 21 Inspect lambda and alpha effects.

Understanding the result

Positive final gain means the split improves the regularised objective. Zero gain means the split adds no measurable improvement. Negative gain normally means the split should be rejected.

Lambda reduces extreme node scores and leaf weights. Alpha removes weak gradient contributions through soft thresholding. Gamma requires enough improvement before a split is accepted.

Minimum child weight checks each child Hessian total. Missing values are tested in both directions. The calculator selects the direction producing higher final gain.

Frequently asked questions

What does XGBoost gain measure?

Gain measures objective improvement from creating two child nodes. It compares child scores against the parent score. Regularisation penalties reduce the final value.

Why is the Hessian required?

The Hessian represents second-order curvature information. It stabilises score and weight calculations. Larger Hessians usually reduce extreme updates.

What does lambda change?

Lambda adds L2 regularisation to every denominator. Higher values shrink leaf weights. They may also reduce split gain.

What does alpha change?

Alpha applies L1 regularisation to gradients. Small gradients may become zero. This encourages simpler and sparser updates.

What does gamma change?

Gamma is subtracted from raw split gain. It discourages weak tree growth. A split must exceed this penalty.

Why compare missing directions?

XGBoost can learn a default path for missing values. Each direction produces different child statistics. The better gain becomes the preferred path.

When is a split accepted?

The final gain should be positive. Both children should satisfy minimum child weight. Input statistics must also remain valid.

Can regression gradients be used?

Yes, custom regression gradients and Hessians are supported. Enter their sums for each node. The gain formula remains objective based.

Why might totals not match?

Parent statistics should equal left, right, and missing totals. Rounding may create small differences. Large differences usually indicate input mistakes.

Related Calculators

Decision Tree Entropy CalculatorInformation Gain CalculatorGini Impurity CalculatorDecision Tree Split CalculatorRandom Forest Voting CalculatorGradient Boosting Prediction CalculatorAdaBoost Weight CalculatorBagging Sample CalculatorDecision Tree Splitting QuizGini Impurity Quiz

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.