pub struct Perceptron { /* private fields */ }Expand description
Binary Perceptron classifier (Rosenblatt 1958).
Labels must be in {−1, +1}. The update rule fires only when a prediction
is wrong: w ← w + η·y·x and bias ← bias + η·y.
Implementations§
Source§impl Perceptron
impl Perceptron
Sourcepub fn new(n_features: usize) -> Self
pub fn new(n_features: usize) -> Self
Create a new Perceptron with n_features dimensions and default η = 1.0.
Sourcepub fn with_learning_rate(self, lr: f64) -> Self
pub fn with_learning_rate(self, lr: f64) -> Self
Set the per-mistake learning rate (η).
Sourcepub fn stats(&self) -> &OnlineStats
pub fn stats(&self) -> &OnlineStats
Reference to running statistics.
Trait Implementations§
Source§impl Clone for Perceptron
impl Clone for Perceptron
Source§fn clone(&self) -> Perceptron
fn clone(&self) -> Perceptron
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Perceptron
impl Debug for Perceptron
Source§impl OnlineLearner for Perceptron
impl OnlineLearner for Perceptron
Source§fn update(
&mut self,
features: &[f64],
label: f64,
) -> Result<OnlineUpdateResult, OnlineError>
fn update( &mut self, features: &[f64], label: f64, ) -> Result<OnlineUpdateResult, OnlineError>
Update model on a single (features, label) pair. Returns update stats.
Auto Trait Implementations§
impl Freeze for Perceptron
impl RefUnwindSafe for Perceptron
impl Send for Perceptron
impl Sync for Perceptron
impl Unpin for Perceptron
impl UnsafeUnpin for Perceptron
impl UnwindSafe for Perceptron
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