VotingClassifier

Struct VotingClassifier 

Source
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>

Source

pub fn new(config: VotingClassifierConfig) -> Self

Create a new untrained voting classifier

Source

pub fn builder() -> VotingClassifierBuilder

Create a builder for configuring the voting classifier

Source

pub fn add_estimator( &mut self, estimator: Box<dyn EnsembleMember + Send + Sync>, )

Add an estimator to the ensemble

Source

pub fn config(&self) -> &VotingClassifierConfig

Get the current configuration

Source

pub fn estimators(&self) -> &[Box<dyn EnsembleMember + Send + Sync>]

Get the estimators in the ensemble

Source

pub fn optimize_ensemble_size( &self, x: &Array2<Float>, y: &Array1<Float>, ) -> Result<EnsembleSizeRecommendations>

Optimize ensemble size based on training data

Source

pub fn analyze_ensemble_size( &self, x: &Array2<Float>, y: &Array1<Float>, ) -> Result<EnsembleSizeAnalysis>

Analyze ensemble size performance characteristics

Source§

impl VotingClassifier<Trained>

Source

pub fn classes(&self) -> &Array1<Float>

Get the classes discovered during training

Source

pub fn n_features_in(&self) -> usize

Get the number of features seen during training

Source

pub fn estimators(&self) -> &[Box<dyn EnsembleMember + Send + Sync>]

Get the estimators in the ensemble

Source

pub fn predict_with_confidence( &self, x: &Array2<Float>, ) -> Result<(Array1<Float>, Array1<Float>)>

Make predictions with confidence scores

Source

pub fn predict_with_confidence_weighting( &self, x: &Array2<Float>, ) -> Result<Array1<Float>>

Make predictions with confidence weighting

Source

pub fn estimator_confidence_scores( &self, x: &Array2<Float>, ) -> Result<Array1<Float>>

Get confidence scores for individual estimators

Source

pub fn predict_proba(&self, x: &Array2<Float>) -> Result<Array2<Float>>

Make probability predictions (if supported by estimators)

Source

pub fn update_weights_dynamically( &mut self, recent_performances: &[Float], ) -> Result<()>

Update ensemble weights dynamically based on performance

Source

pub fn get_ensemble_size_recommendations(&self) -> EnsembleSizeRecommendations

Get ensemble size recommendations

Trait Implementations§

Source§

impl Debug for VotingClassifier<Untrained>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for VotingClassifier<Trained>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VotingClassifier<Untrained>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for VotingClassifier<Untrained>

Source§

type Fitted = VotingClassifier<Trained>

The fitted model type
Source§

fn fit(self, x: &Array2<Float>, y: &Array1<Float>) -> Result<Self::Fitted>

Fit the model to the provided data with validation
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,

Fit with custom validation and early stopping
Source§

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>>

Make predictions on the provided data
Source§

fn predict_with_uncertainty( &self, x: &X, ) -> Result<(Output, UncertaintyMeasure), SklearsError>

Make predictions with confidence intervals

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V