Skip to content

Commit

Permalink
Merge pull request #109 from zStupan/remove-similar-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
firefly-cpp authored Feb 10, 2024
2 parents cd64aab + 95951a5 commit 3a463cf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 15 deletions.
69 changes: 62 additions & 7 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,62 @@
Sphinx==4.4.0
sphinx-rtd-theme==1.0.0
sphinxcontrib-bibtex==2.4.1
niapy>=2.0.1
numpy>=1.22.3
pandas>=1.4.0
nltk
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile
#
alabaster==0.7.13
# via sphinx
babel==2.13.1
# via sphinx
certifi==2023.7.22
# via requests
charset-normalizer==3.3.1
# via requests
docutils==0.18.1
# via
# sphinx
# sphinx-rtd-theme
idna==3.4
# via requests
imagesize==1.4.1
# via sphinx
jinja2==3.1.2
# via sphinx
markupsafe==2.1.3
# via jinja2
packaging==23.2
# via sphinx
pygments==2.16.1
# via sphinx
requests==2.31.0
# via sphinx
snowballstemmer==2.2.0
# via sphinx
sphinx==7.2.6
# via
# -r requirements.in
# sphinx-rtd-theme
# sphinxcontrib-applehelp
# sphinxcontrib-devhelp
# sphinxcontrib-htmlhelp
# sphinxcontrib-jquery
# sphinxcontrib-qthelp
# sphinxcontrib-serializinghtml
sphinx-rtd-theme==1.3.0
# via -r requirements.in
sphinxcontrib-applehelp==1.0.7
# via sphinx
sphinxcontrib-devhelp==1.0.5
# via sphinx
sphinxcontrib-htmlhelp==2.0.4
# via sphinx
sphinxcontrib-jquery==4.1
# via sphinx-rtd-theme
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==1.0.6
# via sphinx
sphinxcontrib-serializinghtml==1.1.9
# via sphinx
urllib3==2.0.7
# via requests
20 changes: 13 additions & 7 deletions niaarm/feature.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import math


class Feature:
r"""Class representing a feature.
Expand All @@ -20,19 +23,22 @@ def __init__(self, name, dtype, min_val=None, max_val=None, categories=None):
self.categories = categories

def __eq__(self, other):
return (
self.name == other.name
and self.dtype == other.dtype
and self.min_val == other.min_val
and self.max_val == other.max_val
)
if self.dtype != other.dtype or self.name != other.name:
return False

if self.dtype == "cat":
return self.categories == other.categories

return math.isclose(
self.min_val, other.min_val, rel_tol=1e-6, abs_tol=1e-6
) and math.isclose(self.max_val, other.max_val, rel_tol=1e-6, abs_tol=1e-6)

def __repr__(self):
string = f"{self.name}("
if self.dtype == "cat":
string += f"{self.categories if len(self.categories) != 1 else self.categories[0]})"
else:
if self.min_val == self.max_val:
if math.isclose(self.min_val, self.max_val, rel_tol=1e-6, abs_tol=1e-6):
string += f"{self.min_val})"
else:
string += f"[{self.min_val}, {self.max_val}])"
Expand Down
5 changes: 4 additions & 1 deletion niaarm/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ def zhang(self):
support = self.support

numerator = support - support_x * support_y
denominator = max(support * (1 - support_x), support_x * (support_y - support))
denominator = (
max(support * (1 - support_x), support_x * (support_y - support))
+ 2.220446049250313e-16
)

return numerator / denominator

Expand Down

0 comments on commit 3a463cf

Please sign in to comment.