-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.cc
More file actions
149 lines (128 loc) · 3.5 KB
/
Copy pathtrain.cc
File metadata and controls
149 lines (128 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include <string>
#include <fstream>
#include <iostream>
#include <chrono>
#include "database.h"
#include "fastWY.h"
using namespace std;
using uint = unsigned int;
inline void exit_with_help(){
cout << "-- FastWY method for sequential pattern mining --\n"
"Usage: train [-options] input_file\n"
"options:\n"
" -m : minimum supportSum (default 1)\n"
" If you want to decide on the percentage of the whole, please enter a value less than 1.\n"
" -M : minimum length of pattern (default 1)\n"
" -L : maximum length of pattern (default 10)\n"
" -F : name of reslut file (default output/result.csv)\n"
" -p : maximum interval of event (default 0 | -1:none)\n"
" -C : whether to do CloSpan (default 0:do not | 1:do)\n"
" -R : Repeat resampling in FastWY (default 10000)\n"
" -a : significance level (default 0.05)\n"
" -s : the Mode of counting supportSum(default 0)\n"
" : 0 is 0 or 1 per record,1 is the number of pattern\n"
" -S : double or single-side test (default 0:double | 1:upper-side | 2:lower-side)\n" << endl;
exit(1);
}
int main(int argc, char **argv){
//default
double tMinsup = 1;
uint tMinpat = 1;
uint tMaxpat = 10;
uint tMinItem = 1;
uint tMaxItem = 10;
uint tR = 10000;
double tAlpha = 0.05;
uint tWild = 0;
uint tSide = 0;
int tInterval = 0;
uint tSupMode = 0;
uint tCloSpan = 0;
string tFilename = "result.csv";
int tI;
for(tI = 1; tI < argc; tI++){
if(argv[tI][0] != '-'){
break;
}
if(++tI >= argc){
exit_with_help();
}
switch(argv[tI - 1][1]){
case 'm':
tMinsup = atof(argv[tI]);
break;
case 'M':
tMinpat = atoi(argv[tI]);
break;
case 'L':
tMaxpat = atoi(argv[tI]);
break;
case 'i':
tMinItem = atoi(argv[tI]);
break;
case 'I':
tMaxItem = atoi(argv[tI]);
break;
case 'F':
tFilename = argv[tI];
break;
case 'p':
tInterval = atoi(argv[tI]);
break;
case 's':
tSupMode = atoi(argv[tI]);
break;
case 'C':
tCloSpan = atoi(argv[tI]);
break;
case 'R':
tR = atoi(argv[tI]);
break;
case 'a':
tAlpha = atof(argv[tI]);
break;
case 'w':
tWild = atof(argv[tI]);
break;
case 'S':
tSide = atof(argv[tI]);
break;
default:
cerr << "Error unknown option: -" << argv[tI - 1][1] << endl;
exit_with_help();
break;
}
}
if(tI >= argc){
cerr << "Error please input filename" << endl;
exit_with_help();
}
if(tWild == 1 && tInterval != 0){
cerr << "Error: If you want to consider WildCard, please set Interval value to 0" << endl;
exit_with_help();
}
//read data
Database tDatabase;
tDatabase.read(argv[tI]);
vector<vector<Event> > tTransaction = tDatabase.get_transaction();
vector<double> tY = tDatabase.get_y();
chrono::system_clock::time_point start, end;
start = chrono::system_clock::now();
//make fastWY
FastWY tFastWY(tMinsup, tMinpat, tMaxpat, tMinItem, tMaxItem, tR, tAlpha, tCloSpan, tSupMode, tInterval, tWild, tSide);
tFastWY.init(tTransaction, tY);
cout << "init finish" << endl;
tFastWY.main();
cout << "FastWY finish" << endl;
end = chrono::system_clock::now();
double elapsed = chrono::duration_cast<chrono::milliseconds>(end - start).count();
elapsed *= 0.001;
cout << "****************************" << endl;
cout << "time(sec):" << elapsed << endl;
//write outcome
tFastWY.printSigPattern(tFilename);
tFilename.replace(tFilename.find(".csv"), 4, "_all.csv");
tFastWY.printTree(tFilename);
cout << "print finish" << endl;
return 0;
}