pub struct GradientBoostingClassifier<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: ClassificationLoss,
pub random_state: Option<u64>,
/* private fields */
}Expand description
Gradient boosting classifier.
For binary classification a single model is trained on log-odds residuals. For multiclass (K classes), K regression trees are built per boosting round (one-vs-rest in probability space via softmax).
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§n_estimators: usizeNumber of boosting stages.
learning_rate: f64Learning rate (shrinkage).
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.
loss: ClassificationLossClassification loss function.
random_state: Option<u64>Random seed for reproducibility.
Implementations§
Source§impl<F: Float> GradientBoostingClassifier<F>
impl<F: Float> GradientBoostingClassifier<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new GradientBoostingClassifier 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 = LogLoss.
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.
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 GradientBoostingClassifier<F>
impl<F: Clone> Clone for GradientBoostingClassifier<F>
Source§fn clone(&self) -> GradientBoostingClassifier<F>
fn clone(&self) -> GradientBoostingClassifier<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 GradientBoostingClassifier<F>
impl<F: Debug> Debug for GradientBoostingClassifier<F>
Source§impl<F: Float> Default for GradientBoostingClassifier<F>
impl<F: Float> Default for GradientBoostingClassifier<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for GradientBoostingClassifier<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for GradientBoostingClassifier<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<usize>,
) -> Result<FittedGradientBoostingClassifier<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<usize>, ) -> Result<FittedGradientBoostingClassifier<F>, FerroError>
Fit the gradient boosting classifier.
§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 = FittedGradientBoostingClassifier<F>
type Fitted = FittedGradientBoostingClassifier<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F: Float + ToPrimitive + FromPrimitive + Send + Sync + 'static> PipelineEstimator<F> for GradientBoostingClassifier<F>
impl<F: Float + ToPrimitive + FromPrimitive + Send + Sync + 'static> PipelineEstimator<F> for GradientBoostingClassifier<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 GradientBoostingClassifier<F>
impl<F> RefUnwindSafe for GradientBoostingClassifier<F>where
F: RefUnwindSafe,
impl<F> Send for GradientBoostingClassifier<F>where
F: Send,
impl<F> Sync for GradientBoostingClassifier<F>where
F: Sync,
impl<F> Unpin for GradientBoostingClassifier<F>where
F: Unpin,
impl<F> UnsafeUnpin for GradientBoostingClassifier<F>
impl<F> UnwindSafe for GradientBoostingClassifier<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