pub struct GradientBoostingRegressor<F> {
pub n_estimators: usize,
pub learning_rate: f64,
pub max_depth: Option<usize>,
pub min_samples_split: usize,
pub min_samples_leaf: usize,
pub subsample: f64,
pub loss: RegressionLoss,
pub huber_alpha: f64,
pub random_state: Option<u64>,
/* private fields */
}Expand description
Gradient boosting regressor.
Builds an additive model in a forward stage-wise fashion, fitting each regression tree to the negative gradient of the loss function evaluated on the current ensemble prediction.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§n_estimators: usizeNumber of boosting stages (trees).
learning_rate: f64Learning rate (shrinkage) applied to each tree’s contribution.
max_depth: Option<usize>Maximum depth of each tree.
min_samples_split: usizeMinimum number of samples required to split an internal node.
min_samples_leaf: usizeMinimum number of samples required in a leaf node.
subsample: f64Fraction of samples to use for fitting each tree (stochastic boosting).
loss: RegressionLossLoss function.
huber_alpha: f64Alpha quantile for Huber loss (only used when loss == Huber).
random_state: Option<u64>Random seed for reproducibility.
Implementations§
Source§impl<F: Float> GradientBoostingRegressor<F>
impl<F: Float> GradientBoostingRegressor<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new GradientBoostingRegressor with default settings.
Defaults: n_estimators = 100, learning_rate = 0.1,
max_depth = Some(3), min_samples_split = 2,
min_samples_leaf = 1, subsample = 1.0,
loss = LeastSquares, huber_alpha = 0.9.
Sourcepub fn with_n_estimators(self, n: usize) -> Self
pub fn with_n_estimators(self, n: usize) -> Self
Set the number of boosting stages.
Sourcepub fn with_learning_rate(self, lr: f64) -> Self
pub fn with_learning_rate(self, lr: f64) -> Self
Set the learning rate (shrinkage).
Sourcepub fn with_max_depth(self, d: Option<usize>) -> Self
pub fn with_max_depth(self, d: Option<usize>) -> Self
Set the maximum tree depth.
Sourcepub fn with_min_samples_split(self, n: usize) -> Self
pub fn with_min_samples_split(self, n: usize) -> Self
Set the minimum number of samples to split a node.
Sourcepub fn with_min_samples_leaf(self, n: usize) -> Self
pub fn with_min_samples_leaf(self, n: usize) -> Self
Set the minimum number of samples in a leaf.
Sourcepub fn with_subsample(self, ratio: f64) -> Self
pub fn with_subsample(self, ratio: f64) -> Self
Set the subsample ratio (fraction of training data per tree).
Sourcepub fn with_loss(self, loss: RegressionLoss) -> Self
pub fn with_loss(self, loss: RegressionLoss) -> Self
Set the loss function.
Sourcepub fn with_huber_alpha(self, alpha: f64) -> Self
pub fn with_huber_alpha(self, alpha: f64) -> Self
Set the alpha quantile for Huber loss.
Sourcepub fn with_random_state(self, seed: u64) -> Self
pub fn with_random_state(self, seed: u64) -> Self
Set the random seed for reproducibility.
Trait Implementations§
Source§impl<F: Clone> Clone for GradientBoostingRegressor<F>
impl<F: Clone> Clone for GradientBoostingRegressor<F>
Source§fn clone(&self) -> GradientBoostingRegressor<F>
fn clone(&self) -> GradientBoostingRegressor<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for GradientBoostingRegressor<F>
impl<F: Debug> Debug for GradientBoostingRegressor<F>
Source§impl<F: Float> Default for GradientBoostingRegressor<F>
impl<F: Float> Default for GradientBoostingRegressor<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for GradientBoostingRegressor<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for GradientBoostingRegressor<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedGradientBoostingRegressor<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedGradientBoostingRegressor<F>, FerroError>
Fit the gradient boosting regressor.
§Errors
Returns FerroError::ShapeMismatch if x and y have different
numbers of samples.
Returns FerroError::InsufficientSamples if there are no samples.
Returns FerroError::InvalidParameter for invalid hyperparameters.
Source§type Fitted = FittedGradientBoostingRegressor<F>
type Fitted = FittedGradientBoostingRegressor<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F: Float + Send + Sync + 'static> PipelineEstimator<F> for GradientBoostingRegressor<F>
impl<F: Float + Send + Sync + 'static> PipelineEstimator<F> for GradientBoostingRegressor<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for GradientBoostingRegressor<F>
impl<F> RefUnwindSafe for GradientBoostingRegressor<F>where
F: RefUnwindSafe,
impl<F> Send for GradientBoostingRegressor<F>where
F: Send,
impl<F> Sync for GradientBoostingRegressor<F>where
F: Sync,
impl<F> Unpin for GradientBoostingRegressor<F>where
F: Unpin,
impl<F> UnsafeUnpin for GradientBoostingRegressor<F>
impl<F> UnwindSafe for GradientBoostingRegressor<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more