jashmenn-apriori 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/History.txt +4 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +121 -0
  4. data/README.txt +139 -0
  5. data/Rakefile +4 -0
  6. data/TODO.txt +60 -0
  7. data/attic/c_ext_test1/MyTest/MyTest.c +23 -0
  8. data/attic/c_ext_test1/MyTest/extconf.rb +11 -0
  9. data/attic/c_ext_test1/mytest.rb +10 -0
  10. data/attic/test.c +12 -0
  11. data/config/hoe.rb +77 -0
  12. data/config/requirements.rb +15 -0
  13. data/examples/01_simple_example.rb +23 -0
  14. data/examples/02_small_file_example.rb +17 -0
  15. data/examples/03_large_file_example.rb +22 -0
  16. data/examples/test_data/market_basket_basic_test.dat +9 -0
  17. data/ext/Apriori.c +149 -0
  18. data/ext/Makefile +149 -0
  19. data/ext/apriori/doc/apriori.html +1301 -0
  20. data/ext/apriori/doc/arem.gp +68 -0
  21. data/ext/apriori/doc/c_rev.gp +89 -0
  22. data/ext/apriori/doc/chi2.tex +156 -0
  23. data/ext/apriori/doc/copying +504 -0
  24. data/ext/apriori/doc/line.gif +0 -0
  25. data/ext/apriori/doc/uparrow.gif +0 -0
  26. data/ext/apriori/ex/flg2set +15 -0
  27. data/ext/apriori/ex/hdr2set +13 -0
  28. data/ext/apriori/ex/readme +71 -0
  29. data/ext/apriori/ex/row2set +7 -0
  30. data/ext/apriori/ex/rulesort +24 -0
  31. data/ext/apriori/ex/tab2set +9 -0
  32. data/ext/apriori/ex/test.app +2 -0
  33. data/ext/apriori/ex/test.rul +9 -0
  34. data/ext/apriori/ex/test1.rul +43 -0
  35. data/ext/apriori/ex/test1.tab +10 -0
  36. data/ext/apriori/ex/test2.tab +10 -0
  37. data/ext/apriori/ex/test3.tab +30 -0
  38. data/ext/apriori/ex/test4.tab +11 -0
  39. data/ext/apriori/ex/test5.tab +39 -0
  40. data/ext/apriori/ex/tid2set +23 -0
  41. data/ext/apriori/ex/xhdr2set +33 -0
  42. data/ext/apriori/src/apriori.c +750 -0
  43. data/ext/apriori/src/apriori.dsp +120 -0
  44. data/ext/apriori/src/apriori.dsw +29 -0
  45. data/ext/apriori/src/apriori.mak +99 -0
  46. data/ext/apriori/src/istree.c +1411 -0
  47. data/ext/apriori/src/istree.h +160 -0
  48. data/ext/apriori/src/makefile +105 -0
  49. data/ext/apriori/src/tract.c +870 -0
  50. data/ext/apriori/src/tract.h +261 -0
  51. data/ext/apriori_wrapper.c +757 -0
  52. data/ext/apriori_wrapper.h +10 -0
  53. data/ext/extconf.rb +32 -0
  54. data/ext/math/doc/copying +504 -0
  55. data/ext/math/src/chi2.c +151 -0
  56. data/ext/math/src/chi2.h +27 -0
  57. data/ext/math/src/choose.c +71 -0
  58. data/ext/math/src/choose.h +16 -0
  59. data/ext/math/src/gamma.c +446 -0
  60. data/ext/math/src/gamma.h +39 -0
  61. data/ext/math/src/intexp.c +35 -0
  62. data/ext/math/src/intexp.h +15 -0
  63. data/ext/math/src/makefile +164 -0
  64. data/ext/math/src/math.mak +48 -0
  65. data/ext/math/src/normal.c +387 -0
  66. data/ext/math/src/normal.h +44 -0
  67. data/ext/math/src/radfn.c +113 -0
  68. data/ext/math/src/radfn.h +34 -0
  69. data/ext/math/src/zeta.c +49 -0
  70. data/ext/math/src/zeta.h +15 -0
  71. data/ext/pre-clean.rb +8 -0
  72. data/ext/pre-setup.rb +9 -0
  73. data/ext/util/doc/copying +504 -0
  74. data/ext/util/src/listops.c +76 -0
  75. data/ext/util/src/listops.h +26 -0
  76. data/ext/util/src/makefile +103 -0
  77. data/ext/util/src/memsys.c +84 -0
  78. data/ext/util/src/memsys.h +42 -0
  79. data/ext/util/src/nstats.c +288 -0
  80. data/ext/util/src/nstats.h +69 -0
  81. data/ext/util/src/params.c +86 -0
  82. data/ext/util/src/params.h +19 -0
  83. data/ext/util/src/parse.c +133 -0
  84. data/ext/util/src/parse.h +81 -0
  85. data/ext/util/src/scan.c +767 -0
  86. data/ext/util/src/scan.h +111 -0
  87. data/ext/util/src/symtab.c +443 -0
  88. data/ext/util/src/symtab.h +121 -0
  89. data/ext/util/src/tabscan.c +279 -0
  90. data/ext/util/src/tabscan.h +99 -0
  91. data/ext/util/src/util.mak +91 -0
  92. data/ext/util/src/vecops.c +317 -0
  93. data/ext/util/src/vecops.h +42 -0
  94. data/lib/apriori/adapter.rb +13 -0
  95. data/lib/apriori/association_rule.rb +85 -0
  96. data/lib/apriori/version.rb +9 -0
  97. data/lib/apriori.rb +133 -0
  98. data/script/console +10 -0
  99. data/script/destroy +14 -0
  100. data/script/generate +14 -0
  101. data/script/txt2html +82 -0
  102. data/setup.rb +1585 -0
  103. data/tasks/apriori.rake +20 -0
  104. data/tasks/attic.rake +28 -0
  105. data/tasks/deployment.rake +34 -0
  106. data/tasks/environment.rake +7 -0
  107. data/tasks/install.rake +6 -0
  108. data/tasks/website.rake +17 -0
  109. data/test/apriori_test.rb +13 -0
  110. data/test/fixtures/market_basket_results_test.txt +5 -0
  111. data/test/fixtures/market_basket_string_test.txt +7 -0
  112. data/test/fixtures/results.txt +2 -0
  113. data/test/fixtures/sample.txt +7 -0
  114. data/test/test_helper.rb +5 -0
  115. data/test/unit/test_apriori.rb +68 -0
  116. data/test/unit/test_itemsets_and_parsing.rb +82 -0
  117. data/website/index.html +233 -0
  118. data/website/index.txt +142 -0
  119. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  120. data/website/stylesheets/screen.css +142 -0
  121. data/website/template.html.erb +49 -0
  122. metadata +188 -0
