Trees and Gradients Upgrade: What is a new tree fixing

Four samples were used to calculate the fractions, residues, learning rates and second-order leaf weights and to understand the capacity of tree models and the sources of error.

System Chapter . StepCollate in 2 Graphics6 self-measurement3 First-hand sources
Start Body
Learning objectives and first steps4 objectives 2 first repairs

Try to do it after reading

  • Distinguishing rules, leaves output and overall loss
  • A Gradient Increase for Hand-Square Loss
  • Infers the weight of the leaves and the gain of the cut below the second step
  • Check time leaks, category codes and training for extrapolation of boundaries

Suggested first

  • Average, square loss and lead
  • Training validation delineation and regularization

Why the trees in the table baseline deserve to be carefully understood

User attributes, historical statistics and strategic states often comprise isomer table data: some relationships are only evident if they cross thresholds, depending on the field size. Trees are non-linear in the form of simple projections in the leaves, by cutting into space in turn; There is no need to predetermine each interactive form of function. But trees do not automatically understand time, nor do they prevent future fields that should not be used. For credit and extension missions, a tree baseline that uses a pass through the label is equally likely to yield beautiful but ineffective offline results.

This chapter begins with four synthetic regression samples, requiring averages, square losses and first-order guides. The goal is to identify what is optimized by a single cut, why the gradient rises often refer to the “mixed debris”, and how the second line leaf weight of XGBoost is related to this statement. The example does not use real business data and does not compare the effects of any production model.

How to select a threshold for a small tree

Remove x = [1,2,3,4], y = [1,1,3,5]. When only one constant projection is used, the best value for a square loss is the average label value of 2.5, the residual difference is [−1.5, 10-1.5, 0.5, 2.5], the residual square and 11. If the candidate threshold is 2.5, the average tag value for the two samples on the left is 1; for the two on the right it is 4; and for the square with the cut it is 2. This cut has therefore reduced the training gap square and reduced 9.

The corresponding square and 8 for the threshold of 1.5; The threshold of 3.5 corresponds to 8/3 and approximately 2.66667, so 2.5 of the three candidates are preferable. Here, a partial improvement in the same sample of training, the same square loss was evaluated. Greed choices do not enumerate all the subsequent trees, and the current optimal division does not necessarily make the best tree in the whole picture at a given depth.

One tree gives a constant forecastFour labels are one, one, three, five. The threshold of 2:5 sets the projections for the left or right leaf at one and four, with one residue for each right leaf.1234Threshold 2.5Left leaf projection 1Right leaf projection 4
Original synthetic data diagram. A smooth curve with leaves giving constants rather than connecting samples; The right orange line is broken.

Classification trees will be replaced with criteria such as class probability, cross-enthon or Gini; Other losses may also be used in returning trees. The branch of the missing value, whether the classification features are orderly and how many minimum samples of leaves are required are all part of the model definition.Tree document for scikit-learn The criteria and boundaries are listed and the default behaviour of a bank cannot be considered to be the common nature of all tree algorithms.

The gradient is raised by an amendment to the forecast already available

Sets the current function to F and the new tree to h. A square loss of one-half times the error square is the current projected gradient of F−y and the negative gradient of y−F, which is the residue. Lets the tree fit into a negative gradient and then add the old function to the learning rate. Note that the “to be reduced” is the most intuitive under a square loss and that when replaced with a classification of cross-encolium or other minor loss, the negative gradient definition should be returned, rather than reproducing all steps with the original label to reduce probability.

Fm+1(x)=Fm(x)+ηhm(x)

From the constant 2.5, the threshold of 2.5 new trees are exported to the left -1.5 and to the right 1.5. = 1 with new projection [1,1,4,4], square and 2; = 0.5 p.m., new projections are [1.75,1.75, 3.25, 3.25], square and 4.25. This round of small learning has improved less, but it is possible to achieve a more robust compromise through more rotations, verification of early stoppages and binding tree complexity. Learning rates should not be reduced by half while training cycles should be fixed, and the results should be interpreted as worse in their own way.

A step-by-step update of the training disability square sumThe constant baseline is XI; Half-step update to 4:25; Updates to two. Bar width is drawn at the same scale.Constant baselineη = 0.5η = 1114.252A comparison of the same four training samples does not represent a generalized gain
The original figure is changed by the addition of the new tree. Three columns have no correlative on-line experiments.

