pub struct VotingClassifier<State = Untrained> { /* private fields */ }Expand description
Voting Classifier with type-safe state management
A voting classifier is an ensemble meta-algorithm that fits several base classifiers, each on the whole dataset. It then aggregates the individual predictions to form a final prediction.
§Examples
use sklears_ensemble::voting::{VotingClassifier, VotingStrategy};
use sklears_ensemble::voting::config::VotingClassifierConfig;
// Create voting classifier with configuration
let config = VotingClassifierConfig {
voting: VotingStrategy::Soft,
weights: Some(vec![1.0, 2.0, 1.5]),
confidence_weighting: true,
confidence_threshold: 0.8,
..Default::default()
};
let classifier = VotingClassifier::new(config);
assert_eq!(classifier.estimators().len(), 0);Implementations§
Source§impl VotingClassifier<Untrained>
impl VotingClassifier<Untrained>
Sourcepub fn new(config: VotingClassifierConfig) -> Self
pub fn new(config: VotingClassifierConfig) -> Self
Create a new untrained voting classifier
Sourcepub fn builder() -> VotingClassifierBuilder
pub fn builder() -> VotingClassifierBuilder
Create a builder for configuring the voting classifier
Sourcepub fn add_estimator(
&mut self,
estimator: Box<dyn EnsembleMember + Send + Sync>,
)
pub fn add_estimator( &mut self, estimator: Box<dyn EnsembleMember + Send + Sync>, )
Add an estimator to the ensemble
Sourcepub fn config(&self) -> &VotingClassifierConfig
pub fn config(&self) -> &VotingClassifierConfig
Get the current configuration
Sourcepub fn estimators(&self) -> &[Box<dyn EnsembleMember + Send + Sync>]
pub fn estimators(&self) -> &[Box<dyn EnsembleMember + Send + Sync>]
Get the estimators in the ensemble
Sourcepub fn optimize_ensemble_size(
&self,
x: &Array2<Float>,
y: &Array1<Float>,
) -> Result<EnsembleSizeRecommendations>
pub fn optimize_ensemble_size( &self, x: &Array2<Float>, y: &Array1<Float>, ) -> Result<EnsembleSizeRecommendations>
Optimize ensemble size based on training data
Sourcepub fn analyze_ensemble_size(
&self,
x: &Array2<Float>,
y: &Array1<Float>,
) -> Result<EnsembleSizeAnalysis>
pub fn analyze_ensemble_size( &self, x: &Array2<Float>, y: &Array1<Float>, ) -> Result<EnsembleSizeAnalysis>
Analyze ensemble size performance characteristics
Source§impl VotingClassifier<Trained>
impl VotingClassifier<Trained>
Sourcepub fn n_features_in(&self) -> usize
pub fn n_features_in(&self) -> usize
Get the number of features seen during training
Sourcepub fn estimators(&self) -> &[Box<dyn EnsembleMember + Send + Sync>]
pub fn estimators(&self) -> &[Box<dyn EnsembleMember + Send + Sync>]
Get the estimators in the ensemble
Sourcepub fn predict_with_confidence(
&self,
x: &Array2<Float>,
) -> Result<(Array1<Float>, Array1<Float>)>
pub fn predict_with_confidence( &self, x: &Array2<Float>, ) -> Result<(Array1<Float>, Array1<Float>)>
Make predictions with confidence scores
Sourcepub fn predict_with_confidence_weighting(
&self,
x: &Array2<Float>,
) -> Result<Array1<Float>>
pub fn predict_with_confidence_weighting( &self, x: &Array2<Float>, ) -> Result<Array1<Float>>
Make predictions with confidence weighting
Sourcepub fn estimator_confidence_scores(
&self,
x: &Array2<Float>,
) -> Result<Array1<Float>>
pub fn estimator_confidence_scores( &self, x: &Array2<Float>, ) -> Result<Array1<Float>>
Get confidence scores for individual estimators
Sourcepub fn predict_proba(&self, x: &Array2<Float>) -> Result<Array2<Float>>
pub fn predict_proba(&self, x: &Array2<Float>) -> Result<Array2<Float>>
Make probability predictions (if supported by estimators)
Sourcepub fn update_weights_dynamically(
&mut self,
recent_performances: &[Float],
) -> Result<()>
pub fn update_weights_dynamically( &mut self, recent_performances: &[Float], ) -> Result<()>
Update ensemble weights dynamically based on performance
Sourcepub fn get_ensemble_size_recommendations(&self) -> EnsembleSizeRecommendations
pub fn get_ensemble_size_recommendations(&self) -> EnsembleSizeRecommendations
Get ensemble size recommendations
Trait Implementations§
Source§impl Debug for VotingClassifier<Untrained>
impl Debug for VotingClassifier<Untrained>
Source§impl Debug for VotingClassifier<Trained>
impl Debug for VotingClassifier<Trained>
Source§impl Default for VotingClassifier<Untrained>
impl Default for VotingClassifier<Untrained>
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for VotingClassifier<Untrained>
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for VotingClassifier<Untrained>
Source§type Fitted = VotingClassifier<Trained>
type Fitted = VotingClassifier<Trained>
Source§fn fit(self, x: &Array2<Float>, y: &Array1<Float>) -> Result<Self::Fitted>
fn fit(self, x: &Array2<Float>, y: &Array1<Float>) -> Result<Self::Fitted>
Source§fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
Source§impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for VotingClassifier<Trained>
impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for VotingClassifier<Trained>
Source§fn predict(&self, x: &Array2<Float>) -> Result<Array1<Float>>
fn predict(&self, x: &Array2<Float>) -> Result<Array1<Float>>
Source§fn predict_with_uncertainty(
&self,
x: &X,
) -> Result<(Output, UncertaintyMeasure), SklearsError>
fn predict_with_uncertainty( &self, x: &X, ) -> Result<(Output, UncertaintyMeasure), SklearsError>
Auto Trait Implementations§
impl<State> Freeze for VotingClassifier<State>
impl<State = Untrained> !RefUnwindSafe for VotingClassifier<State>
impl<State> Send for VotingClassifier<State>where
State: Send,
impl<State> Sync for VotingClassifier<State>where
State: Sync,
impl<State> Unpin for VotingClassifier<State>where
State: Unpin,
impl<State = Untrained> !UnwindSafe for VotingClassifier<State>
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> 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