jrb-libsvm 0.1.2-java
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.
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/.versions.conf +4 -0
- data/Gemfile +9 -0
- data/LIBSVM-LICENSE +30 -0
- data/MIT-LICENSE +22 -0
- data/README.md +105 -0
- data/Rakefile +16 -0
- data/java/3-11_w_squared/Svm.java +2826 -0
- data/java/COPYRIGHT +31 -0
- data/java/libsvm/Model.java +23 -0
- data/java/libsvm/Node.java +6 -0
- data/java/libsvm/Parameter.java +47 -0
- data/java/libsvm/PrintInterface.java +5 -0
- data/java/libsvm/Problem.java +7 -0
- data/java/libsvm/Svm.java +2814 -0
- data/jrb-libsvm.gemspec +23 -0
- data/lib/java/libsvm.jar +0 -0
- data/lib/jrb-libsvm/model.rb +97 -0
- data/lib/jrb-libsvm/node.rb +37 -0
- data/lib/jrb-libsvm/parameter.rb +66 -0
- data/lib/jrb-libsvm/problem.rb +35 -0
- data/lib/jrb-libsvm/version.rb +3 -0
- data/lib/jrb-libsvm.rb +31 -0
- data/spec/model_spec.rb +119 -0
- data/spec/node_spec.rb +62 -0
- data/spec/parameter_spec.rb +79 -0
- data/spec/problem_spec.rb +37 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/usage_spec.rb +47 -0
- data/tmp/.gitkeep +0 -0
- metadata +108 -0
data/java/COPYRIGHT
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
Copyright (c) 2000-2012 Chih-Chung Chang and Chih-Jen Lin
|
3
|
+
All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
6
|
+
modification, are permitted provided that the following conditions
|
7
|
+
are met:
|
8
|
+
|
9
|
+
1. Redistributions of source code must retain the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
3. Neither name of copyright holders nor the names of its contributors
|
17
|
+
may be used to endorse or promote products derived from this software
|
18
|
+
without specific prior written permission.
|
19
|
+
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
|
25
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
26
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
27
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
28
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
29
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
30
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
//
|
2
|
+
// Model
|
3
|
+
//
|
4
|
+
package libsvm;
|
5
|
+
public class Model implements java.io.Serializable
|
6
|
+
{
|
7
|
+
public Parameter param; // parameter
|
8
|
+
public int nr_class; // number of classes, = 2 in regression/one class svm
|
9
|
+
public int l; // total #SV
|
10
|
+
public Node[][] SV; // SVs (SV[l])
|
11
|
+
public double[][] sv_coef; // coefficients for SVs in decision functions (sv_coef[k-1][l])
|
12
|
+
public double[] rho; // constants in decision functions (rho[k*(k-1)/2])
|
13
|
+
public double[] w_2; // hyperplane squared norms for each binary SVM (PCL, taken from Gabor Melis)
|
14
|
+
public double[] probA; // pariwise probability information
|
15
|
+
public double[] probB;
|
16
|
+
public int[] sv_indices; // sv_indices[0,...,nSV-1] are values in [1,...,num_traning_data] to indicate SVs in the training set
|
17
|
+
|
18
|
+
// for classification only
|
19
|
+
|
20
|
+
public int[] label; // label of each class (label[k])
|
21
|
+
public int[] nSV; // number of SVs for each class (nSV[k])
|
22
|
+
// nSV[0] + nSV[1] + ... + nSV[k-1] = l
|
23
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
package libsvm;
|
2
|
+
public class Parameter implements Cloneable,java.io.Serializable
|
3
|
+
{
|
4
|
+
/* svm_type */
|
5
|
+
public static final int C_SVC = 0;
|
6
|
+
public static final int NU_SVC = 1;
|
7
|
+
public static final int ONE_CLASS = 2;
|
8
|
+
public static final int EPSILON_SVR = 3;
|
9
|
+
public static final int NU_SVR = 4;
|
10
|
+
|
11
|
+
/* kernel_type */
|
12
|
+
public static final int LINEAR = 0;
|
13
|
+
public static final int POLY = 1;
|
14
|
+
public static final int RBF = 2;
|
15
|
+
public static final int SIGMOID = 3;
|
16
|
+
public static final int PRECOMPUTED = 4;
|
17
|
+
|
18
|
+
public int svm_type;
|
19
|
+
public int kernel_type;
|
20
|
+
public int degree; // for poly
|
21
|
+
public double gamma; // for poly/rbf/sigmoid
|
22
|
+
public double coef0; // for poly/sigmoid
|
23
|
+
|
24
|
+
// these are for training only
|
25
|
+
public double cache_size; // in MB
|
26
|
+
public double eps; // stopping criteria
|
27
|
+
public double C; // for C_SVC, EPSILON_SVR and NU_SVR
|
28
|
+
public int nr_weight; // for C_SVC
|
29
|
+
public int[] weight_label; // for C_SVC
|
30
|
+
public double[] weight; // for C_SVC
|
31
|
+
public double nu; // for NU_SVC, ONE_CLASS, and NU_SVR
|
32
|
+
public double p; // for EPSILON_SVR
|
33
|
+
public int shrinking; // use the shrinking heuristics
|
34
|
+
public int probability; // do probability estimates
|
35
|
+
|
36
|
+
public Object clone()
|
37
|
+
{
|
38
|
+
try
|
39
|
+
{
|
40
|
+
return super.clone();
|
41
|
+
} catch (CloneNotSupportedException e)
|
42
|
+
{
|
43
|
+
return null;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|