jashmenn-apriori 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/README.txt +7 -7
- data/examples/01_simple_example.rb +15 -8
- data/lib/apriori/association_rule.rb +8 -0
- data/lib/apriori/version.rb +1 -1
- data/website/index.html +31 -13
- data/website/index.txt +14 -12
- metadata +2 -2
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -68,15 +68,15 @@ This document is not an introduction to the Apriori algorithm. To find out more
|
|
68
68
|
puts rules.join("\n")
|
69
69
|
|
70
70
|
# Results:
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
71
|
+
# beer -> doritos (33.3/2, 100.0)
|
72
|
+
# doritos -> beer (50.0/3, 66.7)
|
73
|
+
# doritos -> apple (50.0/3, 33.3)
|
74
|
+
# apple -> doritos (66.7/4, 25.0)
|
75
|
+
# cheese -> apple (50.0/3, 100.0)
|
76
|
+
# apple -> cheese (66.7/4, 75.0)
|
77
77
|
|
78
78
|
# NOTE:
|
79
|
-
#
|
79
|
+
# beer -> doritos (33.3/2, 100.0)
|
80
80
|
# means:
|
81
81
|
# * beer appears in 33.3% (2 total) of the transactions (the support)
|
82
82
|
# * beer implies doritos 100% of the time (the confidence)
|
@@ -1,6 +1,13 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
2
2
|
require 'apriori'
|
3
3
|
|
4
|
+
# or alternatively:
|
5
|
+
# transactions = [ %w{apple cheese},
|
6
|
+
# %w{beer doritos},
|
7
|
+
# %w{beer doritos eggs},
|
8
|
+
# %w{beer doritos},
|
9
|
+
# %w{apple cheese} ]
|
10
|
+
|
4
11
|
transactions = [ %w{beer doritos},
|
5
12
|
%w{apple cheese},
|
6
13
|
%w{beer doritos},
|
@@ -17,16 +24,16 @@ rules = Apriori.find_association_rules(transactions,
|
|
17
24
|
|
18
25
|
puts rules.join("\n")
|
19
26
|
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
+
# Results:
|
28
|
+
# beer -> doritos (33.3/2, 100.0)
|
29
|
+
# doritos -> beer (50.0/3, 66.7)
|
30
|
+
# doritos -> apple (50.0/3, 33.3)
|
31
|
+
# apple -> doritos (66.7/4, 25.0)
|
32
|
+
# cheese -> apple (50.0/3, 100.0)
|
33
|
+
# apple -> cheese (66.7/4, 75.0)
|
27
34
|
|
28
35
|
# NOTE:
|
29
|
-
#
|
36
|
+
# beer -> doritos (33.3/2, 100.0)
|
30
37
|
# means:
|
31
38
|
# * beer appears in 33.3% (2 total) of the transactions (the support)
|
32
39
|
# * beer implies doritos 100% of the time (the confidence)
|
@@ -41,6 +41,10 @@ module Apriori
|
|
41
41
|
# Given +line+ returns an Itemset
|
42
42
|
# Example of a line:
|
43
43
|
# foo <- bar baz bangle (66.7/4, 75.0)
|
44
|
+
#
|
45
|
+
# Note that this is the opposite order of how apriori.rb returns the
|
46
|
+
# AssociationRule#to_s. (apriori.rb returns the antecedent on the left
|
47
|
+
# and consequent on the right)
|
44
48
|
def parse_line(line)
|
45
49
|
is = new
|
46
50
|
line =~ /(.+)\s+<-\s+(.+?)\s+\((\d+\.\d)(?:\/(\d+))?,\s+(\d+\.\d)\)/
|
@@ -56,6 +60,10 @@ module Apriori
|
|
56
60
|
|
57
61
|
# Returns the standard form of this rule as a string. For instance:
|
58
62
|
# bar baz bangle -> foo (66.7/4, 75.0)
|
63
|
+
# # (antecedent) (consequent)
|
64
|
+
#
|
65
|
+
# Note that this order is the opposite order of the association rules returned by apriori.c
|
66
|
+
# I believe this format reads more naturally.
|
59
67
|
def to_s
|
60
68
|
# "%s <- %s (%0.01f%s, %0.01f)" % [ consequent,
|
61
69
|
# antecedent.join(" "),
|
data/lib/apriori/version.rb
CHANGED
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>apriori</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/apriori"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/apriori" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/apriori" class="numbers">0.2.2</a>
|
37
37
|
<img src="images/2118201782_4e87521dc9_m.jpg" />
|
38
38
|
</div>
|
39
39
|
<h1>→ ‘find item associations’</h1>
|
@@ -47,7 +47,7 @@ large sets of transactions. This library provides a Ruby interface to Christian
|
|
47
47
|
Borgelt’s C implementation of this algorithm.</p>
|
48
48
|
|
49
49
|
|
50
|
-
<p>From
|
50
|
+
<p>From <a href="http://www.borgelt.net/apriori.html">Christian Borgelt’s Apriori</a> documentation:</p>
|
51
51
|
|
52
52
|
|
53
53
|
<blockquote>
|
@@ -129,15 +129,15 @@ Borgelt’s C implementation of this algorithm.</p>
|
|
129
129
|
<span class="ident">puts</span> <span class="ident">rules</span><span class="punct">.</span><span class="ident">join</span><span class="punct">("</span><span class="string"><span class="escape">\n</span></span><span class="punct">")</span>
|
130
130
|
|
131
131
|
<span class="comment"># Results: </span>
|
132
|
-
<span class="comment">#
|
133
|
-
<span class="comment">#
|
134
|
-
<span class="comment">#
|
135
|
-
<span class="comment">#
|
136
|
-
<span class="comment">#
|
137
|
-
<span class="comment">#
|
132
|
+
<span class="comment"># beer -> doritos (33.3/2, 100.0)</span>
|
133
|
+
<span class="comment"># doritos -> beer (50.0/3, 66.7)</span>
|
134
|
+
<span class="comment"># doritos -> apple (50.0/3, 33.3)</span>
|
135
|
+
<span class="comment"># apple -> doritos (66.7/4, 25.0)</span>
|
136
|
+
<span class="comment"># cheese -> apple (50.0/3, 100.0)</span>
|
137
|
+
<span class="comment"># apple -> cheese (66.7/4, 75.0)</span>
|
138
138
|
|
139
139
|
<span class="comment"># NOTE:</span>
|
140
|
-
<span class="comment">#
|
140
|
+
<span class="comment"># beer -> doritos (33.3/2, 100.0)</span>
|
141
141
|
<span class="comment"># means: </span>
|
142
142
|
<span class="comment"># * beer appears in 33.3% (2 total) of the transactions (the support)</span>
|
143
143
|
<span class="comment"># * beer implies doritos 100% of the time (the confidence)</span>
|
@@ -147,13 +147,16 @@ Borgelt’s C implementation of this algorithm.</p>
|
|
147
147
|
<p>See the <ins>examples</ins> directory for more examples of usage.</p>
|
148
148
|
|
149
149
|
|
150
|
-
<h2>
|
150
|
+
<h2>Rdoc</h2>
|
151
151
|
|
152
152
|
|
153
|
-
<p><a href="http://
|
153
|
+
<p><a href="http://apriori.rubyforge.org/rdoc/">View the rdoc here</a></p>
|
154
154
|
|
155
155
|
|
156
|
-
<
|
156
|
+
<h2>Mailing List</h2>
|
157
|
+
|
158
|
+
|
159
|
+
<p><a href="http://rubyforge.org/mail/?group_id=6948">Rubyforge Mailing List</a></p>
|
157
160
|
|
158
161
|
|
159
162
|
<h2>How to submit patches</h2>
|
@@ -173,6 +176,21 @@ Borgelt’s C implementation of this algorithm.</p>
|
|
173
176
|
rake test
|
174
177
|
rake install_gem</pre>
|
175
178
|
|
179
|
+
<h3><tt>add_development_dependency</tt> error</h3>
|
180
|
+
|
181
|
+
|
182
|
+
<p>If you get the error:</p>
|
183
|
+
|
184
|
+
|
185
|
+
<pre><code>undefined method `add_development_dependency' for #<Gem::Specification:0x2aabcba63ed8></code></pre>
|
186
|
+
|
187
|
+
|
188
|
+
<p>This is because hoe 1.7.0 requires rubygems 1.2.0. To upgrade, simply do the following:</p>
|
189
|
+
|
190
|
+
|
191
|
+
<pre><code>gem update --system</code></pre>
|
192
|
+
|
193
|
+
|
176
194
|
<h2>License</h2>
|
177
195
|
|
178
196
|
|
@@ -222,7 +240,7 @@ included in all copies or substantial portions of the Software.</p>
|
|
222
240
|
|
223
241
|
<p>Comments are welcome. Send an email to <a href="mailto:nate@natemurray.com">Nate Murray</a> via the <a href="http://groups.google.com/group/apriori">forum</a></p>
|
224
242
|
<p class="coda">
|
225
|
-
<a href="nate@natemurray.com">Nate Murray</a>,
|
243
|
+
<a href="nate@natemurray.com">Nate Murray</a>, 18th September 2008<br>
|
226
244
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
227
245
|
</p>
|
228
246
|
</div>
|
data/website/index.txt
CHANGED
@@ -9,7 +9,7 @@ Ruby Apriori is a library to efficiently find item association rules within
|
|
9
9
|
large sets of transactions. This library provides a Ruby interface to Christian
|
10
10
|
Borgelt's C implementation of this algorithm.
|
11
11
|
|
12
|
-
From Christian Borgelt's Apriori:http://www.borgelt.net/apriori.html documentation:
|
12
|
+
From "Christian Borgelt's Apriori":http://www.borgelt.net/apriori.html documentation:
|
13
13
|
|
14
14
|
bq. Association rule induction is a powerful method for so-called market basket
|
15
15
|
analysis, which aims at finding regularities in the shopping behavior of
|
@@ -68,15 +68,15 @@ h2. Demonstration of usage
|
|
68
68
|
puts rules.join("\n")
|
69
69
|
|
70
70
|
# Results:
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
71
|
+
# beer -> doritos (33.3/2, 100.0)
|
72
|
+
# doritos -> beer (50.0/3, 66.7)
|
73
|
+
# doritos -> apple (50.0/3, 33.3)
|
74
|
+
# apple -> doritos (66.7/4, 25.0)
|
75
|
+
# cheese -> apple (50.0/3, 100.0)
|
76
|
+
# apple -> cheese (66.7/4, 75.0)
|
77
77
|
|
78
78
|
# NOTE:
|
79
|
-
#
|
79
|
+
# beer -> doritos (33.3/2, 100.0)
|
80
80
|
# means:
|
81
81
|
# * beer appears in 33.3% (2 total) of the transactions (the support)
|
82
82
|
# * beer implies doritos 100% of the time (the confidence)
|
@@ -84,11 +84,13 @@ h2. Demonstration of usage
|
|
84
84
|
|
85
85
|
See the +examples+ directory for more examples of usage.
|
86
86
|
|
87
|
-
h2.
|
87
|
+
h2. Rdoc
|
88
88
|
|
89
|
-
"
|
89
|
+
"View the rdoc here":http://apriori.rubyforge.org/rdoc/
|
90
90
|
|
91
|
-
|
91
|
+
h2. Mailing List
|
92
|
+
|
93
|
+
"Rubyforge Mailing List":http://rubyforge.org/mail/?group_id=6948
|
92
94
|
|
93
95
|
h2. How to submit patches
|
94
96
|
|
@@ -102,7 +104,7 @@ h3. Build and test instructions
|
|
102
104
|
rake test
|
103
105
|
rake install_gem</pre>
|
104
106
|
|
105
|
-
h3.
|
107
|
+
h3. <tt>add_development_dependency</tt> error
|
106
108
|
|
107
109
|
If you get the error:
|
108
110
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jashmenn-apriori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Murray
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-18 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|