jrb-libsvm 0.1.2-java

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --tty
2
+ --color
3
+ --format documentation
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ jruby-1.7.3
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - jruby-19mode
4
+ - jruby-head
data/.versions.conf ADDED
@@ -0,0 +1,4 @@
1
+ ruby=jruby-1.7.3
2
+ ruby-gemset=jrb-libsvm
3
+ #ruby-gem-install=bundler rake
4
+ #ruby-bundle-install=true
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jrb-libsvm.gemspec
4
+ gemspec
5
+
6
+ group :test, :development do
7
+ gem 'rake'
8
+ gem 'pry'
9
+ end
data/LIBSVM-LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ Copyright (c) 2000-2012 Chih-Chung Chang and Chih-Jen Lin
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ 3. Neither name of copyright holders nor the names of its contributors
16
+ may be used to endorse or promote products derived from this software
17
+ without specific prior written permission.
18
+
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
24
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Andreas Eger
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # jrb-libsvm
2
+
3
+ [![Build Status](https://travis-ci.org/sch1zo/jrb-libsvm.png?branch=master)](undefined)
4
+
5
+ This jruby gem exposes more or less exactly the same interface as [rb-libsvm][].
6
+ Goal was to make them as interchangeable as possible.
7
+
8
+ This package provides a Ruby bindings to the [LIBSVM][] library. SVM
9
+ is a machine learning and classification algorithm, and LIBSVM is a
10
+ popular free implementation of it, written by Chih-Chung Chang and
11
+ Chih-Jen Lin, of National Taiwan University, Taipei. See the book ["Programming
12
+ Collective Intelligence,"](http://books.google.com/books?id=fEsZ3Ey-Hq4C) among others, for a usage example.
13
+
14
+ LIBSVM includes a number of command line tools for preprocessing
15
+ training data and finding parameters. These tools are not included in
16
+ this gem. You should install the original package if you need them.
17
+
18
+ It is helpful to consult the [README][] of the LIBSVM package for
19
+ reference when configuring the training parameters.
20
+
21
+ ## Java Libary
22
+
23
+ Currently this package includes a modified version of libsvm version
24
+ 3.16.
25
+
26
+ - proper Java class names, e.g. svm_model -> Model
27
+ - overloaded `svm_save_model` to be able to save to any DataOutputStream e.g. a String
28
+ - supress all info output written to STDOUT
29
+
30
+ This gem also includes v.3.11 sources which have a Model which provides value of w-squared for hyperplane.
31
+ These can be found in `java/3-11_w_squared/Svm.java`, to use it just move it into the libsvm folder
32
+ and recompile the jar (`rake compile`).
33
+
34
+ ## Dependencies
35
+
36
+ None. LIBSVM is bundled with the project. Just install and go!
37
+
38
+ ## Installation
39
+
40
+ Add this line to your application's Gemfile:
41
+
42
+ gem 'jrb-libsvm'
43
+
44
+ And then execute:
45
+
46
+ $ bundle
47
+
48
+ Or install it yourself as:
49
+
50
+ $ gem install jrb-libsvm
51
+
52
+ ## Usage
53
+
54
+ This is a short example of how to use the gem.
55
+
56
+ ```ruby
57
+ require 'jrb-libsvm'
58
+
59
+ # This library is namespaced.
60
+ problem = Libsvm::Problem.new
61
+ parameter = Libsvm::Parameter.new
62
+
63
+ parameter.cache_size = 1 # in megabytes
64
+
65
+ parameter.eps = 0.001
66
+ parameter.c = 10
67
+
68
+ examples = [ [1,0,1], [-1,0,-1] ].map {|ary| Libsvm::Node.features(ary) }
69
+ labels = [1, -1]
70
+
71
+ problem.set_examples(labels, examples)
72
+
73
+ model = Libsvm::Model.train(problem, parameter)
74
+
75
+ pred = model.predict(Libsvm::Node.features(1, 1, 1))
76
+ puts "Example [1, 1, 1] - Predicted #{pred}"
77
+ ```
78
+
79
+ ## License
80
+
81
+ This software can be freely used under the terms of the MIT license,
82
+ see file MIT-LICENSE.
83
+
84
+ This package includes the source of LIBSVM, which is free to use under
85
+ the license in the file LIBSVM-LICENSE.
86
+
87
+
88
+ ## Contributing
89
+
90
+ 1. Fork it
91
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
92
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
93
+ 4. Push to the branch (`git push origin my-new-feature`)
94
+ 5. Create new Pull Request
95
+
96
+
97
+ [libsvm]: http://www.csie.ntu.edu.tw/~cjlin/libsvm/
98
+
99
+ [svmrubyswig]: http://github.com/tomz/libsvm-ruby-swig/tree/master
100
+
101
+ [ruby-svm]: http://sourceforge.net/projects/rubysvm/
102
+
103
+ [README]: https://github.com/febeling/libsvm/blob/master/README
104
+
105
+ [rb-libsvm]: https://github.com/febeling/rb-libsvm
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "compile libsvm.jar from sources"
5
+ task :compile do
6
+ Dir.chdir('java') do
7
+ print `javac libsvm/*.java`
8
+ print `jar cvf libsvm.jar libsvm/*.class libsvm/*.java COPYRIGHT`
9
+ end
10
+ FileUtils.rm_r Dir['java/libsvm/*.class']
11
+ FileUtils.mv 'java/libsvm.jar','lib/java/libsvm.jar'
12
+ p "lib/java/libsvm.jar generated"
13
+ end
14
+
15
+ RSpec::Core::RakeTask.new('spec')
16
+ task :default => :spec