Repository navigation
Replace np.asscalar in the dataset feature transformation fallback - #1088
Open
aad1tyaaaaa wants to merge 1 commit into
Open
aad1tyaaaaa wants to merge 1 commit into
aad1tyaaaaa wants to merge 1 commit into
Conversation
_fixed_transformation falls back to a random transformation when the index is past the end of the function list, which make_uplift_classification_logistic hits whenever feature_association_list is shorter than n_classification_informative. The fallback called np.asscalar, removed in numpy 1.23, so those calls raised AttributeError.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
_fixed_transformationincausalml/dataset/classification.pyusesfs[f_index]and, when the index is past the end of the list, falls back to a random function throughnp.asscalar(...).np.asscalarwas removed in numpy 1.23.make_uplift_classification_logisticreaches this fallback wheneverfeature_association_listis shorter thann_classification_informative:This PR indexes with
np.random.choice(len(fs))directly, which draws a single index from the same random stream.Types of changes
Checklist
Further comments
The new test
test_make_uplift_classification_logistic_with_fewer_associations_than_featuresintests/test_datasets.pyfails on master with the AttributeError and passes with this change; black is clean.I used an AI assistant (Claude Code) to help find this bug and write the fix and test. I reviewed and ran everything myself.