Where does the weight of the second line come from

XGBoost expands each sample loss to second order. With fixed tree structure and common leaf output w, sum gradients as G and second derivatives as H, adding λw²/2. Stationarity gives optimal leaf weight −G/(H+λ), subject to conditions such as H+λ>0. Arbitrary losses do not automatically yield valid convex approximations.

w*=−GH+λ,G=∑i∈叶gi,H=∑i∈叶hi

Here squared loss has second derivative 1 per sample. Left/right leaf gradients are 3 and −3, each with H=2. With λ=1, outputs become −1 and 1, distinct from unregularized ±1.5; do not mix them in one gain table. Split gain subtracts the parent score and new-leaf complexity cost γ. λ shrinks values; γ prices structure. For derivations and notation see XGBoost official curriculum Checks on a line-by-line basis.

Standard Python recovery

The following Python 3 codes have been implemented by CPU, without dependency and random numbers. It carries three single identity thresholds and achieves only one tree, not disguised as a complete GBDT trainer.

import math
x, y = [1,2,3,4], [1.0,1.0,3.0,5.0]
base = sum(y)/len(y)
residual = [v-base for v in y]
results = []
for threshold in [1.5,2.5,3.5]:
left = [r for a,r in zip(x,residual) if a <= threshold]
right = [r for a,r in zip(x,residual) if a > threshold]
wl, wr = sum(left)/len(left), sum(right)/len(right)
pred = [base+(wl if a <= threshold else wr) for a in x]
sse = sum((p-t)**2 for p,t in zip(pred,y))
results.append((sse,threshold,wl,wr))
best = min(results)
assert math.isclose(best[0],2.0)
assert best[1] == 2.5
for eta in [0.5,1.0]:
pred = [base+eta*(best[2] if a<=best[1] else best[3]) for a in x]
print(eta,pred,sum((p-t)**2 for p,t in zip(pred,y)))
# 0.5 [1.75,1.75,3.25,3.25] 4.25
# 1.0 [1.0,1.0,4.0,4.0] 2.0
print(-3/(2+1),3/(2+1)) # 正则叶子 -1.0 1.0

What kind of engineering errors could make it less real

(b) Random forests train multiple trees on different samples and feature subsets, then average, mainly using diversity to reduce differences; Uplifting trees are supplemented by current errors, which cannot be understood by simply "in many trees".Official Integrated Learning Document This could be used to compare training mechanisms. The depth of the tree, the amount of leaf samples, the column sampling and the early stop should be recorded, avoiding the attribution of the benefit of one parameter to another.

(a) Strict single-line conversion of consecutive values, maintaining theoretically the candidate order; The use of heterogeneity drums, float accuracy and missing processing can lead to differences in actual achievement. Trees also lack natural exterior extrapolation capacity: input over training maximums and often fall into already marginal leaves. For new customers, over-cycles or large groups of people, it cannot be assumed that the in-training indicators will automatically continue. By time and by key customer segment Verify and check the sample cover and export boundary.

Self-measure and answer

Why is the constant baseline 2.5?

Under a square loss, constant guidance is projected to equal the average label value. The sum of the four labels in this case is 10.

Why do you predict 4 instead of 3 or 5 in the right leaf of the threshold of 2.5?

The two labels for the right leaf have an average value of 4, which minimizes the leaf square error; This does not apply to all losses.

What is the training sum of squares after η=0.5?

The projections are 1.75, 1.75, 3.25 and 3.25, and the four square differences are added to the 4.25.

Can a categorised tree be simply described as a raw residue?

The definition of the current loss and the negative gradient should be clarified; The intuition of the square loss is not a substitute for the classification of loss.

Why do leaf weights shrink to ±1 when λ=1?

Absolute leaf gradient sum is 3 and H=2. Applying −G/(H+λ) gives ±1.

Is it possible to lower the tree depths to avoid leaks when a future repayment field appears in the leaves?

Can't. Leaks are derived from time error in the use of characteristics and can be used directly by shallow trees; Data generation protocols must be amended.

Next Sort and Calibrate Check if tree model output can be used for probabilistic calculations and read again Retrieval and feedback Understand how the sample was selected to enter the log.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. XGBoost — Introduction to Boosted Trees
  2. scikit-learn Decision Trees
  3. scikit-learn Ensembles — gradient boosting and random forests

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.