fastout 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.gitignore +4 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +38 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +8 -0
  7. data/Rakefile +2 -0
  8. data/doc/classes/Fastout.html +105 -0
  9. data/doc/classes/Ranker.html +468 -0
  10. data/doc/classes/Ranker.src/M000001.html +18 -0
  11. data/doc/classes/Ranker.src/M000002.html +22 -0
  12. data/doc/classes/Ranker.src/M000003.html +42 -0
  13. data/doc/classes/Ranker.src/M000004.html +21 -0
  14. data/doc/classes/Ranker.src/M000005.html +28 -0
  15. data/doc/classes/Ranker.src/M000006.html +35 -0
  16. data/doc/classes/Ranker.src/M000007.html +18 -0
  17. data/doc/classes/Ranker.src/M000008.html +18 -0
  18. data/doc/classes/Ranker.src/M000009.html +33 -0
  19. data/doc/classes/Ranker.src/M000010.html +18 -0
  20. data/doc/classes/Ranker.src/M000011.html +22 -0
  21. data/doc/classes/Ranker.src/M000012.html +24 -0
  22. data/doc/classes/Ranker.src/M000013.html +28 -0
  23. data/doc/classes/Ranker.src/M000014.html +20 -0
  24. data/doc/classes/Ranker.src/M000015.html +19 -0
  25. data/doc/classes/Ranker/Point.html +262 -0
  26. data/doc/classes/Ranker/Point.src/M000016.html +18 -0
  27. data/doc/classes/Ranker/Point.src/M000017.html +24 -0
  28. data/doc/classes/Ranker/Point.src/M000018.html +18 -0
  29. data/doc/classes/Ranker/Point.src/M000019.html +18 -0
  30. data/doc/classes/Ranker/Point.src/M000020.html +18 -0
  31. data/doc/classes/Ranker/Point.src/M000021.html +26 -0
  32. data/doc/classes/Ranker/Point.src/M000022.html +18 -0
  33. data/doc/created.rid +1 -0
  34. data/doc/files/lib/fastout/ranker_rb.html +121 -0
  35. data/doc/files/lib/fastout/version_rb.html +101 -0
  36. data/doc/files/lib/fastout_rb.html +108 -0
  37. data/doc/files/spec/fastout/ranker_spec_rb.html +109 -0
  38. data/doc/files/spec/spec_helper_rb.html +110 -0
  39. data/doc/fr_class_index.html +29 -0
  40. data/doc/fr_file_index.html +28 -0
  41. data/doc/fr_method_index.html +48 -0
  42. data/doc/index.html +24 -0
  43. data/doc/rdoc-style.css +208 -0
  44. data/fastout.gemspec +29 -0
  45. data/lib/fastout.rb +1 -0
  46. data/lib/fastout/ranker.rb +243 -0
  47. data/lib/fastout/version.rb +3 -0
  48. data/spec/fastout/ranker_spec.rb +252 -0
  49. data/spec/parkinsons.csv +1 -0
  50. data/spec/spec_helper.rb +9 -0
  51. metadata +217 -0
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>pointify (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 63</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pointify</span> <span class="ruby-identifier">data</span>
15
+ <span class="ruby-identifier">data</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">attributes</span><span class="ruby-operator">|</span> <span class="ruby-constant">Point</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">*</span><span class="ruby-identifier">attributes</span> }
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 71</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">data</span>
15
+ <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;data must have more than one attribute and more than one data point&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
16
+ <span class="ruby-ivar">@data</span> = <span class="ruby-identifier">data</span>
17
+ <span class="ruby-ivar">@points</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">pointify</span> <span class="ruby-identifier">data</span>
18
+ <span class="ruby-ivar">@minimums</span>, <span class="ruby-ivar">@maximums</span> = <span class="ruby-identifier">compute_minimums_and_maximums</span>
19
+ <span class="ruby-constant">Point</span>.<span class="ruby-identifier">next_id</span> = <span class="ruby-value">0</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>optimized_ranking (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 83</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">optimized_ranking</span> <span class="ruby-identifier">sample</span>, <span class="ruby-identifier">n</span>, <span class="ruby-identifier">theta_target</span>=<span class="ruby-value">1</span>
15
+ <span class="ruby-identifier">k</span> = <span class="ruby-value">3</span>
16
+ <span class="ruby-identifier">q</span> = <span class="ruby-value">5</span>
17
+ <span class="ruby-identifier">max_q</span> = <span class="ruby-identifier">n</span> <span class="ruby-operator">/</span> <span class="ruby-value">4</span>
18
+ <span class="ruby-identifier">step_q</span> = <span class="ruby-value">10</span>
19
+ <span class="ruby-identifier">last_theta</span> = <span class="ruby-identifier">n</span>
20
+ <span class="ruby-identifier">theta</span>, <span class="ruby-identifier">s</span> = <span class="ruby-identifier">calculate_theta</span>(<span class="ruby-identifier">sample</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">n</span>, <span class="ruby-identifier">q</span>)
21
+
22
+ <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">theta</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">theta_target</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">theta</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">last_theta</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">q</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">max_q</span>) <span class="ruby-keyword kw">do</span>
23
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">theta</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">theta_target</span>)
24
+
25
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">theta</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">last_theta</span>)
26
+ <span class="ruby-comment cmt"># effectiveness declining so try next k</span>
27
+ <span class="ruby-identifier">k</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
28
+ <span class="ruby-identifier">q</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">step_q</span>
29
+ <span class="ruby-identifier">last_theta</span> = <span class="ruby-identifier">n</span>
30
+ <span class="ruby-keyword kw">else</span>
31
+ <span class="ruby-comment cmt"># try next q</span>
32
+ <span class="ruby-identifier">q</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">step_q</span>
33
+ <span class="ruby-identifier">last_theta</span> = <span class="ruby-identifier">theta</span>
34
+ <span class="ruby-keyword kw">end</span>
35
+
36
+ <span class="ruby-identifier">theta</span>, <span class="ruby-identifier">s</span> = <span class="ruby-identifier">calculate_theta</span>(<span class="ruby-identifier">sample</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">n</span>, <span class="ruby-identifier">q</span>)
37
+ <span class="ruby-keyword kw">end</span>
38
+
39
+ <span class="ruby-identifier">s</span>
40
+ <span class="ruby-keyword kw">end</span></pre>
41
+ </body>
42
+ </html>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>calculate_theta (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 113</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calculate_theta</span> <span class="ruby-identifier">sample</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">n</span>, <span class="ruby-identifier">q</span>
15
+ <span class="ruby-identifier">s</span> = <span class="ruby-identifier">ranked_outliers</span> <span class="ruby-identifier">sample</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">q</span>
16
+ <span class="ruby-identifier">theta</span> = <span class="ruby-identifier">points</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">sum</span>, <span class="ruby-identifier">point</span><span class="ruby-operator">|</span> <span class="ruby-identifier">point</span>.<span class="ruby-identifier">score</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">n</span> <span class="ruby-value">? </span><span class="ruby-identifier">sum</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">sum</span> }
17
+
18
+ [<span class="ruby-identifier">theta</span>, <span class="ruby-identifier">s</span>]
19
+ <span class="ruby-keyword kw">end</span></pre>
20
+ </body>
21
+ </html>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>ranked_outliers (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 122</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ranked_outliers</span> <span class="ruby-identifier">sample_size</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">q</span>
15
+ <span class="ruby-comment cmt"># determine number of bins and their widths</span>
16
+ <span class="ruby-identifier">bin_count</span> = <span class="ruby-identifier">compute_bin_count</span>(<span class="ruby-identifier">q</span>)
17
+ <span class="ruby-identifier">bin_widths</span> = <span class="ruby-identifier">compute_bin_widths</span>(<span class="ruby-identifier">q</span>, <span class="ruby-identifier">bin_count</span>)
18
+
19
+ <span class="ruby-comment cmt"># assign points to the attribute bins</span>
20
+ <span class="ruby-identifier">assign_points_to_bins!</span> <span class="ruby-identifier">bin_widths</span>, <span class="ruby-identifier">bin_count</span>
21
+
22
+ <span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-identifier">sample_size</span>) {
23
+ <span class="ruby-identifier">score_points_from_a_random_set_of_attributes!</span> <span class="ruby-identifier">k</span>, <span class="ruby-identifier">bin_widths</span> }
24
+
25
+ <span class="ruby-identifier">points</span>.<span class="ruby-identifier">sort_by</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:score</span>).<span class="ruby-identifier">reverse</span>
26
+ <span class="ruby-keyword kw">end</span></pre>
27
+ </body>
28
+ </html>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>score_points_from_a_random_set_of_attributes! (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 138</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">score_points_from_a_random_set_of_attributes!</span> <span class="ruby-identifier">number_of_attributes_to_choose</span>, <span class="ruby-identifier">all_bin_widths</span>
15
+ <span class="ruby-identifier">cluster</span> = <span class="ruby-value">0</span>
16
+ <span class="ruby-identifier">attribute_indexes</span> = <span class="ruby-identifier">random_attribute_indexes</span> <span class="ruby-identifier">number_of_attributes_to_choose</span>
17
+ <span class="ruby-identifier">bin_widths</span> = <span class="ruby-identifier">attribute_indexes</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">index</span><span class="ruby-operator">|</span> <span class="ruby-identifier">all_bin_widths</span>[<span class="ruby-identifier">index</span>] }
18
+
19
+ <span class="ruby-identifier">points</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">point</span><span class="ruby-operator">|</span>
20
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">point</span>.<span class="ruby-identifier">clustered?</span>
21
+
22
+ <span class="ruby-identifier">point</span>.<span class="ruby-identifier">cluster</span> = (<span class="ruby-identifier">cluster</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>)
23
+ <span class="ruby-identifier">neighbors</span> = <span class="ruby-identifier">cluster_neighbors</span> <span class="ruby-identifier">point</span>, <span class="ruby-identifier">cluster</span>, <span class="ruby-identifier">attribute_indexes</span>, <span class="ruby-identifier">bin_widths</span>
24
+
25
+ <span class="ruby-identifier">point</span>.<span class="ruby-identifier">uncluster!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">neighbors</span>.<span class="ruby-identifier">empty?</span>
26
+ <span class="ruby-keyword kw">end</span>
27
+
28
+ <span class="ruby-identifier">points</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">point</span><span class="ruby-operator">|</span>
29
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">point</span>.<span class="ruby-identifier">clustered?</span>
30
+ <span class="ruby-identifier">point</span>.<span class="ruby-identifier">uncluster!</span>
31
+ <span class="ruby-identifier">point</span>.<span class="ruby-identifier">score</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
32
+ <span class="ruby-keyword kw">end</span>
33
+ <span class="ruby-keyword kw">end</span></pre>
34
+ </body>
35
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>random_attribute_indexes (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 160</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">random_attribute_indexes</span> <span class="ruby-identifier">number</span>
15
+ (<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-ivar">@data</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span>).<span class="ruby-identifier">sort_by</span> { <span class="ruby-identifier">rand</span> }[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">number</span>]
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>cluster_neighbors (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 167</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cluster_neighbors</span> <span class="ruby-identifier">point</span>, <span class="ruby-identifier">cluster</span>, <span class="ruby-identifier">attribute_indexes</span>, <span class="ruby-identifier">bin_widths</span>
15
+ <span class="ruby-identifier">recursively_cluster_neighbors</span> <span class="ruby-identifier">point</span>, <span class="ruby-identifier">cluster</span>, <span class="ruby-identifier">attribute_indexes</span>, <span class="ruby-identifier">bin_widths</span>, []
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>recursively_cluster_neighbors (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 172</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recursively_cluster_neighbors</span> <span class="ruby-identifier">point</span>, <span class="ruby-identifier">cluster</span>, <span class="ruby-identifier">attribute_indexes</span>, <span class="ruby-identifier">bin_widths</span>, <span class="ruby-identifier">neighbors</span>
15
+ <span class="ruby-identifier">fruitful</span> = <span class="ruby-keyword kw">false</span>
16
+
17
+ <span class="ruby-identifier">unclustered_points</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">unclustered_point</span><span class="ruby-operator">|</span>
18
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">point</span>.<span class="ruby-identifier">in_the_neighborhood_of?</span>(<span class="ruby-identifier">unclustered_point</span>, <span class="ruby-identifier">attribute_indexes</span>, <span class="ruby-identifier">bin_widths</span>) <span class="ruby-keyword kw">or</span>
19
+ <span class="ruby-identifier">unclustered_point</span>.<span class="ruby-identifier">neighbor_of_any?</span>(<span class="ruby-identifier">neighbors</span>, <span class="ruby-identifier">attribute_indexes</span>, <span class="ruby-identifier">bin_widths</span>)
20
+
21
+ <span class="ruby-identifier">fruitful</span> = <span class="ruby-keyword kw">true</span>
22
+ <span class="ruby-identifier">unclustered_point</span>.<span class="ruby-identifier">cluster</span> = <span class="ruby-identifier">cluster</span>
23
+ <span class="ruby-identifier">neighbors</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">unclustered_point</span>
24
+ <span class="ruby-keyword kw">end</span>
25
+
26
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fruitful</span>
27
+ <span class="ruby-identifier">recursively_cluster_neighbors</span> <span class="ruby-identifier">point</span>, <span class="ruby-identifier">cluster</span>, <span class="ruby-identifier">attribute_indexes</span>, <span class="ruby-identifier">bin_widths</span>, <span class="ruby-identifier">neighbors</span>
28
+ <span class="ruby-keyword kw">else</span>
29
+ <span class="ruby-identifier">neighbors</span>
30
+ <span class="ruby-keyword kw">end</span>
31
+ <span class="ruby-keyword kw">end</span></pre>
32
+ </body>
33
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>unclustered_points (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 192</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unclustered_points</span>
15
+ <span class="ruby-identifier">points</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">point</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">point</span>.<span class="ruby-identifier">clustered?</span> }
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>assign_points_to_bins! (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 198</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assign_points_to_bins!</span> <span class="ruby-identifier">bin_widths</span>, <span class="ruby-identifier">bin_count</span>
15
+ <span class="ruby-identifier">bin_widths</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">bin_width</span>, <span class="ruby-identifier">attribute_index</span><span class="ruby-operator">|</span>
16
+ <span class="ruby-identifier">points</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">point</span><span class="ruby-operator">|</span>
17
+ <span class="ruby-identifier">point</span>.<span class="ruby-identifier">bins</span>[<span class="ruby-identifier">attribute_index</span>] = <span class="ruby-identifier">bin_index</span>(<span class="ruby-identifier">point</span>, <span class="ruby-identifier">attribute_index</span>, <span class="ruby-identifier">bin_width</span>)
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-keyword kw">end</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>bin_index (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 206</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bin_index</span> <span class="ruby-identifier">point</span>, <span class="ruby-identifier">attribute_index</span>, <span class="ruby-identifier">bin_width</span>
15
+ <span class="ruby-identifier">minimum</span> = <span class="ruby-ivar">@minimums</span>[<span class="ruby-identifier">attribute_index</span>]
16
+ <span class="ruby-identifier">maximum</span> = <span class="ruby-ivar">@maximums</span>[<span class="ruby-identifier">attribute_index</span>]
17
+
18
+ <span class="ruby-identifier">value</span> = <span class="ruby-identifier">point</span>[<span class="ruby-identifier">attribute_index</span>]
19
+ <span class="ruby-identifier">index</span> = ((<span class="ruby-identifier">value</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">minimum</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">bin_width</span>).<span class="ruby-identifier">floor</span>
20
+
21
+ <span class="ruby-identifier">value</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">maximum</span> <span class="ruby-value">? </span><span class="ruby-identifier">index</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>
22
+ <span class="ruby-keyword kw">end</span></pre>
23
+ </body>
24
+ </html>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>compute_minimums_and_maximums (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 216</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compute_minimums_and_maximums</span>
15
+ <span class="ruby-identifier">minimums</span> = <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">dup</span>
16
+ <span class="ruby-identifier">maximums</span> = <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">dup</span>
17
+
18
+ <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attributes</span><span class="ruby-operator">|</span>
19
+ <span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span>, <span class="ruby-identifier">attribute_index</span><span class="ruby-operator">|</span>
20
+ <span class="ruby-identifier">minimums</span>[<span class="ruby-identifier">attribute_index</span>] = <span class="ruby-identifier">attribute</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">attribute</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">minimums</span>[<span class="ruby-identifier">attribute_index</span>]
21
+ <span class="ruby-identifier">maximums</span>[<span class="ruby-identifier">attribute_index</span>] = <span class="ruby-identifier">attribute</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">attribute</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">maximums</span>[<span class="ruby-identifier">attribute_index</span>]
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">end</span>
24
+
25
+ [<span class="ruby-identifier">minimums</span>, <span class="ruby-identifier">maximums</span>]
26
+ <span class="ruby-keyword kw">end</span></pre>
27
+ </body>
28
+ </html>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>compute_bin_widths (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 231</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compute_bin_widths</span> <span class="ruby-identifier">q</span>, <span class="ruby-identifier">bin_count</span>
15
+ (<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-ivar">@data</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute_index</span><span class="ruby-operator">|</span>
16
+ (<span class="ruby-ivar">@maximums</span>[<span class="ruby-identifier">attribute_index</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@minimums</span>[<span class="ruby-identifier">attribute_index</span>]) <span class="ruby-operator">/</span> <span class="ruby-identifier">bin_count</span>.<span class="ruby-identifier">to_f</span>
17
+ <span class="ruby-keyword kw">end</span>
18
+ <span class="ruby-keyword kw">end</span></pre>
19
+ </body>
20
+ </html>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>compute_bin_count (Ranker)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/fastout/ranker.rb, line 238</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compute_bin_count</span> <span class="ruby-identifier">q</span>
15
+ <span class="ruby-identifier">count</span> = (<span class="ruby-ivar">@data</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">q</span>.<span class="ruby-identifier">to_f</span>).<span class="ruby-identifier">ceil</span>
16
+ <span class="ruby-identifier">count</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">2</span> <span class="ruby-operator">?</span> <span class="ruby-value">2</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">count</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,262 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Ranker::Point</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Ranker::Point</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/fastout/ranker_rb.html">
59
+ lib/fastout/ranker.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000018">[]</a>&nbsp;&nbsp;
90
+ <a href="#M000019">clustered?</a>&nbsp;&nbsp;
91
+ <a href="#M000021">in_the_neighborhood_of?</a>&nbsp;&nbsp;
92
+ <a href="#M000022">neighbor_of_any?</a>&nbsp;&nbsp;
93
+ <a href="#M000017">new</a>&nbsp;&nbsp;
94
+ <a href="#M000016">next_id=</a>&nbsp;&nbsp;
95
+ <a href="#M000020">uncluster!</a>&nbsp;&nbsp;
96
+ </div>
97
+ </div>
98
+
99
+ </div>
100
+
101
+
102
+ <!-- if includes -->
103
+
104
+ <div id="section">
105
+
106
+
107
+
108
+
109
+
110
+ <div id="attribute-list">
111
+ <h3 class="section-bar">Attributes</h3>
112
+
113
+ <div class="name-list">
114
+ <table>
115
+ <tr class="top-aligned-row context-row">
116
+ <td class="context-item-name">attributes</td>
117
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
118
+ <td class="context-item-desc"></td>
119
+ </tr>
120
+ <tr class="top-aligned-row context-row">
121
+ <td class="context-item-name">bins</td>
122
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
123
+ <td class="context-item-desc"></td>
124
+ </tr>
125
+ <tr class="top-aligned-row context-row">
126
+ <td class="context-item-name">cluster</td>
127
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
128
+ <td class="context-item-desc"></td>
129
+ </tr>
130
+ <tr class="top-aligned-row context-row">
131
+ <td class="context-item-name">id</td>
132
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
133
+ <td class="context-item-desc"></td>
134
+ </tr>
135
+ <tr class="top-aligned-row context-row">
136
+ <td class="context-item-name">score</td>
137
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
138
+ <td class="context-item-desc"></td>
139
+ </tr>
140
+ </table>
141
+ </div>
142
+ </div>
143
+
144
+
145
+
146
+ <!-- if method_list -->
147
+ <div id="methods">
148
+ <h3 class="section-bar">Public Class methods</h3>
149
+
150
+ <div id="method-M000017" class="method-detail">
151
+ <a name="M000017"></a>
152
+
153
+ <div class="method-heading">
154
+ <a href="Point.src/M000017.html" target="Code" class="method-signature"
155
+ onclick="popupCode('Point.src/M000017.html');return false;">
156
+ <span class="method-name">new</span><span class="method-args">(*attributes)</span>
157
+ </a>
158
+ </div>
159
+
160
+ <div class="method-description">
161
+ </div>
162
+ </div>
163
+
164
+ <div id="method-M000016" class="method-detail">
165
+ <a name="M000016"></a>
166
+
167
+ <div class="method-heading">
168
+ <a href="Point.src/M000016.html" target="Code" class="method-signature"
169
+ onclick="popupCode('Point.src/M000016.html');return false;">
170
+ <span class="method-name">next_id=</span><span class="method-args">(id)</span>
171
+ </a>
172
+ </div>
173
+
174
+ <div class="method-description">
175
+ </div>
176
+ </div>
177
+
178
+ <h3 class="section-bar">Public Instance methods</h3>
179
+
180
+ <div id="method-M000018" class="method-detail">
181
+ <a name="M000018"></a>
182
+
183
+ <div class="method-heading">
184
+ <a href="Point.src/M000018.html" target="Code" class="method-signature"
185
+ onclick="popupCode('Point.src/M000018.html');return false;">
186
+ <span class="method-name">[]</span><span class="method-args">(index)</span>
187
+ </a>
188
+ </div>
189
+
190
+ <div class="method-description">
191
+ </div>
192
+ </div>
193
+
194
+ <div id="method-M000019" class="method-detail">
195
+ <a name="M000019"></a>
196
+
197
+ <div class="method-heading">
198
+ <a href="Point.src/M000019.html" target="Code" class="method-signature"
199
+ onclick="popupCode('Point.src/M000019.html');return false;">
200
+ <span class="method-name">clustered?</span><span class="method-args">()</span>
201
+ </a>
202
+ </div>
203
+
204
+ <div class="method-description">
205
+ </div>
206
+ </div>
207
+
208
+ <div id="method-M000021" class="method-detail">
209
+ <a name="M000021"></a>
210
+
211
+ <div class="method-heading">
212
+ <a href="Point.src/M000021.html" target="Code" class="method-signature"
213
+ onclick="popupCode('Point.src/M000021.html');return false;">
214
+ <span class="method-name">in_the_neighborhood_of?</span><span class="method-args">(point, attribute_indexes, neighborhoods)</span>
215
+ </a>
216
+ </div>
217
+
218
+ <div class="method-description">
219
+ </div>
220
+ </div>
221
+
222
+ <div id="method-M000022" class="method-detail">
223
+ <a name="M000022"></a>
224
+
225
+ <div class="method-heading">
226
+ <a href="Point.src/M000022.html" target="Code" class="method-signature"
227
+ onclick="popupCode('Point.src/M000022.html');return false;">
228
+ <span class="method-name">neighbor_of_any?</span><span class="method-args">(points, attribute_indexes, neighborhoods)</span>
229
+ </a>
230
+ </div>
231
+
232
+ <div class="method-description">
233
+ </div>
234
+ </div>
235
+
236
+ <div id="method-M000020" class="method-detail">
237
+ <a name="M000020"></a>
238
+
239
+ <div class="method-heading">
240
+ <a href="Point.src/M000020.html" target="Code" class="method-signature"
241
+ onclick="popupCode('Point.src/M000020.html');return false;">
242
+ <span class="method-name">uncluster!</span><span class="method-args">()</span>
243
+ </a>
244
+ </div>
245
+
246
+ <div class="method-description">
247
+ </div>
248
+ </div>
249
+
250
+
251
+ </div>
252
+
253
+
254
+ </div>
255
+
256
+
257
+ <div id="validator-badges">
258
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
259
+ </div>
260
+
261
+ </body>
262
+ </html>