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

[🐛BUG] Fix discretization bug #2128

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
34 changes: 17 additions & 17 deletions recbole/data/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,26 +722,26 @@ def _discretization(self):
Only float-like fields can be discretized.
"""

dis_info = {}
if not self.config["discretization"]:
return

if self.config["discretization"]:
dis_info = self.config["discretization"]
dis_info = self.config["discretization"]

for field in dis_info.keys():
if field not in self.field2type:
raise ValueError(f"Field [{field}] does not exist.")
if field not in self.config["numerical_features"]:
raise ValueError(f"Field [{field}] must be a numerical feature")
ftype = self.field2type[field]
if ftype != FeatureType.FLOAT and ftype != FeatureType.FLOAT_SEQ:
self.logger.warning(
f"{field} is not a FLOAT/FLOAT_SEQ feat, which will not be normalized."
)
del dis_info[field]
for field in dis_info.keys():
if field not in self.field2type:
raise ValueError(f"Field [{field}] does not exist.")
if field not in self.config["numerical_features"]:
raise ValueError(f"Field [{field}] must be a numerical feature")
ftype = self.field2type[field]
if ftype != FeatureType.FLOAT and ftype != FeatureType.FLOAT_SEQ:
self.logger.warning(
f"{field} is not a FLOAT/FLOAT_SEQ feat, which will not be normalized."
)
del dis_info[field]

self.logger.debug(
set_color("Normalized fields", "blue") + f": {dis_info.keys()}"
)
self.logger.debug(
set_color("Normalized fields", "blue") + f": {dis_info.keys()}"
)

for field in self.config["numerical_features"]:
if field in dis_info:
Expand Down
Loading