libsvmloader 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/HISTORY.md +9 -0
- data/lib/libsvmloader.rb +6 -9
- data/lib/libsvmloader/version.rb +1 -9
- data/libsvmloader.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feb8cd299e4b1221e3c6cb4c2d2b006890f70a55
|
4
|
+
data.tar.gz: 99e4bcd0831930025f00bf00b72cc8063ea22a96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0a83f69953b4fabebde09baff9e674723d8e2c05960caf3d390a6cacb520b077bdc515d27a2dc63c60e21720ced6569ce5151fef477df0472301231406101cd
|
7
|
+
data.tar.gz: 4da38d07e12770f2072837c34545398d41ad77f6b15d2e6f94805b2f236dd5e39d76acb2b6319ff4a6b99213a943bdd83e2c2796404b14719815e72dfca3f2ac
|
data/.rubocop.yml
ADDED
data/HISTORY.md
ADDED
data/lib/libsvmloader.rb
CHANGED
@@ -16,18 +16,15 @@ class LibSVMLoader
|
|
16
16
|
# @return [Array<NMatrix>]
|
17
17
|
# Returns array containing the (n_samples x n_features) matrix for feature vectors
|
18
18
|
# and (n_samples x 1) matrix for labels or target values.
|
19
|
-
def load_libsvm_file(filename, zero_based: false, stype: :yale,
|
20
|
-
label_dtype: :int32, value_dtype: :float64)
|
19
|
+
def load_libsvm_file(filename, zero_based: false, stype: :yale, label_dtype: :int32, value_dtype: :float64)
|
21
20
|
ftvecs = []
|
22
21
|
labels = []
|
23
22
|
n_features = 0
|
24
|
-
File.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
n_features = [n_features, max_idx].max
|
30
|
-
end
|
23
|
+
File.read(filename).split("\n").each do |line|
|
24
|
+
label, ftvec, max_idx = parse_libsvm_line(line, zero_based)
|
25
|
+
labels.push(label)
|
26
|
+
ftvecs.push(ftvec)
|
27
|
+
n_features = [n_features, max_idx].max
|
31
28
|
end
|
32
29
|
[convert_to_nmatrix(ftvecs, n_features, value_dtype, stype),
|
33
30
|
NMatrix.new([labels.size, 1], labels, dtype: label_dtype)]
|
data/lib/libsvmloader/version.rb
CHANGED
data/libsvmloader.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libsvmloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,9 +76,11 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
|
+
- ".rubocop.yml"
|
79
80
|
- ".travis.yml"
|
80
81
|
- CODE_OF_CONDUCT.md
|
81
82
|
- Gemfile
|
83
|
+
- HISTORY.md
|
82
84
|
- LICENSE.txt
|
83
85
|
- README.md
|
84
86
|
- Rakefile
|