-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrule.py
49 lines (38 loc) · 1.5 KB
/
rule.py
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
#!/usr/bin/env python3
import math
class Rule:
""" Represents a final Rule that is extracted from the tree. """
def __init__(self, items, label, confidence, ss, support):
self._items = items
self._label = label
self._confidence = confidence
self._ss = ss
self._support = support
def get_items(self):
return self._items
def get_label(self):
return self._label
def get_confidence(self):
return self._confidence
def get_ss(self):
return self._ss
def get_support(self):
return self._support
def set_items(self, new_items):
self._items = new_items
def __str__(self):
try:
return "{} {};{:.4f},{:.3f},{:.3f}".format(' '.join(map(str, self._items)),
self._label,
self._support,
self._confidence,
math.log(self._ss),
)
except Exception as e:
print(repr(e), self._items, self._label, self._ss)
return "{} {};{:.4f},{:.3f},{:.3f}".format(' '.join(map(str, self._items)),
self._label,
float(self._support),
float(self._confidence),
0.0,
)