Struct linfa_linear::TweedieRegressor [−][src]
Generalized Linear Model (GLM) with a Tweedie distribution
The Regressor can be used to model different GLMs depending on
power,
which determines the underlying distribution.
| Power | Distribution |
|---|---|
| 0 | Normal |
| 1 | Poisson |
| (1, 2) | Compound Poisson Gamma |
| 2 | Gamma |
| 3 | Inverse Gaussian |
NOTE: No distribution exists between 0 and 1
Learn more from sklearn’s excellent User Guide
Examples
Here’s an example on how to train a GLM on the diabetes dataset
use linfa::traits::{Fit, Predict}; use linfa_linear::TweedieRegressor; use linfa::prelude::SingleTargetRegression; let dataset = linfa_datasets::diabetes(); let model = TweedieRegressor::default().fit(&dataset).unwrap(); let pred = model.predict(&dataset); let r2 = pred.r2(&dataset).unwrap(); println!("r2 from prediction: {}", r2);
Implementations
impl TweedieRegressor[src]
pub fn new() -> Self[src]
pub fn alpha(self, alpha: f64) -> Self[src]
Constant that multiplies with the penalty term and thus determines the
regularization strenght. alpha set to 0 is equivalent to unpenalized GLM.
pub fn fit_intercept(self, fit_intercept: bool) -> Self[src]
Specifies whether a bias or intercept should be added to the model
pub fn power(self, power: f64) -> Self[src]
The power determines the underlying target distribution
pub fn link(self, link: Link) -> Self[src]
The link function of the GLM, for mapping from linear predictor x @ coeff + intercept to
the prediction. If no value is set, the link will be selected based on the following,
pub fn max_iter(self, max_iter: usize) -> Self[src]
Maximum number of iterations for the LBFGS solver
pub fn tol(self, tol: f64) -> Self[src]
Stopping criterion for the LBFGS solver
Trait Implementations
impl Default for TweedieRegressor[src]
impl<'de> Deserialize<'de> for TweedieRegressor[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl<A: Float, D: Data<Elem = A>, T: AsTargets<Elem = A>> Fit<'_, ArrayBase<D, Dim<[usize; 2]>>, T> for TweedieRegressor[src]
type Object = Result<FittedTweedieRegressor<A>>
fn fit(
&self,
ds: &DatasetBase<ArrayBase<D, Ix2>, T>
) -> Result<FittedTweedieRegressor<A>>[src]
&self,
ds: &DatasetBase<ArrayBase<D, Ix2>, T>
) -> Result<FittedTweedieRegressor<A>>
impl Serialize for TweedieRegressor[src]
Auto Trait Implementations
impl RefUnwindSafe for TweedieRegressor
impl Send for TweedieRegressor
impl Sync for TweedieRegressor
impl Unpin for TweedieRegressor
impl UnwindSafe for TweedieRegressor
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
T: Send + Sync + UnwindSafe + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,