numo-liblinear 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +27 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +5 -10
- data/ext/numo/liblinear/converter.c +6 -0
- data/ext/numo/liblinear/liblinearext.c +12 -0
- data/ext/numo/liblinear/problem.c +3 -0
- data/lib/numo/liblinear/version.rb +1 -1
- metadata +4 -4
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 582af5c3cacbe43a05329bd6d355a89c4bff8ac52aceacedb50a20ae61703dd0
|
|
4
|
+
data.tar.gz: c522cd810baa4f5b57065a52675479ea9ad563b32d2608e03f42639b929a6753
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b1d93cbcadf64aa4eddb44f47b1d0725d6002201393b8dc926f8288214609b140381beaa1ed09a47180a640c0d9b93612b5d2d1fb70c1c81c74caebcc1fc7de
|
|
7
|
+
data.tar.gz: 3d254a3ca1ab5075c1b5a5cc84a64e40473d7e8575368f5eface0585eaa52eaa6c515fd7f43be4460c82b7aad7e95e02982a8c1e45c06cbe550266da8dee6db2
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
ruby: [ '2.5', '2.6', '2.7' ]
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- name: Checkout submodule
|
|
14
|
+
shell: bash
|
|
15
|
+
run: |
|
|
16
|
+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
|
17
|
+
git submodule sync --recursive
|
|
18
|
+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
|
19
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
20
|
+
uses: actions/setup-ruby@v1
|
|
21
|
+
with:
|
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
|
23
|
+
- name: Build and test with Rake
|
|
24
|
+
run: |
|
|
25
|
+
gem install bundler
|
|
26
|
+
bundle install --jobs 4 --retry 3
|
|
27
|
+
bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Numo::Liblinear
|
|
2
2
|
|
|
3
|
-
[](https://github.com/yoshoku/numo-liblinear/actions?query=workflow%3Abuild)
|
|
4
4
|
[](https://badge.fury.io/rb/numo-liblinear)
|
|
5
|
-
[](https://github.com/yoshoku/numo-liblinear/blob/
|
|
5
|
+
[](https://github.com/yoshoku/numo-liblinear/blob/main/LICENSE.txt)
|
|
6
6
|
[](https://yoshoku.github.io/numo-liblinear/doc/)
|
|
7
7
|
|
|
8
8
|
Numo::Liblinear is a Ruby gem binding to the [LIBLINEAR](https://www.csie.ntu.edu.tw/~cjlin/liblinear/) library.
|
|
@@ -148,7 +148,7 @@ Accuracy: 87.9 %
|
|
|
148
148
|
## Note
|
|
149
149
|
The hyperparemter of LIBLINEAR is given with Ruby Hash on Numo::Liblinear.
|
|
150
150
|
The hash key of hyperparameter and its meaning match the struct parameter of LIBLINEAR.
|
|
151
|
-
The parameter is detailed in [LIBLINEAR README](https://github.com/cjlin1/liblinear/blob/
|
|
151
|
+
The parameter is detailed in [LIBLINEAR README](https://github.com/cjlin1/liblinear/blob/main/README)
|
|
152
152
|
|
|
153
153
|
```ruby
|
|
154
154
|
param = {
|
|
@@ -162,17 +162,12 @@ param = {
|
|
|
162
162
|
weight: # [Numo::DFloat] Weight values
|
|
163
163
|
Numo::DFloat[0.4, 0.4, 0.2],
|
|
164
164
|
p: 0.1, # [Float] Sensitiveness of loss of support vector regression
|
|
165
|
+
nu: 0.5, # [Float] one-class SVM approximates the fraction of data as outliers
|
|
165
166
|
verbose: false, # [Boolean] Whether to output learning process message
|
|
166
167
|
random_seed: 1 # [Integer/Nil] Random seed
|
|
167
168
|
}
|
|
168
169
|
```
|
|
169
170
|
|
|
170
|
-
## Development
|
|
171
|
-
|
|
172
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
173
|
-
|
|
174
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
175
|
-
|
|
176
171
|
## Contributing
|
|
177
172
|
|
|
178
173
|
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/numo-liblinear.
|
|
@@ -181,4 +176,4 @@ This project is intended to be a safe, welcoming space for collaboration, and co
|
|
|
181
176
|
## Code of Conduct
|
|
182
177
|
|
|
183
178
|
Everyone interacting in the Numo::Liblinear project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow
|
|
184
|
-
the [code of conduct](https://github.com/yoshoku/numo-liblinear/blob/
|
|
179
|
+
the [code of conduct](https://github.com/yoshoku/numo-liblinear/blob/main/CODE_OF_CONDUCT.md).
|
|
@@ -27,6 +27,8 @@ int* nary_to_int_vec(VALUE vec_val)
|
|
|
27
27
|
vec_pt = (int32_t*)na_get_pointer_for_read(vec_val);
|
|
28
28
|
for (i = 0; i < n_elements; i++) { vec[i] = (int)vec_pt[i]; }
|
|
29
29
|
|
|
30
|
+
RB_GC_GUARD(vec_val);
|
|
31
|
+
|
|
30
32
|
return vec;
|
|
31
33
|
}
|
|
32
34
|
|
|
@@ -56,6 +58,8 @@ double* nary_to_dbl_vec(VALUE vec_val)
|
|
|
56
58
|
vec_pt = (double*)na_get_pointer_for_read(vec_val);
|
|
57
59
|
memcpy(vec, vec_pt, n_elements * sizeof(double));
|
|
58
60
|
|
|
61
|
+
RB_GC_GUARD(vec_val);
|
|
62
|
+
|
|
59
63
|
return vec;
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -98,6 +102,8 @@ double** nary_to_dbl_mat(VALUE mat_val)
|
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
|
|
105
|
+
RB_GC_GUARD(mat_val);
|
|
106
|
+
|
|
101
107
|
return mat;
|
|
102
108
|
}
|
|
103
109
|
|
|
@@ -112,6 +112,9 @@ VALUE numo_liblinear_train(VALUE self, VALUE x_val, VALUE y_val, VALUE param_has
|
|
|
112
112
|
xfree_problem(problem);
|
|
113
113
|
xfree_parameter(param);
|
|
114
114
|
|
|
115
|
+
RB_GC_GUARD(x_val);
|
|
116
|
+
RB_GC_GUARD(y_val);
|
|
117
|
+
|
|
115
118
|
return model_hash;
|
|
116
119
|
}
|
|
117
120
|
|
|
@@ -225,6 +228,9 @@ VALUE numo_liblinear_cross_validation(VALUE self, VALUE x_val, VALUE y_val, VALU
|
|
|
225
228
|
xfree_problem(problem);
|
|
226
229
|
xfree_parameter(param);
|
|
227
230
|
|
|
231
|
+
RB_GC_GUARD(x_val);
|
|
232
|
+
RB_GC_GUARD(y_val);
|
|
233
|
+
|
|
228
234
|
return t_val;
|
|
229
235
|
}
|
|
230
236
|
|
|
@@ -291,6 +297,8 @@ VALUE numo_liblinear_predict(VALUE self, VALUE x_val, VALUE param_hash, VALUE mo
|
|
|
291
297
|
xfree_model(model);
|
|
292
298
|
xfree_parameter(param);
|
|
293
299
|
|
|
300
|
+
RB_GC_GUARD(x_val);
|
|
301
|
+
|
|
294
302
|
return y_val;
|
|
295
303
|
}
|
|
296
304
|
|
|
@@ -381,6 +389,8 @@ VALUE numo_liblinear_decision_function(VALUE self, VALUE x_val, VALUE param_hash
|
|
|
381
389
|
xfree_model(model);
|
|
382
390
|
xfree_parameter(param);
|
|
383
391
|
|
|
392
|
+
RB_GC_GUARD(x_val);
|
|
393
|
+
|
|
384
394
|
return y_val;
|
|
385
395
|
}
|
|
386
396
|
|
|
@@ -457,6 +467,8 @@ VALUE numo_liblinear_predict_proba(VALUE self, VALUE x_val, VALUE param_hash, VA
|
|
|
457
467
|
xfree_model(model);
|
|
458
468
|
xfree_parameter(param);
|
|
459
469
|
|
|
470
|
+
RB_GC_GUARD(x_val);
|
|
471
|
+
|
|
460
472
|
return y_val;
|
|
461
473
|
}
|
|
462
474
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: numo-liblinear
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yoshoku
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-01-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: numo-narray
|
|
@@ -91,10 +91,10 @@ extensions:
|
|
|
91
91
|
- ext/numo/liblinear/extconf.rb
|
|
92
92
|
extra_rdoc_files: []
|
|
93
93
|
files:
|
|
94
|
+
- ".github/workflows/build.yml"
|
|
94
95
|
- ".gitignore"
|
|
95
96
|
- ".gitmodules"
|
|
96
97
|
- ".rspec"
|
|
97
|
-
- ".travis.yml"
|
|
98
98
|
- CHANGELOG.md
|
|
99
99
|
- CODE_OF_CONDUCT.md
|
|
100
100
|
- Gemfile
|
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
149
|
- !ruby/object:Gem::Version
|
|
150
150
|
version: '0'
|
|
151
151
|
requirements: []
|
|
152
|
-
rubygems_version: 3.1.
|
|
152
|
+
rubygems_version: 3.1.4
|
|
153
153
|
signing_key:
|
|
154
154
|
specification_version: 4
|
|
155
155
|
summary: Numo::Liblinear is a Ruby gem binding to the LIBLINEAR library. Numo::Liblinear
|