Skip to content
forked from vspaz/wls-rs

WLS, weighted linear regression in pure Rust with a single 3rd party dependency.

Notifications You must be signed in to change notification settings

fred314159265/wls-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wls-rust

Weighted linear regression in pure Rust with only a single any 3rd party dependency (num-traits).

Forked to expose as a library crate & enable generic float support - the hard work was done by vspaz here: https://github.com/vspaz/wls-rs

How-to

Use in your project by adding this line to your Cargo.toml:

wls = {git = "https://github.com/fred314159265/wls-rs.git"}
use wls::models::wls::Wls;

fn main() {
    let x_points = vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0];
    let y_points = vec![1.0, 3.0, 4.0, 5.0, 2.0, 3.0, 4.0];
    let weights = vec![10.0, 1.0, 3.0, 8.0, 14.0, 21.0, 13.0];

    let wls = Wls::new(x_points, y_points, Some(weights));
    let point = wls.fit_linear_regression().unwrap();

    println!("Slope: {:?}", point.get_slope());
    println!("Intercept: {:?}", point.get_intercept());
}

Description

WLS is based on the OLS method and help solve problems of model inadequacy or violations of the basic regression assumptions.

Estimating a linear regression with WLS is useful, but can appear to be daunting without special stats packages, such as Python statsmodels or Pandas.

References

About

WLS, weighted linear regression in pure Rust with a single 3rd party dependency.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 97.2%
  • Makefile 2.8%