gslr 0.1.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/NOTICE.txt +1 -1
- data/README.md +2 -13
- data/lib/gslr/ffi.rb +2 -1
- data/lib/gslr/ridge.rb +14 -1
- data/lib/gslr/version.rb +1 -1
- data/lib/gslr.rb +11 -5
- metadata +10 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '096a21638b7b984b6a1942d0f9858d5835c3ea10eb1cb84d9128b793dc9e5447'
|
4
|
+
data.tar.gz: 2119c1dec30f2ed1c3013c630091268ba3053fd54c104acff98db11570f062d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6c34852bd83eb6a195958c330afdd781d59b0939a53a9bd41e6ed5fdd8b22a713765b94d3841b6e3d9949df4629161c75e79b24a426da364e7ceca8129c536
|
7
|
+
data.tar.gz: 36e9336ce4ff03cf60da3268fc9a4c6237e2227ba9878ea411ca0f6fea57dbc8648dfa6efa20c0655c6069a8d3c9c79a1394cc23d05b681f71be1dd8c66af264
|
data/CHANGELOG.md
CHANGED
data/NOTICE.txt
CHANGED
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://
|
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
|
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, "
|
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
data/lib/gslr.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
require "fiddle/import"
|
3
3
|
|
4
4
|
# modules
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
require_relative "gslr/model"
|
6
|
+
require_relative "gslr/ols"
|
7
|
+
require_relative "gslr/ridge"
|
8
|
+
require_relative "gslr/version"
|
9
9
|
|
10
10
|
module GSLR
|
11
11
|
class Error < StandardError; end
|
@@ -18,7 +18,13 @@ module GSLR
|
|
18
18
|
if Gem.win_platform?
|
19
19
|
["gsl.dll"]
|
20
20
|
elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
|
21
|
-
["
|
21
|
+
if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
|
22
|
+
self.cblas_lib = ["libgslcblas.dylib", "/opt/homebrew/lib/libgslcblas.dylib"]
|
23
|
+
["libgsl.dylib", "/opt/homebrew/lib/libgsl.dylib"]
|
24
|
+
else
|
25
|
+
self.cblas_lib = ["libgslcblas.dylib"]
|
26
|
+
["libgsl.dylib"]
|
27
|
+
end
|
22
28
|
else
|
23
29
|
self.cblas_lib = ["libgslcblas.so"]
|
24
30
|
["libgsl.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
|
4
|
+
version: 0.2.1
|
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:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
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: 2023-06-08 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.
|
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.
|
105
|
-
signing_key:
|
48
|
+
rubygems_version: 3.4.10
|
49
|
+
signing_key:
|
106
50
|
specification_version: 4
|
107
51
|
summary: High performance linear regression for Ruby, powered by GSL
|
108
52
|
test_files: []
|