#[non_exhaustive]pub struct VotingClassifier { /* private fields */ }Expand description
Combines multiple classifiers via voting.
In Voting::Hard mode, each estimator votes for a class and the majority
wins. In Voting::Soft mode, predicted probabilities are averaged and
the class with the highest average probability is selected.
§Examples
ⓘ
use scry_learn::ensemble::{VotingClassifier, Voting};
use scry_learn::tree::DecisionTreeClassifier;
let vc = VotingClassifier::new(vec![
Box::new(DecisionTreeClassifier::new().max_depth(3)),
Box::new(DecisionTreeClassifier::new().max_depth(5)),
Box::new(DecisionTreeClassifier::new().max_depth(7)),
]).voting(Voting::Hard);Implementations§
Source§impl VotingClassifier
impl VotingClassifier
Sourcepub fn new(estimators: Vec<Box<dyn EnsembleClassifier>>) -> Self
pub fn new(estimators: Vec<Box<dyn EnsembleClassifier>>) -> Self
Create a new voting classifier with the given base estimators.
Sourcepub fn voting(self, v: Voting) -> Self
pub fn voting(self, v: Voting) -> Self
Set the voting strategy (default: Voting::Hard).
Sourcepub fn weights(self, w: Vec<f64>) -> Self
pub fn weights(self, w: Vec<f64>) -> Self
Set weights for each estimator (default: equal weights).
Trait Implementations§
Source§impl Clone for VotingClassifier
impl Clone for VotingClassifier
Source§fn clone(&self) -> VotingClassifier
fn clone(&self) -> VotingClassifier
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for VotingClassifier
impl !RefUnwindSafe for VotingClassifier
impl Send for VotingClassifier
impl Sync for VotingClassifier
impl Unpin for VotingClassifier
impl UnsafeUnpin for VotingClassifier
impl !UnwindSafe for VotingClassifier
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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