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

Fix the bug in the discretize method caused by the misalignment of column order #90

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

ankh1999
Copy link
Contributor

Bug description: The elements in continuous_columns passed into the discretize method are not necessarily strictly increasing according to the column indices in the data. However, the discretize_all method returns continuous_edges assuming this order. This leads to a consistent error triggering at line 59, pd.Categorical.from_codes, with the message: ValueError: codes need to be between -1 and len(categories)-1.

To reproduce the issue, in the example provided in the "Advanced discretizing continuous data" section, replace continuous_columns = ["mpg", "displacement", "horsepower", "weight", "acceleration"] with continuous_columns = ["mpg", "displacement", "horsepower", "acceleration", "weight"], or change the order in any way that differs from the order in the df. This will consistently trigger the error.

To fix the issue, sorting the continuous_columns in the correct order.

@erdogant erdogant merged commit c1e4f27 into erdogant:master Nov 15, 2023
2 checks passed
@erdogant
Copy link
Owner

great fix!

@erdogant
Copy link
Owner

I published a new release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants