jashmenn-apriori 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +121 -0
- data/README.txt +139 -0
- data/Rakefile +4 -0
- data/TODO.txt +60 -0
- data/attic/c_ext_test1/MyTest/MyTest.c +23 -0
- data/attic/c_ext_test1/MyTest/extconf.rb +11 -0
- data/attic/c_ext_test1/mytest.rb +10 -0
- data/attic/test.c +12 -0
- data/config/hoe.rb +77 -0
- data/config/requirements.rb +15 -0
- data/examples/01_simple_example.rb +23 -0
- data/examples/02_small_file_example.rb +17 -0
- data/examples/03_large_file_example.rb +22 -0
- data/examples/test_data/market_basket_basic_test.dat +9 -0
- data/ext/Apriori.c +149 -0
- data/ext/Makefile +149 -0
- data/ext/apriori/doc/apriori.html +1301 -0
- data/ext/apriori/doc/arem.gp +68 -0
- data/ext/apriori/doc/c_rev.gp +89 -0
- data/ext/apriori/doc/chi2.tex +156 -0
- data/ext/apriori/doc/copying +504 -0
- data/ext/apriori/doc/line.gif +0 -0
- data/ext/apriori/doc/uparrow.gif +0 -0
- data/ext/apriori/ex/flg2set +15 -0
- data/ext/apriori/ex/hdr2set +13 -0
- data/ext/apriori/ex/readme +71 -0
- data/ext/apriori/ex/row2set +7 -0
- data/ext/apriori/ex/rulesort +24 -0
- data/ext/apriori/ex/tab2set +9 -0
- data/ext/apriori/ex/test.app +2 -0
- data/ext/apriori/ex/test.rul +9 -0
- data/ext/apriori/ex/test1.rul +43 -0
- data/ext/apriori/ex/test1.tab +10 -0
- data/ext/apriori/ex/test2.tab +10 -0
- data/ext/apriori/ex/test3.tab +30 -0
- data/ext/apriori/ex/test4.tab +11 -0
- data/ext/apriori/ex/test5.tab +39 -0
- data/ext/apriori/ex/tid2set +23 -0
- data/ext/apriori/ex/xhdr2set +33 -0
- data/ext/apriori/src/apriori.c +750 -0
- data/ext/apriori/src/apriori.dsp +120 -0
- data/ext/apriori/src/apriori.dsw +29 -0
- data/ext/apriori/src/apriori.mak +99 -0
- data/ext/apriori/src/istree.c +1411 -0
- data/ext/apriori/src/istree.h +160 -0
- data/ext/apriori/src/makefile +105 -0
- data/ext/apriori/src/tract.c +870 -0
- data/ext/apriori/src/tract.h +261 -0
- data/ext/apriori_wrapper.c +757 -0
- data/ext/apriori_wrapper.h +10 -0
- data/ext/extconf.rb +32 -0
- data/ext/math/doc/copying +504 -0
- data/ext/math/src/chi2.c +151 -0
- data/ext/math/src/chi2.h +27 -0
- data/ext/math/src/choose.c +71 -0
- data/ext/math/src/choose.h +16 -0
- data/ext/math/src/gamma.c +446 -0
- data/ext/math/src/gamma.h +39 -0
- data/ext/math/src/intexp.c +35 -0
- data/ext/math/src/intexp.h +15 -0
- data/ext/math/src/makefile +164 -0
- data/ext/math/src/math.mak +48 -0
- data/ext/math/src/normal.c +387 -0
- data/ext/math/src/normal.h +44 -0
- data/ext/math/src/radfn.c +113 -0
- data/ext/math/src/radfn.h +34 -0
- data/ext/math/src/zeta.c +49 -0
- data/ext/math/src/zeta.h +15 -0
- data/ext/pre-clean.rb +8 -0
- data/ext/pre-setup.rb +9 -0
- data/ext/util/doc/copying +504 -0
- data/ext/util/src/listops.c +76 -0
- data/ext/util/src/listops.h +26 -0
- data/ext/util/src/makefile +103 -0
- data/ext/util/src/memsys.c +84 -0
- data/ext/util/src/memsys.h +42 -0
- data/ext/util/src/nstats.c +288 -0
- data/ext/util/src/nstats.h +69 -0
- data/ext/util/src/params.c +86 -0
- data/ext/util/src/params.h +19 -0
- data/ext/util/src/parse.c +133 -0
- data/ext/util/src/parse.h +81 -0
- data/ext/util/src/scan.c +767 -0
- data/ext/util/src/scan.h +111 -0
- data/ext/util/src/symtab.c +443 -0
- data/ext/util/src/symtab.h +121 -0
- data/ext/util/src/tabscan.c +279 -0
- data/ext/util/src/tabscan.h +99 -0
- data/ext/util/src/util.mak +91 -0
- data/ext/util/src/vecops.c +317 -0
- data/ext/util/src/vecops.h +42 -0
- data/lib/apriori/adapter.rb +13 -0
- data/lib/apriori/association_rule.rb +85 -0
- data/lib/apriori/version.rb +9 -0
- data/lib/apriori.rb +133 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/apriori.rake +20 -0
- data/tasks/attic.rake +28 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/install.rake +6 -0
- data/tasks/website.rake +17 -0
- data/test/apriori_test.rb +13 -0
- data/test/fixtures/market_basket_results_test.txt +5 -0
- data/test/fixtures/market_basket_string_test.txt +7 -0
- data/test/fixtures/results.txt +2 -0
- data/test/fixtures/sample.txt +7 -0
- data/test/test_helper.rb +5 -0
- data/test/unit/test_apriori.rb +68 -0
- data/test/unit/test_itemsets_and_parsing.rb +82 -0
- data/website/index.html +233 -0
- data/website/index.txt +142 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +142 -0
- data/website/template.html.erb +49 -0
- 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
|
data/ext/math/src/zeta.c
ADDED
@@ -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
|
data/ext/math/src/zeta.h
ADDED
@@ -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