libsvmloader 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -1
- data/.github/workflows/build.yml +22 -0
- data/.github/workflows/coverage.yml +26 -0
- data/.rubocop.yml +6 -0
- data/{HISTORY.md → CHANGELOG.md} +5 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +3 -9
- data/Steepfile +20 -0
- data/lib/libsvmloader.rb +4 -4
- data/lib/libsvmloader/version.rb +1 -1
- data/libsvmloader.gemspec +0 -7
- data/sig/libsvmloader.rbs +18 -0
- metadata +11 -69
- data/.travis.yml +0 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/exe/libsvmloader +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c9126689f92d7501d691bdf6bbebf04ada08073d76839bf4599d70224f693e9
|
4
|
+
data.tar.gz: e4b83b0e4afc8c3760bd54b79349d8e5920a2cf7503194ee5a223bfec2517fd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bb9d9de0b39b85a2ec0a206b8f8e2dbb7d4ba50ebabd672231432bfb1c895c5db5f0d433df0db03d2b8acad4429484c8ae07951a0ffde92d3a87a8144f92b35
|
7
|
+
data.tar.gz: f1b8262ac0e2dbfd8e990c0935cf6360e7b3c3e5ab43892899e3a92dcb22b377dc60f09bd98c92126b629d5a3bff6d649a64e2945459627b069425813c8f5396
|
data/.coveralls.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
service_name:
|
1
|
+
service_name: github-ci
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: build
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-20.04
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [ '2.6', '2.7', '3.0' ]
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
15
|
+
uses: actions/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
- name: Build and test with Rake
|
19
|
+
run: |
|
20
|
+
gem install --no-document bundler
|
21
|
+
bundle install --jobs 4 --retry 3
|
22
|
+
bundle exec rake
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: coverage
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
coverage:
|
11
|
+
runs-on: ubuntu-20.04
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby 2.7
|
15
|
+
uses: actions/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: '2.7'
|
18
|
+
- name: Build and test with Rake
|
19
|
+
run: |
|
20
|
+
gem install bundler
|
21
|
+
bundle install
|
22
|
+
bundle exec rake
|
23
|
+
- name: Coveralls GitHub Action
|
24
|
+
uses: coverallsapp/github-action@v1.1.2
|
25
|
+
with:
|
26
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
data/.rubocop.yml
CHANGED
data/{HISTORY.md → CHANGELOG.md}
RENAMED
data/Gemfile
CHANGED
@@ -4,3 +4,11 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in libsvmloader.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'bundler', '~> 2.0'
|
9
|
+
gem 'rake', '~> 13.0'
|
10
|
+
gem 'rspec', '~> 3.0'
|
11
|
+
gem 'simplecov', '~> 0.19'
|
12
|
+
gem 'simplecov-lcov', '~> 0.8'
|
13
|
+
gem 'rbs', '~> 1.2'
|
14
|
+
gem 'steep', '~> 0.44'
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# LibSVMLoader
|
2
2
|
|
3
|
-
[![Build Status](https://
|
4
|
-
[![Coverage Status](https://coveralls.io/repos/github/yoshoku/LibSVMLoader/badge.svg?branch=
|
3
|
+
[![Build Status](https://github.com/yoshoku/LibSVMLoader/workflows/build/badge.svg)](https://github.com/yoshoku/LibSVMLoader/actions?query=workflow%3Abuild)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/github/yoshoku/LibSVMLoader/badge.svg?branch=main)](https://coveralls.io/github/yoshoku/LibSVMLoader?branch=main)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/libsvmloader.svg)](https://badge.fury.io/rb/libsvmloader)
|
6
|
-
[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/yoshoku/LibSVMLoader/blob/
|
6
|
+
[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/yoshoku/LibSVMLoader/blob/main/LICENSE.txt)
|
7
7
|
|
8
8
|
LibSVMLoader loads (and dumps) dataset file with the libsvm file format.
|
9
9
|
|
@@ -65,12 +65,6 @@ labels_nm = N[*labels]
|
|
65
65
|
LibSVMLoader.dump_libsvm_file(samples_nm.to_a, labels_nm.to_a, 'bar.t')
|
66
66
|
```
|
67
67
|
|
68
|
-
## Development
|
69
|
-
|
70
|
-
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.
|
71
|
-
|
72
|
-
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).
|
73
|
-
|
74
68
|
## Contributing
|
75
69
|
|
76
70
|
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/libsvmloader.
|
data/Steepfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
target :lib do
|
2
|
+
signature "sig"
|
3
|
+
#
|
4
|
+
check "lib" # Directory name
|
5
|
+
# check "Gemfile" # File name
|
6
|
+
# check "app/models/**/*.rb" # Glob
|
7
|
+
# # ignore "lib/templates/*.rb"
|
8
|
+
#
|
9
|
+
# # library "pathname", "set" # Standard libraries
|
10
|
+
# # library "strong_json" # Gems
|
11
|
+
end
|
12
|
+
|
13
|
+
# target :spec do
|
14
|
+
# signature "sig", "sig-private"
|
15
|
+
#
|
16
|
+
# check "spec"
|
17
|
+
#
|
18
|
+
# # library "pathname", "set" # Standard libraries
|
19
|
+
# # library "rspec"
|
20
|
+
# end
|
data/lib/libsvmloader.rb
CHANGED
@@ -38,9 +38,9 @@ class LibSVMLoader
|
|
38
38
|
# @param filename [String] Path to the output libsvm file.
|
39
39
|
# @param zero_based [Boolean] Whether the column index starts from 0 (true) or 1 (false).
|
40
40
|
def dump_libsvm_file(data, labels, filename, zero_based: false)
|
41
|
-
n_samples =
|
42
|
-
label_format = detect_format(labels
|
43
|
-
value_format = detect_format(data.flatten
|
41
|
+
n_samples = data.size < labels.size ? data.size : labels.size
|
42
|
+
label_format = detect_format(labels[0])
|
43
|
+
value_format = detect_format(data.flatten[0])
|
44
44
|
File.open(filename, 'w') do |file|
|
45
45
|
n_samples.times { |n| file.puts(dump_libsvm_line(labels[n], data[n], label_format, value_format, zero_based)) }
|
46
46
|
end
|
@@ -53,7 +53,7 @@ class LibSVMLoader
|
|
53
53
|
adj_idx = zero_based == false ? 1 : 0
|
54
54
|
max_idx = -1
|
55
55
|
ftvec = []
|
56
|
-
while el = row.shift
|
56
|
+
while (el = row.shift)
|
57
57
|
idx, val = el.split(':')
|
58
58
|
idx = idx.to_i - adj_idx
|
59
59
|
max_idx = idx if max_idx < idx
|
data/lib/libsvmloader/version.rb
CHANGED
data/libsvmloader.gemspec
CHANGED
@@ -25,11 +25,4 @@ MSG
|
|
25
25
|
spec.bindir = 'exe'
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
|
-
|
29
|
-
spec.required_ruby_version = '>= 2.1'
|
30
|
-
|
31
|
-
spec.add_development_dependency 'bundler', '~> 1.15'
|
32
|
-
spec.add_development_dependency 'coveralls', '~> 0.8'
|
33
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
28
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# LibSVMLoader loads (and dumps) dataset file with the libsvm file format.
|
2
|
+
class LibSVMLoader
|
3
|
+
VERSION: String
|
4
|
+
|
5
|
+
def self.load_libsvm_file: (String filename, ?zero_based: bool zero_based,
|
6
|
+
?label_dtype: String label_dtype, ?value_dtype: String value_dtype) -> Array[Array[untyped]]
|
7
|
+
def self.dump_libsvm_file: (Array[Array[untyped]] data, Array[Numeric | String] labels, String filename,
|
8
|
+
?zero_based: bool zero_based) -> void
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def self.parse_libsvm_row: (Array[String] row, bool zero_based, Symbol label_type, Symbol value_type) -> Array[untyped]
|
13
|
+
def self.parse_dtype: (String | Symbol dtype) -> Symbol
|
14
|
+
def self.convert_type: (untyped value, Symbol dtype) -> untyped
|
15
|
+
def self.convert_to_matrix: (Array[untyped] data, Integer n_features, Symbol value_type) -> Array[Array[untyped]]
|
16
|
+
def self.detect_format: (untyped data) -> String
|
17
|
+
def self.dump_libsvm_line: (Numeric | String label, Array[untyped] ftvec, String label_format, String value_format, bool zero_based) -> String
|
18
|
+
end
|
metadata
CHANGED
@@ -1,98 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libsvmloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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: '1.15'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.15'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: coveralls
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.8'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.8'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.0'
|
11
|
+
date: 2021-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
69
13
|
description: |
|
70
14
|
LibSVMLoader is a class that loads (and dumps) dataset file with the libsvm file format.
|
71
15
|
The feature vectors and labels of dataset are represented by Ruby Array.
|
72
16
|
email:
|
73
17
|
- yoshoku@outlook.com
|
74
|
-
executables:
|
75
|
-
- libsvmloader
|
18
|
+
executables: []
|
76
19
|
extensions: []
|
77
20
|
extra_rdoc_files: []
|
78
21
|
files:
|
79
22
|
- ".coveralls.yml"
|
23
|
+
- ".github/workflows/build.yml"
|
24
|
+
- ".github/workflows/coverage.yml"
|
80
25
|
- ".gitignore"
|
81
26
|
- ".rspec"
|
82
27
|
- ".rubocop.yml"
|
83
|
-
-
|
28
|
+
- CHANGELOG.md
|
84
29
|
- CODE_OF_CONDUCT.md
|
85
30
|
- Gemfile
|
86
|
-
- HISTORY.md
|
87
31
|
- LICENSE.txt
|
88
32
|
- README.md
|
89
33
|
- Rakefile
|
90
|
-
-
|
91
|
-
- bin/setup
|
92
|
-
- exe/libsvmloader
|
34
|
+
- Steepfile
|
93
35
|
- lib/libsvmloader.rb
|
94
36
|
- lib/libsvmloader/version.rb
|
95
37
|
- libsvmloader.gemspec
|
38
|
+
- sig/libsvmloader.rbs
|
96
39
|
homepage: https://github.com/yoshoku/libsvmloader
|
97
40
|
licenses:
|
98
41
|
- MIT
|
@@ -105,15 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
48
|
requirements:
|
106
49
|
- - ">="
|
107
50
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
51
|
+
version: '0'
|
109
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
53
|
requirements:
|
111
54
|
- - ">="
|
112
55
|
- !ruby/object:Gem::Version
|
113
56
|
version: '0'
|
114
57
|
requirements: []
|
115
|
-
|
116
|
-
rubygems_version: 2.7.6
|
58
|
+
rubygems_version: 3.1.6
|
117
59
|
signing_key:
|
118
60
|
specification_version: 4
|
119
61
|
summary: LibSVMLoader loads (and dumps) dataset file with the libsvm file format.
|
data/.travis.yml
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "libsvmloader"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/exe/libsvmloader
DELETED