Expand description
Gradient boosting classifiers and regressors.
This module provides GradientBoostingClassifier and GradientBoostingRegressor,
which build ensembles of decision trees sequentially. Each tree fits the negative
gradient (pseudo-residuals) of the loss function, progressively reducing prediction error.
§Regression Losses
LeastSquares(L2): mean squared error; pseudo-residuals arey - F(x).Lad(L1): least absolute deviation; pseudo-residuals aresign(y - F(x)).Huber: a blend of L2 (for small residuals) and L1 (for large residuals), controlled by thealphaquantile parameter (default 0.9).
§Classification Loss
LogLoss: binary and multiclass logistic loss. For binary classification a single model is trained on log-odds; for K-class problems K trees are built per boosting round (one-vs-rest in probability space via softmax).
§Examples
use ferrolearn_tree::GradientBoostingRegressor;
use ferrolearn_core::{Fit, Predict};
use ndarray::{array, Array1, Array2};
let x = Array2::from_shape_vec((8, 1), vec![
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
]).unwrap();
let y = array![1.0, 1.0, 1.0, 1.0, 5.0, 5.0, 5.0, 5.0];
let model = GradientBoostingRegressor::<f64>::new()
.with_n_estimators(50)
.with_learning_rate(0.1)
.with_random_state(42);
let fitted = model.fit(&x, &y).unwrap();
let preds = fitted.predict(&x).unwrap();
assert_eq!(preds.len(), 8);Structs§
- Fitted
Gradient Boosting Classifier - A fitted gradient boosting classifier.
- Fitted
Gradient Boosting Regressor - A fitted gradient boosting regressor.
- Gradient
Boosting Classifier - Gradient boosting classifier.
- Gradient
Boosting Regressor - Gradient boosting regressor.
Enums§
- Classification
Loss - Loss function for gradient boosting classification.
- Regression
Loss - Loss function for gradient boosting regression.