-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapriori.dart
More file actions
111 lines (109 loc) · 3.3 KB
/
apriori.dart
File metadata and controls
111 lines (109 loc) · 3.3 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
import 'package:excel/excel.dart'; // excel dependency for manipulating xlsx files with dart
import 'dart:io'; // input / output dependency
// apriori, aprioriTID and setm modules
import 'apriori_methods.dart';
import 'tid_methods.dart';
import 'setm.dart';
import 'utilities.dart';
// main function
void main(List<String> arguments) {
print('Extraction des données ...');
var file = './testdata.xlsx';
var bytes = File(file).readAsBytesSync();
var excel = Excel.decodeBytes(bytes);
var datas = {}; // transactions
var transac = []; // invoice-item association
var I = []; // Items
for (var table in excel.tables.keys) {
var Rows = excel.tables[table].rows; // contain all the rows of the sheet
transac = setTransac(Rows);
}
datas = setDatas(transac);
I = setItems(datas);
var II = setItemsTID(I);
var choice;
print('Il y a ${datas.length} transactions.');
print('');
print('************************ MENU ************************');
print('1. Apriori');
print('2. Apriori TID');
print('3. SETM');
do {
try {
print("Entrez le numéro de l'algorithme que vous désirez exécuter : ");
choice = int.parse(stdin.readLineSync());
break;
} on FormatException {
print("Entrez une valeur entière s'il vous plaît.");
}
} while (true);
switch (choice) {
case 1:
{
var supp;
do {
try {
print('Choisissez le support minimum :');
supp = int.parse(stdin.readLineSync());
break;
} on FormatException {
print("Entrez une valeur entière s'il vous plaît.");
}
} while (true);
print("Exécution de l'algorithme Apriori, patientez !");
var freq = apriori_reel(I, datas, supp);
print('Les itemsets fréquents trouvés sont : ');
for (var elem in freq) {
print(' ==> $elem');
}
print('Il y a ${freq.length} itemsets fréquents.');
break;
}
case 2:
{
var supp;
do {
try {
print('Choisissez le support minimum :');
supp = int.parse(stdin.readLineSync());
break;
} on FormatException {
print("Entrez une valeur entière s'il vous plaît.");
}
} while (true);
print("Exécution de l'algorithme Apriori TID, patientez !");
var freq = apriori_TID(II, datas, supp);
print('Les itemsets fréquents trouvés sont : ');
for (var elem in freq) {
print(' ==> $elem');
}
print('Il y a ${freq.length} itemsets fréquents.');
break;
}
case 3:
{
var supp;
do {
try {
print('Choisissez le support minimum :');
supp = int.parse(stdin.readLineSync());
break;
} on FormatException {
print("Entrez une valeur entière s'il vous plaît.");
}
} while (true);
print("Exécution de l'algorithme SETM, patientez !");
var freq = SETM(I, datas, supp);
print('Les itemsets fréquents trouvés sont : ');
for (var elem in freq) {
print(' ==> $elem');
}
print('Il y a ${freq.length} itemsets fréquents.');
break;
}
default:
{
print('Not allowed value');
}
}
}