Skip to content
High performance linear regression for Ruby, powered by GSL
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
CHANGELOG.md
Gemfile
LICENSE.txt
NOTICE.txt
README.md
Rakefile
gslr.gemspec

README.md

GSLR

🔥 High performance linear regression for Ruby, powered by GSL

Build Status

Installation

Install GSL. For Homebrew, use:

brew install gsl

Add this line to your application’s Gemfile:

gem 'gslr'

Getting Started

Ordinary Least Squares

Prep your data

x = [[1, 3], [2, 3], [3, 5], [4, 5]]
y = [10, 11, 16, 17]

Train a model

model = GSLR::OLS.new
model.fit(x, y)

Make predictions

model.predict(x)

Get the coefficients and intercept

model.coefficients
model.intercept

Get the covariance matrix and chi-squared

model.covariance
model.chi2

Pass weights

weight = [1, 2, 3, 4]
model.fit(x, y, weight: weight)

Disable the intercept

GSLR::OLS.new(intercept: false)

Ridge

Train a model

model = GSLR::Ridge.new
model.fit(x, y)

Set the regularization strength

GSLR::Ridge.new(alpha: 1.0)

Note: Weights aren’t supported yet

GSL Installation

Mac

brew install gsl

Windows

Check out the options.

Ubuntu

sudo apt install libgsl-dev

Heroku

Use the Apt buildpack and create an Aptfile with:

libgsl-dev

Travis CI

Add to .travis.yml:

addons:
  apt:
    packages:
    - libgsl-dev

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/gslr.git
cd gslr
bundle install
bundle exec rake test
You can’t perform that action at this time.