Skip to content
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