gslr 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 374367109a0114a6b5dfe233edfb6decf292f0be3fd2a211d72152775789b2df
4
- data.tar.gz: dc24bcc8e1c6427a09750394b5bec0f9e0634cd9d00a7a2f26bfabda3ca9d579
3
+ metadata.gz: 521c330d9040f7959bda2aa653e1151b081145eefcfee8cbdb18d1e795cf020b
4
+ data.tar.gz: 34e28e1a9a6920e75d103e58b6f26d86b4bffbd3d5be16f6ae85b2e902ec5567
5
5
  SHA512:
6
- metadata.gz: 6b65b69fc217e1766ac870c9fdcf3b753e2a0cb52ce59efafc0bdcc0384f5f04c54fbbd9055e3c87449216fa735e6e1d22d0f7e3cf38047ea5f75405bf3cb981
7
- data.tar.gz: bf9eb0963cbd1154d043b02fe2d9056501959db494329bdcd93b0d3c899ea57fd5df4d3be667f7a210413c9f35678bdf9181df5cca60e3c3986c790e8cca9a5b
6
+ metadata.gz: 257651df760713ed75f60907c423dd6bcdd4bbd63621d89bd2243269631311d07ea1b9045b4d3adcdfc2d8499f29eec9e29983fc0e3f71a572715ed363429432
7
+ data.tar.gz: 2baadaa2e4da0650ccd630549e57ca3cbfe3781d278ee2653602a12062a586427cef50fd980cd8563a7efa6565464b39b1b323fba41ef02ee269577c8fcfaae7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.0 (2022-09-02)
2
+
3
+ - Fixed error on Mac
4
+ - Dropped support for Ruby < 2.7
5
+
1
6
  ## 0.1.3 (2020-07-26)
2
7
 
3
8
  - Improved performance
data/NOTICE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2019 Andrew Kane
1
+ Copyright (C) 2019-2022 Andrew Kane
2
2
 
3
3
  This program is free software: you can redistribute it and/or modify
4
4
  it under the terms of the GNU General Public License as published by
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  :fire: High performance linear regression for Ruby, powered by [GSL](https://www.gnu.org/software/gsl/)
4
4
 
5
- [![Build Status](https://travis-ci.org/ankane/gslr.svg?branch=master)](https://travis-ci.org/ankane/gslr)
5
+ [![Build Status](https://github.com/ankane/gslr/workflows/build/badge.svg?branch=master)](https://github.com/ankane/gslr/actions)
6
6
 
7
7
  ## Installation
8
8
 
@@ -15,7 +15,7 @@ brew install gsl
15
15
  Add this line to your application’s Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'gslr'
18
+ gem "gslr"
19
19
  ```
20
20
 
21
21
  ## Getting Started
@@ -112,17 +112,6 @@ Use the [Apt buildpack](https://github.com/heroku/heroku-buildpack-apt) and crea
112
112
  libgsl-dev
113
113
  ```
114
114
 
115
- ### Travis CI
116
-
117
- Add to `.travis.yml`:
118
-
119
- ```yml
120
- addons:
121
- apt:
122
- packages:
123
- - libgsl-dev
124
- ```
125
-
126
115
  ## History
127
116
 
128
117
  View the [changelog](https://github.com/ankane/gslr/blob/master/CHANGELOG.md)
data/lib/gslr/ffi.rb CHANGED
@@ -11,7 +11,7 @@ module GSLR
11
11
  rescue Fiddle::DLError => e
12
12
  retry if libs.any?
13
13
  raise e if ENV["GSLR_DEBUG"]
14
- raise LoadError, "Could not find GSL"
14
+ raise LoadError, "GSL CBLAS not found"
15
15
  end
16
16
  end
17
17
 
@@ -48,5 +48,6 @@ module GSLR
48
48
  extern "void gsl_multifit_linear_free(gsl_multifit_linear_workspace * work)"
49
49
  extern "int gsl_multifit_linear_solve(double lambda, gsl_matrix * Xs, gsl_vector * ys, gsl_vector * cs, double * rnorm, double * snorm, gsl_multifit_linear_workspace * work)"
50
50
  extern "int gsl_multifit_linear_svd(gsl_matrix * X, gsl_multifit_linear_workspace * work)"
51
+ extern "int gsl_multifit_linear_applyW(gsl_matrix * X, gsl_vector * w, gsl_vector * y, gsl_matrix * WX, gsl_vector * Wy)"
51
52
  end
52
53
  end
data/lib/gslr/ridge.rb CHANGED
@@ -5,16 +5,29 @@ module GSLR
5
5
  @alpha = alpha
6
6
  end
7
7
 
8
- def fit(x, y)
8
+ def fit(x, y, weight: nil)
9
9
  if @fit_intercept
10
10
  # the intercept should not be regularized
11
11
  # so we need to center x and y
12
12
  # and exclude the intercept
13
13
  xc, x_offset, s1, s2 = centered_matrix(x)
14
14
  yc, y_offset = centered_vector(y)
15
+
16
+ if weight
17
+ # TODO apply weights before centering
18
+ # not a great way to calculate and subtract the mean
19
+ # with GSL and FFI
20
+ raise "weight not supported with intercept yet"
21
+ end
15
22
  else
16
23
  xc, s1, s2 = set_matrix(x, intercept: false)
17
24
  yc = set_vector(y)
25
+
26
+ if weight
27
+ wc = set_vector(weight)
28
+ # in place transformation
29
+ check_status FFI.gsl_multifit_linear_applyW(xc, wc, yc, xc, yc)
30
+ end
18
31
  end
19
32
 
20
33
  # allocate solution
data/lib/gslr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GSLR
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/gslr.rb CHANGED
@@ -18,6 +18,7 @@ module GSLR
18
18
  if Gem.win_platform?
19
19
  ["gsl.dll"]
20
20
  elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
21
+ self.cblas_lib = ["libgslcblas.dylib"]
21
22
  ["libgsl.dylib"]
22
23
  else
23
24
  self.cblas_lib = ["libgslcblas.so"]
metadata CHANGED
@@ -1,73 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gslr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-26 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: minitest
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '5'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '5'
55
- - !ruby/object:Gem::Dependency
56
- name: numo-narray
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- description:
70
- email: andrew@chartkick.com
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: andrew@ankane.org
71
15
  executables: []
72
16
  extensions: []
73
17
  extra_rdoc_files: []
@@ -86,7 +30,7 @@ homepage: https://github.com/ankane/gslr
86
30
  licenses:
87
31
  - GPL-3.0-or-later
88
32
  metadata: {}
89
- post_install_message:
33
+ post_install_message:
90
34
  rdoc_options: []
91
35
  require_paths:
92
36
  - lib
@@ -94,15 +38,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
38
  requirements:
95
39
  - - ">="
96
40
  - !ruby/object:Gem::Version
97
- version: '2.4'
41
+ version: '2.7'
98
42
  required_rubygems_version: !ruby/object:Gem::Requirement
99
43
  requirements:
100
44
  - - ">="
101
45
  - !ruby/object:Gem::Version
102
46
  version: '0'
103
47
  requirements: []
104
- rubygems_version: 3.1.2
105
- signing_key:
48
+ rubygems_version: 3.3.7
49
+ signing_key:
106
50
  specification_version: 4
107
51
  summary: High performance linear regression for Ruby, powered by GSL
108
52
  test_files: []