Skip to content

Commit 3a463cf

Browse files
authored
Merge pull request #109 from zStupan/remove-similar-rules
2 parents cd64aab + 95951a5 commit 3a463cf

File tree

3 files changed

+79
-15
lines changed

3 files changed

+79
-15
lines changed

docs/requirements.txt

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,62 @@
1-
Sphinx==4.4.0
2-
sphinx-rtd-theme==1.0.0
3-
sphinxcontrib-bibtex==2.4.1
4-
niapy>=2.0.1
5-
numpy>=1.22.3
6-
pandas>=1.4.0
7-
nltk
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile
6+
#
7+
alabaster==0.7.13
8+
# via sphinx
9+
babel==2.13.1
10+
# via sphinx
11+
certifi==2023.7.22
12+
# via requests
13+
charset-normalizer==3.3.1
14+
# via requests
15+
docutils==0.18.1
16+
# via
17+
# sphinx
18+
# sphinx-rtd-theme
19+
idna==3.4
20+
# via requests
21+
imagesize==1.4.1
22+
# via sphinx
23+
jinja2==3.1.2
24+
# via sphinx
25+
markupsafe==2.1.3
26+
# via jinja2
27+
packaging==23.2
28+
# via sphinx
29+
pygments==2.16.1
30+
# via sphinx
31+
requests==2.31.0
32+
# via sphinx
33+
snowballstemmer==2.2.0
34+
# via sphinx
35+
sphinx==7.2.6
36+
# via
37+
# -r requirements.in
38+
# sphinx-rtd-theme
39+
# sphinxcontrib-applehelp
40+
# sphinxcontrib-devhelp
41+
# sphinxcontrib-htmlhelp
42+
# sphinxcontrib-jquery
43+
# sphinxcontrib-qthelp
44+
# sphinxcontrib-serializinghtml
45+
sphinx-rtd-theme==1.3.0
46+
# via -r requirements.in
47+
sphinxcontrib-applehelp==1.0.7
48+
# via sphinx
49+
sphinxcontrib-devhelp==1.0.5
50+
# via sphinx
51+
sphinxcontrib-htmlhelp==2.0.4
52+
# via sphinx
53+
sphinxcontrib-jquery==4.1
54+
# via sphinx-rtd-theme
55+
sphinxcontrib-jsmath==1.0.1
56+
# via sphinx
57+
sphinxcontrib-qthelp==1.0.6
58+
# via sphinx
59+
sphinxcontrib-serializinghtml==1.1.9
60+
# via sphinx
61+
urllib3==2.0.7
62+
# via requests

niaarm/feature.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import math
2+
3+
14
class Feature:
25
r"""Class representing a feature.
36
@@ -20,19 +23,22 @@ def __init__(self, name, dtype, min_val=None, max_val=None, categories=None):
2023
self.categories = categories
2124

2225
def __eq__(self, other):
23-
return (
24-
self.name == other.name
25-
and self.dtype == other.dtype
26-
and self.min_val == other.min_val
27-
and self.max_val == other.max_val
28-
)
26+
if self.dtype != other.dtype or self.name != other.name:
27+
return False
28+
29+
if self.dtype == "cat":
30+
return self.categories == other.categories
31+
32+
return math.isclose(
33+
self.min_val, other.min_val, rel_tol=1e-6, abs_tol=1e-6
34+
) and math.isclose(self.max_val, other.max_val, rel_tol=1e-6, abs_tol=1e-6)
2935

3036
def __repr__(self):
3137
string = f"{self.name}("
3238
if self.dtype == "cat":
3339
string += f"{self.categories if len(self.categories) != 1 else self.categories[0]})"
3440
else:
35-
if self.min_val == self.max_val:
41+
if math.isclose(self.min_val, self.max_val, rel_tol=1e-6, abs_tol=1e-6):
3642
string += f"{self.min_val})"
3743
else:
3844
string += f"[{self.min_val}, {self.max_val}])"

niaarm/rule.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,10 @@ def zhang(self):
322322
support = self.support
323323

324324
numerator = support - support_x * support_y
325-
denominator = max(support * (1 - support_x), support_x * (support_y - support))
325+
denominator = (
326+
max(support * (1 - support_x), support_x * (support_y - support))
327+
+ 2.220446049250313e-16
328+
)
326329

327330
return numerator / denominator
328331

0 commit comments

Comments
 (0)