How does gradient boosting calculate probability estimates?

I have been trying to understand gradient boosting reading various blogs, websites and trying to find my answer by looking through for example the XGBoost source code. However, I cannot seem to find an understandable explanation of how gradient boosting algorithms produce probability estimates. So, how do they calculate the probabilities?

XGBoost for classification is a model that combines the principles of decision trees and logistic regression.

The logistic regression function computes probabilities that are linear on the logit scale:

$$z = Xw \\ \mathbb{P}(y=1|X) = \frac{1}{1 + \exp(-z)}$$

Unlike logistic regression, the "features" in $$X$$ are constructed as the terminal nodes of an ensemble of decision trees -- so each row of $$X$$ collects the terminal leafs for each sample; the row is a $$T$$-hot binary vector, for $$T$$ the number of trees. (Each XGBoost tree is generated according to a particular algorithm, but that's not relevant here.)

There are $$n$$ columns in $$X$$, one column for each terminal node. There is no expression for the total number of terminal nodes, because the number of nodes can vary between trees (and usually does, in my experience).

Each leaf in the tree has an associated "weight." That weight is recorded in $$w$$. To be conformable with $$X$$, there are $$n$$ elements in $$w$$.

Or, alternatively stated, the log-odds for a sample is the sum of the weights of its terminal leafs. The probability of the sample belonging to class 1 is the inverse-logit transformation of the sum.

• This is very helpful, thanks. How many elements would the beta-vector contain? Would it be equal to the number of total leaf nodes across all trees? (And there would be equal number of columns in the X matrix, correct?) – Vishal Jun 6 '18 at 20:00
• Thank you for the updated answer. Does this mean that there's a unique X matrix as well as a unique set of betas for each sample/observation (i)? In other words, for every sample/observation for which you want to calculate the probability of belonging to class 1, you'd need to determine the unique values of the X matrix and beta vector? – Vishal Jul 3 '18 at 15:50
• Each row of $X$ stores the terminal leafs for a sample. – Sycorax Jul 3 '18 at 15:54