bio-band 0.1.0
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/Gemfile +20 -0
- data/Gemfile.lock +79 -0
- data/Jarfile +9 -0
- data/Jarfile.lock +10 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +54 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/bio-band +83 -0
- data/bio-band.gemspec +129 -0
- data/ext/mkrf_conf.rb +74 -0
- data/features/create_dataset.feature +12 -0
- data/features/step_definitions/create_dataset.rb +40 -0
- data/features/step_definitions/weka_classifiers.rb +42 -0
- data/features/step_definitions/weka_clustering.rb +30 -0
- data/features/step_definitions/weka_filters.rb +29 -0
- data/features/step_definitions/weka_parsers.rb +45 -0
- data/features/support/env.rb +3 -0
- data/features/weka_classifiers.feature +16 -0
- data/features/weka_clustering.feature +14 -0
- data/features/weka_filters.feature +12 -0
- data/features/weka_parsers.feature +18 -0
- data/features/weka_pipeline.feature +13 -0
- data/lib/bio-band.rb +10 -0
- data/lib/bio-band/apache.rb +1 -0
- data/lib/bio-band/apache/stat/inference.rb +145 -0
- data/lib/bio-band/core.rb +6 -0
- data/lib/bio-band/core/parser/parser.rb +23 -0
- data/lib/bio-band/core/type/apache_matrices.rb +35 -0
- data/lib/bio-band/core/type/attribute.rb +53 -0
- data/lib/bio-band/core/type/instance.rb +10 -0
- data/lib/bio-band/core/type/instances.rb +332 -0
- data/lib/bio-band/core/type/utils.rb +31 -0
- data/lib/bio-band/weka.rb +11 -0
- data/lib/bio-band/weka/classifiers/bayes/bayes.rb +75 -0
- data/lib/bio-band/weka/classifiers/bayes/bayes_utils.rb +42 -0
- data/lib/bio-band/weka/classifiers/evaluation.rb +12 -0
- data/lib/bio-band/weka/classifiers/functions/functions.rb +23 -0
- data/lib/bio-band/weka/classifiers/functions/functions_utils.rb +39 -0
- data/lib/bio-band/weka/classifiers/lazy/lazy.rb +23 -0
- data/lib/bio-band/weka/classifiers/lazy/lazy_utils.rb +39 -0
- data/lib/bio-band/weka/classifiers/trees/trees.rb +48 -0
- data/lib/bio-band/weka/classifiers/trees/trees_utils.rb +42 -0
- data/lib/bio-band/weka/clusterers/clusterers.rb +32 -0
- data/lib/bio-band/weka/clusterers/clusterers_utils.rb +49 -0
- data/lib/bio-band/weka/db/DatabaseUtils_mysql +280 -0
- data/lib/bio-band/weka/db/DatabaseUtils_postgresql +594 -0
- data/lib/bio-band/weka/db/db.rb +74 -0
- data/lib/bio-band/weka/filters/supervised/attribute/attribute.rb +25 -0
- data/lib/bio-band/weka/filters/supervised/instance/instance.rb +17 -0
- data/lib/bio-band/weka/filters/supervised/supervised_utils.rb +32 -0
- data/lib/bio-band/weka/filters/unsupervised/attribute/attribute.rb +70 -0
- data/lib/bio-band/weka/filters/unsupervised/instance/instance.rb +48 -0
- data/lib/bio-band/weka/filters/unsupervised/unsupervised_utils.rb +33 -0
- data/resources/weather.csv +15 -0
- data/resources/weather.numeric.arff +23 -0
- data/spec/bio-band_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +302 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
module Core
|
4
|
+
module Utils
|
5
|
+
|
6
|
+
# Convert a bidimensional RubyArray to a java double [][]
|
7
|
+
def Utils.bidimensional_to_double(ruby_array)
|
8
|
+
ruby_array.to_java Java::double[]
|
9
|
+
end
|
10
|
+
|
11
|
+
def Utils.bidimensional_to_long(ruby_array)
|
12
|
+
ruby_array.to_java Java::long[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def Utils.double_to_a(java_array)
|
16
|
+
ruby_array = []
|
17
|
+
java_array.each {|val| ruby_array << val}
|
18
|
+
ruby_array
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Array
|
25
|
+
def is_2d?
|
26
|
+
self.each do |item|
|
27
|
+
return true if item.is_a? Array
|
28
|
+
end
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'ruby_mining/weka/db/db'
|
2
|
+
require 'ruby_mining/weka/filters/unsupervised/attribute/attribute.rb'
|
3
|
+
require 'ruby_mining/weka/filters/unsupervised/instance/instance.rb'
|
4
|
+
require 'ruby_mining/weka/filters/supervised/instance/instance.rb'
|
5
|
+
require 'ruby_mining/weka/filters/supervised/attribute/attribute.rb'
|
6
|
+
require 'ruby_mining/weka/classifiers/bayes/bayes.rb'
|
7
|
+
require 'ruby_mining/weka/classifiers/evaluation.rb'
|
8
|
+
require 'ruby_mining/weka/classifiers/functions/functions.rb'
|
9
|
+
require 'ruby_mining/weka/classifiers/trees/trees.rb'
|
10
|
+
require 'ruby_mining/weka/classifiers/lazy/lazy.rb'
|
11
|
+
require 'ruby_mining/weka/clusterers/clusterers.rb'
|
@@ -0,0 +1,75 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'bayes_utils'
|
3
|
+
|
4
|
+
module Weka
|
5
|
+
module Classifier
|
6
|
+
module Bayes
|
7
|
+
java_import "weka.classifiers.bayes.NaiveBayes"
|
8
|
+
java_import "weka.classifiers.bayes.BayesianLogisticRegression"
|
9
|
+
java_import "weka.classifiers.bayes.AODE"
|
10
|
+
java_import "weka.classifiers.bayes.ComplementNaiveBayes"
|
11
|
+
java_import "weka.classifiers.bayes.WAODE"
|
12
|
+
|
13
|
+
class NaiveBayes
|
14
|
+
include Bayes_utils
|
15
|
+
class Base < NaiveBayes
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
set_options(self.class.options) if self.class.options
|
19
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
20
|
+
buildClassifier(self.class.data)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class AODE
|
26
|
+
include Bayes_utils
|
27
|
+
class Base < AODE
|
28
|
+
def initialize
|
29
|
+
super
|
30
|
+
set_options(self.class.options) if self.class.options
|
31
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
32
|
+
buildClassifier(self.class.data)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class BayesianLogisticRegression
|
38
|
+
include Bayes_utils
|
39
|
+
class Base < BayesianLogisticRegression
|
40
|
+
def initialize
|
41
|
+
super
|
42
|
+
set_options(self.class.options) if self.class.options
|
43
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
44
|
+
buildClassifier(self.class.data)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class ComplementNaiveBayes
|
50
|
+
include Bayes_utils
|
51
|
+
class Base < ComplementNaiveBayes
|
52
|
+
def initialize
|
53
|
+
super
|
54
|
+
set_options(self.class.options) if self.class.options
|
55
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
56
|
+
buildClassifier(self.class.data)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class WAODE
|
62
|
+
include Bayes_utils
|
63
|
+
class Base < WAODE
|
64
|
+
def initialize
|
65
|
+
super
|
66
|
+
set_options(self.class.options) if self.class.options
|
67
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
68
|
+
buildClassifier(self.class.data)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#This module is used by the Bayesian classifiers from 'bayes.rb'
|
2
|
+
#to inherit the following methods (instance and class methods)
|
3
|
+
module Bayes_utils
|
4
|
+
java_import "weka.core.Utils"
|
5
|
+
|
6
|
+
#Instance methods list
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_options(options)
|
12
|
+
options_inst = Utils.splitOptions(options)
|
13
|
+
setOptions(options_inst)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_options
|
17
|
+
listOptions.each {|key| puts "#{key.synopsis} #{key.description}"}
|
18
|
+
end
|
19
|
+
|
20
|
+
def description
|
21
|
+
puts globalInfo
|
22
|
+
end
|
23
|
+
|
24
|
+
#Class methods module
|
25
|
+
module ClassMethods
|
26
|
+
|
27
|
+
def self.classifier_attr_accessor(*args)
|
28
|
+
args.each do |arg|
|
29
|
+
#Here's the getter
|
30
|
+
self.class_eval("def #{arg};@#{arg};end")
|
31
|
+
#Here's the setter
|
32
|
+
self.class_eval("def set_#{arg}(val);@#{arg}=val;end")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
classifier_attr_accessor :options,:data,:class_index
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'functions_utils'
|
3
|
+
|
4
|
+
module Weka
|
5
|
+
module Classifier
|
6
|
+
module Functions
|
7
|
+
java_import 'weka.classifiers.functions.LinearRegression'
|
8
|
+
|
9
|
+
class LinearRegression
|
10
|
+
include Functions_utils
|
11
|
+
class Base < LinearRegression
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
set_options(self.class.options) if self.class.options
|
15
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
16
|
+
buildClassifier(self.class.data)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#This module is used by the 'functions' classifiers from 'functions.rb'
|
2
|
+
#to inherit the following methods (instance and class methods)
|
3
|
+
module Functions_utils
|
4
|
+
java_import "weka.core.Utils"
|
5
|
+
|
6
|
+
#Instance methods list
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_options(options)
|
12
|
+
options_inst = Utils.splitOptions(options)
|
13
|
+
setOptions(options_inst)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_options
|
17
|
+
listOptions.each {|key| puts "#{key.synopsis} #{key.description}"}
|
18
|
+
end
|
19
|
+
|
20
|
+
def description
|
21
|
+
puts globalInfo
|
22
|
+
end
|
23
|
+
|
24
|
+
#Class methods module
|
25
|
+
module ClassMethods
|
26
|
+
|
27
|
+
def self.classifier_attr_accessor(*args)
|
28
|
+
args.each do |arg|
|
29
|
+
#Here's the getter
|
30
|
+
self.class_eval("def #{arg};@#{arg};end")
|
31
|
+
#Here's the setter
|
32
|
+
self.class_eval("def set_#{arg}(val);@#{arg}=val;end")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
classifier_attr_accessor :options,:data,:class_index
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'lazy_utils'
|
3
|
+
|
4
|
+
module Weka
|
5
|
+
module Classifier
|
6
|
+
module Lazy
|
7
|
+
|
8
|
+
java_import 'weka.classifiers.lazy.KStar'
|
9
|
+
|
10
|
+
class KStar
|
11
|
+
include Lazy_utils
|
12
|
+
class Base < KStar
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
set_options(self.class.options) if self.class.options
|
16
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
17
|
+
buildClassifier(self.class.data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#This module is used by the 'lazy' classifiers from 'lazy.rb'
|
2
|
+
#to inherit the following methods (instance and class methods)
|
3
|
+
module Lazy_utils
|
4
|
+
java_import "weka.core.Utils"
|
5
|
+
|
6
|
+
#Instance methods list
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_options(options)
|
12
|
+
options_inst = Utils.splitOptions(options)
|
13
|
+
setOptions(options_inst)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_options
|
17
|
+
listOptions.each {|key| puts "#{key.synopsis} #{key.description}"}
|
18
|
+
end
|
19
|
+
|
20
|
+
def description
|
21
|
+
puts globalInfo
|
22
|
+
end
|
23
|
+
|
24
|
+
#Class methods module
|
25
|
+
module ClassMethods
|
26
|
+
|
27
|
+
def self.classifier_attr_accessor(*args)
|
28
|
+
args.each do |arg|
|
29
|
+
#Here's the getter
|
30
|
+
self.class_eval("def #{arg};@#{arg};end")
|
31
|
+
#Here's the setter
|
32
|
+
self.class_eval("def set_#{arg}(val);@#{arg}=val;end")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
classifier_attr_accessor :options,:data,:class_index
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'trees_utils'
|
3
|
+
|
4
|
+
module Weka
|
5
|
+
module Classifier
|
6
|
+
module Trees
|
7
|
+
java_import 'weka.classifiers.trees.J48'
|
8
|
+
java_import 'weka.classifiers.trees.RandomForest'
|
9
|
+
|
10
|
+
class FT
|
11
|
+
include Trees_utils
|
12
|
+
class Base < FT
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
set_options(self.class.options) if self.class.options
|
16
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
17
|
+
buildClassifier(self.class.data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class J48
|
23
|
+
include Trees_utils
|
24
|
+
class Base < J48
|
25
|
+
def initialize
|
26
|
+
super
|
27
|
+
set_options(self.class.options) if self.class.options
|
28
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
29
|
+
buildClassifier(self.class.data)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class RandomForest
|
35
|
+
include Trees_utils
|
36
|
+
class Base < RandomForest
|
37
|
+
def initialize
|
38
|
+
super
|
39
|
+
set_options(self.class.options) if self.class.options
|
40
|
+
self.class.data.setClassIndex(self.class.class_index) if self.class.class_index
|
41
|
+
buildClassifier(self.class.data)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#This module is used by the 'trees' classifiers from 'trees.rb'
|
2
|
+
#to inherit the following methods (instance and class methods)
|
3
|
+
module Trees_utils
|
4
|
+
java_import "weka.core.Utils"
|
5
|
+
|
6
|
+
#Instance methods list
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_options(options)
|
12
|
+
options_inst = Utils.splitOptions(options)
|
13
|
+
setOptions(options_inst)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_options
|
17
|
+
listOptions.each {|key| puts "#{key.synopsis} #{key.description}"}
|
18
|
+
end
|
19
|
+
|
20
|
+
def description
|
21
|
+
puts globalInfo
|
22
|
+
end
|
23
|
+
|
24
|
+
#Class methods module
|
25
|
+
module ClassMethods
|
26
|
+
|
27
|
+
def self.classifier_attr_accessor(*args)
|
28
|
+
args.each do |arg|
|
29
|
+
#Here's the getter
|
30
|
+
self.class_eval("def #{arg};@#{arg};end")
|
31
|
+
#Here's the setter
|
32
|
+
self.class_eval("def set_#{arg}(val);@#{arg}=val;end")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
classifier_attr_accessor :options,:data,:class_index
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'clusterers_utils'
|
3
|
+
|
4
|
+
module Weka
|
5
|
+
module Clusterer
|
6
|
+
java_import 'weka.clusterers.SimpleKMeans'
|
7
|
+
java_import 'weka.clusterers.FarthestFirst'
|
8
|
+
|
9
|
+
class SimpleKMeans
|
10
|
+
include Clusterer_utils
|
11
|
+
class Base < SimpleKMeans
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
set_options(self.class.options) if self.class.options
|
15
|
+
buildClusterer(self.class.data)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class FarthestFirst
|
21
|
+
include Clusterer_utils
|
22
|
+
class Base < FarthestFirst
|
23
|
+
def initialize
|
24
|
+
super
|
25
|
+
set_options(self.class.options) if self.class.options
|
26
|
+
buildClusterer(self.class.data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#This module is used by the classes from the Clusterer module
|
2
|
+
#to inherit the following methods (instance and class methods)
|
3
|
+
module Clusterer_utils
|
4
|
+
java_import "weka.core.Utils"
|
5
|
+
|
6
|
+
#Instance methods list
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_options(options)
|
12
|
+
options_inst = Utils.splitOptions(options)
|
13
|
+
setOptions(options_inst)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_options
|
17
|
+
options = ''
|
18
|
+
listOptions.each {|key| options="#{options}\n#{key.synopsis} #{key.description}"}
|
19
|
+
options
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
globalInfo
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_centroids
|
27
|
+
getClusterCentroids
|
28
|
+
end
|
29
|
+
|
30
|
+
def list_capabilities
|
31
|
+
get_capabilities.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
#Class methods module
|
35
|
+
module ClassMethods
|
36
|
+
|
37
|
+
def self.classifier_attr_accessor(*args)
|
38
|
+
args.each do |arg|
|
39
|
+
#Here's the getter
|
40
|
+
self.class_eval("def #{arg};@#{arg};end")
|
41
|
+
#Here's the setter
|
42
|
+
self.class_eval("def set_#{arg}(val);@#{arg}=val;end")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
classifier_attr_accessor :options,:data
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|