feature_selection 0.0.2 → 0.0.3
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/README.rdoc +3 -3
- data/VERSION +1 -1
- data/feature_selection.gemspec +2 -2
- data/lib/feature_selection/base.rb +25 -1
- data/lib/feature_selection/log_helpers.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -6,7 +6,7 @@ http://en.wikipedia.org/wiki/Feature_selection
|
|
6
6
|
|
7
7
|
== Install
|
8
8
|
|
9
|
-
gem sources -a http://
|
9
|
+
gem sources -a http://gemcutter.org
|
10
10
|
sudo gem install feature_selection
|
11
11
|
|
12
12
|
== How To Use
|
@@ -35,9 +35,9 @@ Example:
|
|
35
35
|
|
36
36
|
== Logging
|
37
37
|
|
38
|
-
There are two ways to log the activity
|
38
|
+
There are two ways to log the activity:
|
39
39
|
|
40
|
-
# Provide a path
|
40
|
+
# Provide a path of somewhere to log to
|
41
41
|
log = File.expand_path(File.dirname(__FILE__) + '/log.txt')
|
42
42
|
FeatureSelection::MutualInformation.new(data, :log_to => log)
|
43
43
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/feature_selection.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{feature_selection}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["reddavis"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-18}
|
13
13
|
s.description = %q{A library of feature selection algorithms}
|
14
14
|
s.email = %q{reddavis@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -21,15 +21,21 @@ module FeatureSelection
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def pre_compute_n_1_1
|
24
|
+
write_to_log("Pre-Computing N11")
|
24
25
|
results = {}
|
25
26
|
|
27
|
+
# Logger
|
28
|
+
n = 1
|
29
|
+
|
26
30
|
classes.each do |q_klass|
|
27
31
|
results[q_klass] = {}
|
28
32
|
|
29
33
|
uniq_terms.each do |term|
|
34
|
+
log_calculations_complete(n, '--N11--')
|
35
|
+
n += 1
|
30
36
|
count = 0.0
|
31
37
|
|
32
|
-
@data.each_pair do |klass, documents|
|
38
|
+
@data.each_pair do |klass, documents|
|
33
39
|
if klass == q_klass
|
34
40
|
documents.each do |document|
|
35
41
|
count += 1 if document.include?(term)
|
@@ -53,12 +59,18 @@ module FeatureSelection
|
|
53
59
|
|
54
60
|
# Pre-Computer n_1_0
|
55
61
|
def pre_compute_n_1_0
|
62
|
+
write_to_log("Pre-Computing N10")
|
56
63
|
results = {}
|
57
64
|
|
65
|
+
# Logger
|
66
|
+
n = 1
|
67
|
+
|
58
68
|
classes.each do |q_klass|
|
59
69
|
results[q_klass] = {}
|
60
70
|
|
61
71
|
uniq_terms.each do |term|
|
72
|
+
log_calculations_complete(n, '--N10--')
|
73
|
+
n += 1
|
62
74
|
count = 0.0
|
63
75
|
|
64
76
|
@data.each_pair do |klass, documents|
|
@@ -85,12 +97,18 @@ module FeatureSelection
|
|
85
97
|
|
86
98
|
# Pre-Computer n_0_1
|
87
99
|
def pre_compute_n_0_1
|
100
|
+
write_to_log("Pre-Computing N01")
|
88
101
|
results = {}
|
89
102
|
|
103
|
+
# Logger
|
104
|
+
n = 1
|
105
|
+
|
90
106
|
classes.each do |q_klass|
|
91
107
|
results[q_klass] = {}
|
92
108
|
|
93
109
|
uniq_terms.each do |term|
|
110
|
+
log_calculations_complete(n, '--N01--')
|
111
|
+
n += 1
|
94
112
|
count = 0.0
|
95
113
|
|
96
114
|
@data.each_pair do |klass, documents|
|
@@ -117,12 +135,18 @@ module FeatureSelection
|
|
117
135
|
|
118
136
|
# Pre-Computes all n_0_0 queries
|
119
137
|
def pre_compute_n_0_0
|
138
|
+
write_to_log("Pre-Computing N00")
|
120
139
|
results = {}
|
121
140
|
|
141
|
+
# Logger
|
142
|
+
n = 1
|
143
|
+
|
122
144
|
classes.each do |q_klass|
|
123
145
|
results[q_klass] = {}
|
124
146
|
|
125
147
|
uniq_terms.each do |term|
|
148
|
+
log_calculations_complete(n, '--N00--')
|
149
|
+
n += 1
|
126
150
|
count = 0.0
|
127
151
|
|
128
152
|
@data.each_pair do |klass, documents|
|
@@ -19,7 +19,7 @@ module LogHelpers
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Writes the number of calculations completed to the log
|
22
|
-
def log_calculations_complete(n)
|
23
|
-
write_to_log("#{n}/#{total_calculations} calculations complete.")
|
22
|
+
def log_calculations_complete(n, other_text='')
|
23
|
+
write_to_log("#{n}/#{total_calculations} #{other_text} calculations complete.")
|
24
24
|
end
|
25
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,7 @@ require 'spec/autorun'
|
|
6
6
|
|
7
7
|
def data
|
8
8
|
{
|
9
|
-
:spam => [['this', 'is', 'some', 'yer', 'information'], ['this', 'is', 'something', 'that', 'is', 'information']],
|
9
|
+
:spam => [['this', 'is', 'this', 'some', 'yer', 'information'], ['this', 'is', 'something', 'that', 'is', 'information']],
|
10
10
|
:ham => [['this', 'test', 'some', 'more', 'information'], ['there', 'are', 'some', 'things']],
|
11
11
|
}
|
12
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_selection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- reddavis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-18 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|