pub struct HistGradientBoostingRegressor<F> {
pub n_estimators: usize,
pub learning_rate: f64,
pub max_depth: Option<usize>,
pub min_samples_leaf: usize,
pub max_bins: u16,
pub l2_regularization: f64,
pub max_leaf_nodes: Option<usize>,
pub loss: HistRegressionLoss,
pub random_state: Option<u64>,
/* private fields */
}Expand description
Histogram-based gradient boosting regressor.
Uses quantile-based feature binning and gradient/hessian histograms for
O(n_bins) split finding per node. This is significantly faster than the
standard GradientBoostingRegressor
for larger datasets.
§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_leaf: usizeMinimum number of samples required in a leaf node.
max_bins: u16Maximum number of bins for feature discretisation (at most 256).
l2_regularization: f64L2 regularization term on weights.
max_leaf_nodes: Option<usize>Maximum number of leaf nodes per tree (best-first growth).
If None, depth-first growth is used with max_depth.
loss: HistRegressionLossLoss function.
random_state: Option<u64>Random seed for reproducibility.
Implementations§
Source§impl<F: Float> HistGradientBoostingRegressor<F>
impl<F: Float> HistGradientBoostingRegressor<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new HistGradientBoostingRegressor with default settings.
Defaults: n_estimators = 100, learning_rate = 0.1,
max_depth = None, min_samples_leaf = 20,
max_bins = 255, l2_regularization = 0.0,
max_leaf_nodes = Some(31), loss = LeastSquares.
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_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_max_bins(self, bins: u16) -> Self
pub fn with_max_bins(self, bins: u16) -> Self
Set the maximum number of bins for feature discretisation.
Sourcepub fn with_l2_regularization(self, reg: f64) -> Self
pub fn with_l2_regularization(self, reg: f64) -> Self
Set the L2 regularization term.
Sourcepub fn with_max_leaf_nodes(self, n: Option<usize>) -> Self
pub fn with_max_leaf_nodes(self, n: Option<usize>) -> Self
Set the maximum number of leaf nodes (best-first growth).
Sourcepub fn with_loss(self, loss: HistRegressionLoss) -> Self
pub fn with_loss(self, loss: HistRegressionLoss) -> Self
Set the loss function.
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 HistGradientBoostingRegressor<F>
impl<F: Clone> Clone for HistGradientBoostingRegressor<F>
Source§fn clone(&self) -> HistGradientBoostingRegressor<F>
fn clone(&self) -> HistGradientBoostingRegressor<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 HistGradientBoostingRegressor<F>
impl<F: Debug> Debug for HistGradientBoostingRegressor<F>
Source§impl<F: Float> Default for HistGradientBoostingRegressor<F>
impl<F: Float> Default for HistGradientBoostingRegressor<F>
Source§impl<'de, F> Deserialize<'de> for HistGradientBoostingRegressor<F>
impl<'de, F> Deserialize<'de> for HistGradientBoostingRegressor<F>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for HistGradientBoostingRegressor<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for HistGradientBoostingRegressor<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedHistGradientBoostingRegressor<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedHistGradientBoostingRegressor<F>, FerroError>
Fit the histogram-based 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 = FittedHistGradientBoostingRegressor<F>
type Fitted = FittedHistGradientBoostingRegressor<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F: Float + Send + Sync + 'static> PipelineEstimator<F> for HistGradientBoostingRegressor<F>
impl<F: Float + Send + Sync + 'static> PipelineEstimator<F> for HistGradientBoostingRegressor<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 HistGradientBoostingRegressor<F>
impl<F> RefUnwindSafe for HistGradientBoostingRegressor<F>where
F: RefUnwindSafe,
impl<F> Send for HistGradientBoostingRegressor<F>where
F: Send,
impl<F> Sync for HistGradientBoostingRegressor<F>where
F: Sync,
impl<F> Unpin for HistGradientBoostingRegressor<F>where
F: Unpin,
impl<F> UnsafeUnpin for HistGradientBoostingRegressor<F>
impl<F> UnwindSafe for HistGradientBoostingRegressor<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