Struct linfa_linear::TweedieRegressor[][src]

pub struct TweedieRegressor { /* fields omitted */ }

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.

PowerDistribution
0Normal
1Poisson
(1, 2)Compound Poisson Gamma
2Gamma
3Inverse 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

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,

  • identity for Normal distribution (power = 0)
  • log for Poisson, Gamma and Inverse Gaussian distributions (power >= 1)

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]

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

impl Serialize for TweedieRegressor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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