Repository navigation
Label cat_continuous "High" bins with the percentiles they use - #1094
Open
vishalhabib99 wants to merge 1 commit into
Open
vishalhabib99 wants to merge 1 commit into
vishalhabib99 wants to merge 1 commit into
Conversation
With granularity="High", cat_continuous computes cut-offs at p5, p10, ..., p95 and p99, but the labeling code was the "Medium" one: it compared each value with the first nine cut-offs (p5 to p45) and named them p10 to p90, then put every value above p45 in a "> p90" bin. On 1..100 that bin held 55 of the 100 values and the other 15 cut-offs were never used. Label each value with the first cut-off it falls under, giving the 21 bins the computed percentiles describe. "Medium" and "Low" are unchanged.
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
causalml.inference.tree.cat_continuous(x, granularity="High")(also exported fromcausalml.inference.treeand used bykpi_transformfor a single feature) computes 20 cut-offs at p5, p10, ..., p95 and p99, but its labeling code was a copy of the"Medium"branch. It compared each value with only the first nine cut-offs (p5 to p45), named those bins p10 to p90, and put every value above p45 into a"> p90"bin. The other 11 cut-offs were computed and never used.Reproduction on current master (089a882):
Before (10 bins; 55 of 100 values labeled "> p90", with the p45 value as the bound):
After (21 bins, each named after the percentile whose value bounds it):
The
"High"branch now labels each value with the first cut-off it falls under. The"Medium"and"Low"branches are untouched.Types of changes
Checklist
Further comments
Added
test_cat_continuous_high_granularity_uses_its_percentilestotests/test_utils.py. It fails on master (assert 10 == 21distinct bins) and passes with the fix.pytest tests/test_utils.py: 5 passed.pytest tests/test_causal_trees.py tests/test_uplift_trees.py: 97 passed, 1 failed; the failure (test_uplift_tree_visualization, FileNotFoundError for the graphvizdotbinary, which is not installed locally) fails the same way on master.black --checkandflake8are clean on the changed files.