rb-libsvm 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +2 -0
- data/README.md +27 -25
- data/Rakefile +3 -4
- data/ext/{rb-libsvm → libsvm}/extconf.rb +2 -2
- data/ext/{rb-libsvm → libsvm}/libsvm.c +1 -1
- data/ext/{rb-libsvm → libsvm}/ruby-ext.h +0 -0
- data/ext/{rb-libsvm → libsvm}/svm.cpp +0 -0
- data/ext/{rb-libsvm → libsvm}/svm.h +0 -0
- data/lib/libsvm.rb +2 -3
- data/lib/libsvm/version.rb +3 -0
- data/rb-libsvm.gemspec +2 -3
- metadata +15 -15
- data/lib/rb-libsvm/version.rb +0 -3
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
Spec Status: [![Build Status](https://secure.travis-ci.org/febeling/rb-libsvm.png)](http://travis-ci.org/febeling/rb-libsvm)
|
4
4
|
|
5
|
-
This
|
6
|
-
|
7
|
-
|
5
|
+
This package provides a Ruby bindings to the LIBSVM [1] library. SVM
|
6
|
+
is a machine learning and classification algorithm, and LIBSVM is a
|
7
|
+
popular free implementation of it, written by Chih-Chung Chang and
|
8
8
|
Chih-Jen Lin, of National Taiwan University, Taipei. See "Programming
|
9
9
|
Collective Intelligence," [2] among others, for a usage example.
|
10
10
|
|
11
|
-
Note: There
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
Note: There exist two other Ruby bindings for LIBSVM. One is named
|
12
|
+
Ruby SVM, written by Rudi Cilibrasi. It is hard to find now. The
|
13
|
+
other, more actively developed one is libsvm-ruby-swig by Tom Zeng
|
14
|
+
[3], which is built using SWIG.
|
15
15
|
|
16
16
|
## Dependencies
|
17
17
|
|
18
18
|
None. Libsvm is bundled with the project. Just install and go!
|
19
19
|
|
20
|
-
Currently
|
20
|
+
Currently includes libsvm version 3.12.
|
21
21
|
|
22
22
|
## Installation
|
23
23
|
|
@@ -25,27 +25,28 @@ Currently using libsvm version 3.12
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
-
|
28
|
+
```ruby
|
29
|
+
require 'libsvm'
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
# This library is namespaced.
|
32
|
+
problem = Libsvm::Problem.new
|
33
|
+
parameter = Libsvm::SvmParameter.new
|
33
34
|
|
34
|
-
|
35
|
+
parameter.cache_size = 1 # in megabytes
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
parameter.eps = 0.001
|
38
|
+
parameter.c = 10
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
examples = [ [1,0,1], [-1,0,-1] ].map {|ary| Libsvm::Node.features(ary) }
|
41
|
+
labels = [1, -1]
|
41
42
|
|
42
|
-
|
43
|
+
problem.set_examples(labels, examples)
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
pred = model.predict(Libsvm::Node.features(1, 1, 1))
|
47
|
-
puts "Example [1, 1, 1] - Predicted #{pred}"
|
45
|
+
model = Libsvm::Model.train(problem, parameter)
|
48
46
|
|
47
|
+
pred = model.predict(Libsvm::Node.features(1, 1, 1))
|
48
|
+
puts "Example [1, 1, 1] - Predicted #{pred}"
|
49
|
+
```
|
49
50
|
|
50
51
|
## Author, License
|
51
52
|
|
@@ -68,8 +69,9 @@ the license in the file LIBSVM-LICENSE.
|
|
68
69
|
[http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/](http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/)
|
69
70
|
|
70
71
|
|
71
|
-
### Notes
|
72
72
|
|
73
|
-
[http://www.csie.ntu.edu.tw/~cjlin/libsvm/](http://www.csie.ntu.edu.tw/~cjlin/libsvm/)
|
73
|
+
[1]: [http://www.csie.ntu.edu.tw/~cjlin/libsvm/](http://www.csie.ntu.edu.tw/~cjlin/libsvm/)
|
74
|
+
|
75
|
+
[2]: [http://books.google.com/books?id=fEsZ3Ey-Hq4C](http://books.google.com/books?id=fEsZ3Ey-Hq4C)
|
74
76
|
|
75
|
-
[http://
|
77
|
+
[3]: http://github.com/tomz/libsvm-ruby-swig/tree/master
|
data/Rakefile
CHANGED
@@ -4,12 +4,11 @@ require 'rspec/core/rake_task'
|
|
4
4
|
|
5
5
|
task :default => :spec
|
6
6
|
|
7
|
-
Rake::ExtensionTask.new('
|
8
|
-
ext.lib_dir = File.join('lib', '
|
9
|
-
ext.name = '
|
7
|
+
Rake::ExtensionTask.new('libsvm') do |ext|
|
8
|
+
ext.lib_dir = File.join('lib', 'libsvm')
|
9
|
+
ext.name = 'libsvm_ext'
|
10
10
|
end
|
11
11
|
|
12
12
|
RSpec::Core::RakeTask.new('spec')
|
13
13
|
Rake::Task[:spec].prerequisites << :clean
|
14
14
|
Rake::Task[:spec].prerequisites << :compile
|
15
|
-
|
File without changes
|
File without changes
|
File without changes
|
data/lib/libsvm.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'libsvm/version'
|
2
|
+
require 'libsvm/libsvm_ext'
|
3
3
|
require 'libsvm/node'
|
4
4
|
|
5
5
|
module Libsvm
|
@@ -12,7 +12,6 @@ module Libsvm
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
15
|
class Hash
|
17
16
|
include Libsvm::CoreExtensions::Collection
|
18
17
|
end
|
data/rb-libsvm.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require '
|
3
|
+
require 'libsvm/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "rb-libsvm"
|
@@ -22,6 +22,5 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency('rake-compiler')
|
23
23
|
s.add_development_dependency('rspec', '>= 2.7.0')
|
24
24
|
|
25
|
-
s.extensions << 'ext/
|
25
|
+
s.extensions << 'ext/libsvm/extconf.rb'
|
26
26
|
end
|
27
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-libsvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-02 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake-compiler
|
17
|
-
requirement: &
|
17
|
+
requirement: &70133955492220 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70133955492220
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &70133955490320 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
version: 2.7.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70133955490320
|
37
37
|
description: libsvm and ruby without using swig
|
38
38
|
email:
|
39
39
|
- florian.ebeling@gmail.com
|
40
40
|
- neovintage@gmail.com
|
41
41
|
executables: []
|
42
42
|
extensions:
|
43
|
-
- ext/
|
43
|
+
- ext/libsvm/extconf.rb
|
44
44
|
extra_rdoc_files: []
|
45
45
|
files:
|
46
46
|
- .gitignore
|
@@ -53,14 +53,14 @@ files:
|
|
53
53
|
- Rakefile
|
54
54
|
- examples/text.rb
|
55
55
|
- examples/toy.rb
|
56
|
-
- ext/
|
57
|
-
- ext/
|
58
|
-
- ext/
|
59
|
-
- ext/
|
60
|
-
- ext/
|
56
|
+
- ext/libsvm/extconf.rb
|
57
|
+
- ext/libsvm/libsvm.c
|
58
|
+
- ext/libsvm/ruby-ext.h
|
59
|
+
- ext/libsvm/svm.cpp
|
60
|
+
- ext/libsvm/svm.h
|
61
61
|
- lib/libsvm.rb
|
62
62
|
- lib/libsvm/node.rb
|
63
|
-
- lib/
|
63
|
+
- lib/libsvm/version.rb
|
64
64
|
- rb-libsvm.gemspec
|
65
65
|
- spec/model_spec.rb
|
66
66
|
- spec/node_spec.rb
|
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
segments:
|
84
84
|
- 0
|
85
|
-
hash:
|
85
|
+
hash: 1508460701576130505
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
87
|
none: false
|
88
88
|
requirements:
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash:
|
94
|
+
hash: 1508460701576130505
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project: rb-libsvm
|
97
97
|
rubygems_version: 1.8.10
|
data/lib/rb-libsvm/version.rb
DELETED