boosters.Objective#
- class boosters.Objective#
Bases:
objectObjective (loss) functions for gradient boosting.
Each variant represents a different loss function for training GBDT and GBLinear models. Use the static constructor methods for validation.
- Regression:
Objective.Squared(): Mean squared error (L2)
Objective.Absolute(): Mean absolute error (L1)
Objective.Huber(delta): Pseudo-Huber loss (robust)
Objective.Pinball(alpha): Quantile regression
Objective.Poisson(): Poisson deviance for count data
- Classification:
Objective.Logistic(): Binary cross-entropy
Objective.Hinge(): SVM-style hinge loss
Objective.Softmax(n_classes): Multiclass cross-entropy
Note: ranking objectives are not implemented in core yet.
Examples
>>> from boosters import Objective >>> obj = Objective.squared() # L2 regression >>> obj = Objective.logistic() # Binary classification >>> obj = Objective.pinball([0.1, 0.5, 0.9]) # Quantile regression >>> obj = Objective.softmax(10) # Multiclass classification
Pattern matching: >>> match obj: … case Objective.Squared(): … print(“L2 loss”) … case Objective.Pinball(alpha=a): … print(f”Quantile: {a}”)
- Absolute#
alias of
PyObjective_Absolute
- Hinge#
alias of
PyObjective_Hinge
- Huber#
alias of
PyObjective_Huber
- Logistic#
alias of
PyObjective_Logistic
- Pinball#
alias of
PyObjective_Pinball
- Poisson#
alias of
PyObjective_Poisson
- Softmax#
alias of
PyObjective_Softmax
- Squared#
alias of
PyObjective_Squared
- static absolute()#
Create absolute error loss (L1).
- static hinge()#
Create hinge loss for binary classification.
- static huber(delta=1.0)#
Create Huber loss with validation.
- static logistic()#
Create logistic loss for binary classification.
- static pinball(alpha)#
Create pinball loss with validation.
- static poisson()#
Create Poisson loss.
- static softmax(n_classes)#
Create softmax loss with validation.
- static squared()#
Create squared error loss (L2).