Skip to content

Fix bug when converting OSDT leaves into a Text Classifier compatible… #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions python/model/gosdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,24 @@ def __translate__(self, leaves):
}
else:
features = {}
# In next commented section there is a bug when trying to validate if a leaf exists in the "features" dict. Essentially, a "leaf" has
# the form: (feature_1, feature_2, ..., feature_n) and the "keys" and "values" of the "features" dict has the form:
# key = feature
# value = frequency
# So, the condition must be changed in order to evaluate the case when a "feature" from the current "leaf" exists in the "features" dict
# Otherwise, for some specific cases this loop crashes
# ------ Original loop ---------- #
# for leaf in leaves.keys():
# if not leaf in features:
# for e in leaf:
# features[abs(e)] = 1
# else:
# features[abs(e)] += 1

# ------ Fixed loop ---------- #
for leaf in leaves.keys():
if not leaf in features:
for e in leaf:
for e in leaf:
if abs(e) not in features.keys():
features[abs(e)] = 1
else:
features[abs(e)] += 1
Expand Down