pub enum StackingStrategy {
Ridge {
alpha: f32,
rank_transform: bool,
fit_intercept: bool,
min_weight: f32,
},
Average,
}Expand description
Stacking strategy for ensemble combination
Specifies how to combine predictions from multiple ensemble members.
This is a serializable alternative to the Box<dyn Stacker> trait object,
enabling full persistence of ensemble configurations. UniversalModel stores
this enum and constructs the appropriate stacker at runtime.
§Variants
-
Ridge: Uses Ridge regression to learn optimal weights for each ensemble member. Recommended when ensemble members have different prediction scales or accuracies.
-
Average: Simple equal-weight averaging across all members. Recommended for homogeneous ensembles where all members have similar quality.
§Note on Extensibility
Only Ridge and Average strategies are currently exposed because they are the most commonly used and both are fully serializable. If you need custom stacking logic, train multiple independent models and combine them manually, or use the TrainedMember API directly with EnsembleBuilder.
Variants§
Ridge
Ridge regression stacking with regularization
Learns optimal weights via Ridge regression on out-of-fold predictions. Ridge regularization prevents overfitting when stacking.
Fields
alpha: f32Ridge regularization parameter (alpha). Higher values = stronger regularization. Typical range: 0.001 to 0.1. Default: 0.01
rank_transform: boolWhether to apply rank transformation to member predictions before stacking. Useful when members have different prediction scales (e.g., one predicts [0, 100], another [0, 1]). Rank transformation makes them comparable. Default: false
Average
Simple averaging (equal weights)
Combines members by simple arithmetic mean: (pred_1 + pred_2 + ... + pred_n) / n
No learning required. Fast and effective for balanced, diverse ensembles.
Trait Implementations§
Source§impl Archive for StackingStrategy
impl Archive for StackingStrategy
Source§type Resolver = StackingStrategyResolver
type Resolver = StackingStrategyResolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl Clone for StackingStrategy
impl Clone for StackingStrategy
Source§fn clone(&self) -> StackingStrategy
fn clone(&self) -> StackingStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StackingStrategy
impl Debug for StackingStrategy
Source§impl Default for StackingStrategy
impl Default for StackingStrategy
Source§impl<'de> Deserialize<'de> for StackingStrategy
impl<'de> Deserialize<'de> for StackingStrategy
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<__D: Fallible + ?Sized> Deserialize<StackingStrategy, __D> for Archived<StackingStrategy>
impl<__D: Fallible + ?Sized> Deserialize<StackingStrategy, __D> for Archived<StackingStrategy>
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<StackingStrategy, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<StackingStrategy, <__D as Fallible>::Error>
Auto Trait Implementations§
impl Freeze for StackingStrategy
impl RefUnwindSafe for StackingStrategy
impl Send for StackingStrategy
impl Sync for StackingStrategy
impl Unpin for StackingStrategy
impl UnwindSafe for StackingStrategy
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.