@@ -0,0 +1,113 @@
1
+ /*----------------------------------------------------------------------
2
+ File : radfn.c
3
+ Contents: radial function management
4
+ (for clustering, radial basis function networks,
5
+ learning vector quantization etc.)
6
+ Author : Christian Borgelt
7
+ History : 15.08.2003 file created from file cluster1.c
8
+ 24.02.2004 parameterization changed
9
+ 13.08.2004 argument 'a' changed to const
10
+ 15.08.2004 functions for derivatives added
11
+ 24.01.2007 inverse function rfi_cauchy and rfi_gauss added
12
+ ----------------------------------------------------------------------*/
13
+ #include <math.h>
14
+ #include <assert.h>
15
+ #include "gamma.h"
16
+ #include "radfn.h"
17
+
18
+ /*----------------------------------------------------------------------
19
+ Preprocessor Definitions
20
+ ----------------------------------------------------------------------*/
21
+ #define M_PI 3.14159265358979323846 /* \pi */
22
+ #define MINDENOM 1e-12 /* minimal value of denominator */
23
+
24
+ /*----------------------------------------------------------------------
25
+ Functions
26
+ ----------------------------------------------------------------------*/
27
+
28
+ double rf_cauchy (double d2, const double *a)
29
+ { /* --- (generalized) Cauchy function */
30
+ double ma; /* temporary buffer for m/a */
31
+
32
+ assert(a); /* check the function arguments */
33
+ if (d2 < 0) { /* if to the get normalization factor */
34
+ if ((a[0] <= -d2) || (a[1] <= 0))
35
+ return 0; /* check whether the integral exists */
36
+ ma = -d2 /a[0]; d2 *= -0.5; /* m/a and m/2 (m = number of dims.) */
37
+ return (a[0] *Gamma(d2) *sin(ma *M_PI))
38
+ / (2 *pow(M_PI, d2+1) *pow(a[1], ma-1));
39
+ } /* return the normalization factor */
40
+ if (a[0] != 2) /* raise distance to the given power */
41
+ d2 = pow(d2, 0.5*a[0]); /* (note that d2 is already squared) */
42
+ d2 += a[1]; /* add offset to distance */
43
+ return (d2 > MINDENOM) ? 1/d2 : 1/MINDENOM;
44
+ } /* rf_cauchy() */ /* compute Cauchy function */
45
+
46
+ /*----------------------------------------------------------------------
47
+ f_cauchy(d) = 1/(d^{a_0} +a_1), default: 1/d^2
48
+ For retrieving the normalization factor, it must be
49
+ d2 = -(number of dimensions of the data space).
50
+ ----------------------------------------------------------------------*/
51
+
52
+ double rf_gauss (double d2, const double *a)
53
+ { /* --- (general.) Gaussian function */
54
+ double ma; /* temporary buffer for m/a */
55
+
56
+ if (d2 < 0) { /* if to the get normalization factor */
57
+ if (a[0] <= 0) return 0; /* check whether the integral exists */
58
+ if (a[0] == 2) /* use simplified formula for a = 2 */
59
+ return pow(2*M_PI, 0.5*d2);
60
+ ma = -d2 /a[0]; d2 *= -0.5; /* m/a and m/2 (m = number of dims.) */
61
+ return (a[0] *Gamma(d2)) / (pow(2, ma+1) *pow(M_PI, d2) *Gamma(ma));
62
+ } /* return the normalization factor */
63
+ if (a[0] != 2) /* raise distance to the given power */
64
+ d2 = pow(d2, 0.5*a[0]); /* (note that d2 is already squared) */
65
+ return exp(-0.5 *d2); /* compute Gaussian function */
66
+ } /* rf_gauss() */
67
+
68
+ /*----------------------------------------------------------------------
69
+ f_gauss(d) = exp(-0.5 *d^{a_0}), default: exp(-0.5 *d^2)
70
+ For retrieving the normalization factor, it must be
71
+ d2 = -(number of dimensions of the data space).
72
+ ----------------------------------------------------------------------*/
73
+
74
+ double rfi_cauchy (double d2, const double *a)
75
+ { /* --- inverse Cauchy function */
76
+ assert(a); /* check the function arguments */
77
+ if (a[0] != 2) /* raise distance to the given power */
78
+ d2 = pow(d2, 0.5*a[0]); /* (note that d2 is already squared) */
79
+ return d2 +a[1]; /* add offset to distance */
80
+ } /* rfi_cauchy() */
81
+
82
+ /*--------------------------------------------------------------------*/
83
+
84
+ double rfi_gauss (double d2, const double *a)
85
+ { /* --- (general.) Gaussian function */
86
+ if (a[0] != 2) /* raise distance to the given power */
87
+ d2 = pow(d2, 0.5*a[0]); /* (note that d2 is already squared) */
88
+ return exp(0.5 *d2); /* compute Gaussian function */
89
+ } /* rfi_gauss() */
90
+
91
+ /*--------------------------------------------------------------------*/
92
+
93
+ double rfd_cauchy (double d2, const double *a, double f)
94
+ { /* --- derivative of Cauchy function */
95
+ assert(a && (d2 >= 0)); /* check the function arguments */
96
+ if (d2 <= 0) return 0; /* check for a positive distance */
97
+ if (f < 0) f = rf_cauchy(d2, a); /* get the function value */
98
+ if (a[0] == 2) return -f*f; /* and check special cases */
99
+ if (a[0] == 4) return -2 *f*f *sqrt(d2);
100
+ return -0.5 *a[0] *f*f *pow(d2, 0.25 *a[0] -0.5);
101
+ } /* rfd_cauchy() */ /* return the derivative */
102
+
103
+ /*--------------------------------------------------------------------*/
104
+
105
+ double rfd_gauss (double d2, const double *a, double f)
106
+ { /* --- derivative of Gaussian func. */
107
+ assert(a && (d2 >= 0)); /* check the function arguments */
108
+ if (d2 <= 0) return 0; /* check for a positive distance */
109
+ if (f < 0) f = rf_gauss(d2, a); /* get the function value */
110
+ if (a[0] == 2) return -0.5 *f; /* and check special cases */
111
+ if (a[0] == 4) return -f *sqrt(d2);
112
+ return -0.25 *a[0] *f *pow(d2, 0.25 *a[0] -0.5);
113
+ } /* rfd_gauss() */ /* return the derivative */
@@ -0,0 +1,34 @@
1
+ /*----------------------------------------------------------------------
2
+ File : radfn.h
3
+ Contents: radial function management
4
+ (for clustering, radial basis function networks,
5
+ learning vector quantization etc.)
6
+ Author : Christian Borgelt
7
+ History : 15.08.2003 file created from file cluster1.c
8
+ 24.02.2004 parameterization changed
9
+ 13.08.2004 argument 'a' changed to const
10
+ 15.08.2004 functions for derivatives added
11
+ 24.01.2007 inverse function rfi_cauchy and rfi_gauss added
12
+ ----------------------------------------------------------------------*/
13
+ #ifndef __RADFN__
14
+ #define __RADFN__
15
+
16
+ /*----------------------------------------------------------------------
17
+ Type Definitions
18
+ ----------------------------------------------------------------------*/
19
+ typedef double RADFN (double d2, const double *a);
20
+ typedef double DERIVFN (double d2, const double *a, double f);
21
+
22
+ /*----------------------------------------------------------------------
23
+ Functions
24
+ ----------------------------------------------------------------------*/
25
+ extern double rf_cauchy (double d2, const double *a);
26
+ extern double rf_gauss (double d2, const double *a);
27
+
28
+ extern double rfi_cauchy (double d2, const double *a);
29
+ extern double rfi_gauss (double d2, const double *a);
30
+
31
+ extern double rfd_cauchy (double d2, const double *a, double f);
32
+ extern double rfd_gauss (double d2, const double *a, double f);
33
+
34
+ #endif
@@ -0,0 +1,49 @@
1
+ /*----------------------------------------------------------------------
2
+ File : zeta.c
3
+ Contents: compute Riemann's zeta-function
4
+ Author : Christian Borgelt
5
+ History : 1998.10.20 file created
6
+ 2008.03.14 main function added
7
+ ----------------------------------------------------------------------*/
8
+ #ifdef ZETA_MAIN
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+ #endif
12
+ #include <math.h>
13
+ #include "zeta.h"
14
+
15
+ /*----------------------------------------------------------------------
16
+ Functions
17
+ ----------------------------------------------------------------------*/
18
+
19
+ double zeta (double x)
20
+ { /* --- compute Riemann's zeta-function*/
21
+ double t = 1, z = 0; /* term to add and result */
22
+ double base = 2; /* base for terms */
23
+
24
+ do { /* compute the sum */
25
+ z += t; /* zeta(x) = \sum_{n=1}^\infty n^{-x} */
26
+ t = pow(base++, -x); /* by successively adding terms */
27
+ } while (z +t > z); /* until a terms gets zero */
28
+ return z; /* return the function value */
29
+ } /* zeta() */
30
+
31
+ /*--------------------------------------------------------------------*/
32
+ #ifdef ZETA_MAIN
33
+
34
+ int main (int argc, char *argv[])
35
+ { /* --- main function */
36
+ double x; /* argument of the zeta function */
37
+
38
+ if (argc != 2) { /* if wrong number of arguments given */
39
+ printf("usage: %s arg\n", argv[0]);
40
+ printf("compute Riemann's zeta-function for arg\n");
41
+ return 0; /* print a usage message */
42
+ } /* and abort the program */
43
+ x = atof(argv[1]); /* get argument */
44
+ if (x <= 1) { printf("%s: x must be > 1\n", argv[0]); return -1; }
45
+ printf("%.16g\n", zeta(x)); /* compute zeta function */
46
+ return 0; /* return 'ok' */
47
+ } /* main() */
48
+
49
+ #endif
@@ -0,0 +1,15 @@
1
+ /*----------------------------------------------------------------------
2
+ File : zeta.h
3
+ Contents: compute Riemann's zeta-function
4
+ Author : Christian Borgelt
5
+ History : 20.10.1998 file created
6
+ ----------------------------------------------------------------------*/
7
+ #ifndef __ZETA__
8
+ #define __ZETA__
9
+
10
+ /*----------------------------------------------------------------------
11
+ Functions
12
+ ----------------------------------------------------------------------*/
13
+ extern double zeta (double x);
14
+
15
+ #endif
data/ext/pre-clean.rb ADDED
@@ -0,0 +1,8 @@
1
+ starting_dir = Dir.pwd
2
+ Dir.chdir("util/src")
3
+ system "make clean"
4
+ Dir.chdir(starting_dir)
5
+
6
+ Dir.chdir("math/src")
7
+ system "make clean"
8
+ Dir.chdir(starting_dir)
data/ext/pre-setup.rb ADDED
@@ -0,0 +1,9 @@
1
+ starting_dir = Dir.pwd
2
+ Dir.chdir("util/src")
3
+ system "make"
4
+ Dir.chdir(starting_dir)
5
+
6
+ starting_dir = Dir.pwd
7
+ Dir.chdir("apriori/src")
8
+ system "make"
9
+ Dir.chdir(starting_dir)