pub struct LinearRegression { /* private fields */ }Expand description
Online linear regression model.
§Examples
use rill_ml::{
models::{LinearRegression, LinearRegressionConfig},
optim::{Optimizer, SgdConfig},
loss::RegressionLoss,
OnlineRegressor,
};
let feature_count = 2;
let mut model = LinearRegression::new(
feature_count,
LinearRegressionConfig {
optimizer: Optimizer::sgd(feature_count, SgdConfig {
learning_rate: 0.1,
l2: 0.0,
}).unwrap(),
loss: RegressionLoss::default(),
},
).unwrap();
let prediction = model.predict(&[1.0, 2.0]).unwrap();
model.learn(&[1.0, 2.0], 3.0).unwrap();Implementations§
Source§impl LinearRegression
impl LinearRegression
Trait Implementations§
Source§impl Clone for LinearRegression
impl Clone for LinearRegression
Source§fn clone(&self) -> LinearRegression
fn clone(&self) -> LinearRegression
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 moreSource§impl Debug for LinearRegression
impl Debug for LinearRegression
Source§impl OnlineRegressor for LinearRegression
impl OnlineRegressor for LinearRegression
Source§fn feature_count(&self) -> usize
fn feature_count(&self) -> usize
The number of features the model expects.
Source§fn samples_seen(&self) -> u64
fn samples_seen(&self) -> u64
How many training samples the model has seen so far.
Source§fn predict(&self, features: &[f64]) -> Result<f64, RillError>
fn predict(&self, features: &[f64]) -> Result<f64, RillError>
Predict the target for the given feature slice. Read more
Auto Trait Implementations§
impl Freeze for LinearRegression
impl RefUnwindSafe for LinearRegression
impl Send for LinearRegression
impl Sync for LinearRegression
impl Unpin for LinearRegression
impl UnsafeUnpin for LinearRegression
impl UnwindSafe for LinearRegression
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