-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
ENH Monotonic Contraints for Tree-based models #13649
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
Merged
Merged
Changes from all commits
Commits
Show all changes
203 commits
Select commit
Hold shift + click to select a range
1b0a960
Monotonic features in tree-based models
pat-oreilly 953651f
refactoring monotonic check into a function
pat-oreilly 63c3f9c
tidy up monotonic check function
pat-oreilly 6407e99
fix typo 'decreasin'
pat-oreilly 92f7537
Merge branch 'master' into monotonic-trees
samronsin 119d5a3
Clean up dirty merge
samronsin c331e82
PEP8
samronsin ab6d185
PEP8
samronsin ce9377f
PEP8
samronsin fe21579
Update docstrings for increasing/decreasing parameters
samronsin 642dcb0
Merge branch 'master' into monotonic-trees
samronsin 544cced
Cleanup
samronsin 20c7929
Cleanup
samronsin 8cd9954
Merge branch 'master' into monotonic-trees
samronsin 49747c6
Add basic monotonicity tests
samronsin 37b536b
PEP8
samronsin ef2fb1c
PEP8
samronsin 072ef99
Simplify split_passes_monotonic_check function
samronsin 605e1c8
Fix split_passes_monotonic_check function
samronsin 018d6c2
Fix tests (still something broken though)
samronsin 347e2c6
Merge branch 'master' into monotonic-trees
samronsin b217ec8
Fix PEP8 and missing import in tests
samronsin be8b38a
Fix faulty Splitter call in _classes.py
samronsin 5aacb40
Remove merge bruises
samronsin ef05889
Remove deprecated asserts
samronsin 8ac9945
changing decreasing/increasing to monotonic_cst
dsleo 8a687c1
Fix segfault caused by sending None instead of np.array to Splitter init
samronsin 900ed04
Fix tests
samronsin 15fe7b5
fix linting
dsleo 803efe0
Preliminary pass at adding upper and lower bounds on splits
samronsin 23da3e7
Work towards adding upper and lower bounds on splits and nodes
samronsin f73c820
YOLO
samronsin d43a4a9
Do the easier TODOs
samronsin 822bd5b
Roll back adding bound information to nodes
samronsin e485416
Add bound information to intermediate tree-building structures
samronsin b735ff8
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
samronsin 32e4c70
Add monotonicity tests for tree with single feature
samronsin 8c39842
Add test for best first tree builder
samronsin 89fd890
Fix monotonicity checks related to bounds
samronsin 678b1f8
Fix depth-first tree building with decreasing constraint
samronsin 0ce8b3a
Clean up
samronsin 2fac624
Add tests for random splitter
samronsin cafb309
Clean up Stack
samronsin 4601690
Clean up PriorityHeap
samronsin 3ee90f6
Clean up PriorityHeap
samronsin 1bfdc4c
Fix wrong test for leaves and seed trees
samronsin 3366a30
Make tests consistents with implemented bounding strategy
samronsin 4634dea
Fix monotonicity checks
samronsin a7b4133
Clean up depth-first tree building
samronsin c2cecf5
Fix and clean up best-first tree building
samronsin 4764cf4
Flake8
samronsin dcc9f18
Formatting
samronsin 84b912b
Raise ValueError on multiclass
samronsin 60a4b8c
Linting
samronsin 3ccb540
Fix previous merge
samronsin 5f75c1c
Remove useless check when splitting on unconstrainted feature
samronsin 5feda05
Merge branch 'master' into monotonic-trees
samronsin 05d023c
Group monotonic tree tests into dedicated file
samronsin 3fd364f
Fix linting
samronsin 711c2ee
Merge branch 'master' into monotonic-trees
samronsin e94c9a2
Merge branch 'master' into monotonic-trees
samronsin de6341f
Make test_montonic_constraints harder to pass
samronsin 3a78b94
Fix tree regressions by enforcing bounds for all splits
samronsin 5090853
Make test_montonic_constraints harder to pass
samronsin 70f0276
Fix middle value bound for classifications
samronsin 930ed41
Clean up, document and comment
samronsin b4d1757
Clean up
samronsin b73984d
Fix ExtraTreeRegressor Docstring
samronsin 173db43
Clean up
samronsin c4e119d
Clean up tests
samronsin fc50799
Add test for multi-features trees
samronsin 6312564
Merge branch 'main' into monotonic-trees
ogrisel 847cc4f
Apply suggestions from code review
samronsin 08f8247
Apply more suggestions from code review
samronsin 5a92399
Test error message for multiclass
samronsin 08dadd1
Merge commit '0e7761cdc4f244adb4803f1a97f0a9fe4b365a99' into monotoni…
samronsin c2e6e4e
MAINT Adds target_version to black config (#20293)
thomasjpfan b88a637
Add formatting changes from black
samronsin 46c9087
Merge remote-tracking branch 'upstream/main' into monotonic-trees
samronsin 66032e5
Make the monotonicity constraints hold on the positive class for bina…
samronsin e6264d3
Adapt gradient boosting to disable modifying leaves (line search) and…
samronsin d196ace
Add tests for gradient boosting and removing tests for forests
samronsin 250996a
Format
samronsin df31697
Add whats_new entry
samronsin e6937d9
Fix 1/-1 mixup in the docstrings relative to positive/negative constr…
samronsin 56b361d
Apply suggestions from code review
samronsin 0d1fa94
Merge remote-tracking branch 'upstream/main' into monotonic-trees
samronsin ba95efa
Move blurbs to latest whats_new
samronsin b764a89
Remove named argument for cdef function and use deref instead of [0] …
samronsin c721fa6
Update wording in docstring for perform_line_search argument
samronsin f4ebabe
Split test_montonic_constraints into two tests for classifications/re…
samronsin c0fa6f8
Add name of arguments to stack.push calls as comments
samronsin 70de129
Add test for incorrect input
samronsin 20590d5
Add blank line
samronsin 573aa79
Format
samronsin 03ee5f4
Factor the logic computing the middle value
jjerphan 779efcb
Apply Julien's suggestions in tests
samronsin 1426e1d
Clean up check of monotonic_cst values
samronsin 1db26e0
Use local variables for attributes and initialize on definition
samronsin e87e40a
Add comments in BestFirstTreeBuilder
samronsin f03f089
Update methods signature format for readability
samronsin cc446f6
Update methods signature format for readability
samronsin 24366d7
Merge branch 'main' into monotonic-trees
samronsin c8ec3c4
Format
samronsin 0a02f62
Fix gil stuff and stuff
samronsin 771bc3f
Merge branch 'main' into monotonic-trees
samronsin dea6bda
Fix -1 0 1 monotonic_cst check
samronsin 1c943a3
Move check_monotonicity from Splitter to Criterion
samronsin b0a0317
Fix premature call to check_monotonicity in RandomSparseSplitter
samronsin b784e04
Remove unnecessary GIL-taking
samronsin f68a27b
Fix formatting
samronsin daf54cd
Merge branch 'main' into monotonic-trees
ogrisel 38ce5a7
Merge branch 'main' into monotonic-trees
jjerphan 8b795e7
Add monotonic_cst to parameter contraints for decision tree models
samronsin 279ab6a
Misc formatting
samronsin 79d345b
Fix early casting to int beaking test when input is not int
samronsin 0367f26
Replace paramaterized seed by global_random_seed fixture
samronsin c6e955d
Comment inline the bounds propagation
samronsin bde6754
Fix format
samronsin 2d8b025
Fix format
samronsin efb6424
Add example of incorrect tree if bounds and checks are not propagated…
samronsin 896ef6f
Update whats_new entry
samronsin cc4be1a
Reduce dataset size in test
samronsin bf78a7f
Merge branch 'main' into monotonic-trees
samronsin 23d3a2b
MAINT Adapt logic to use the latest NumPy API
jjerphan 69a0dd8
Clean up cimports in _splitter.pyx
samronsin 6eab6e0
Merge branch 'main' into monotonic-trees
samronsin baa1cf6
Revert hist_gradient_boosting docstring correction to save for a dedi…
samronsin 26a69c0
Address compilation warnings on uninitialised variables
samronsin 66a18e0
Use keyword arguments in _add_split_node calls
samronsin bbf5fb2
Qualify Splitter.monotonic_cst as const and switch to MemoryView
samronsin 96923b6
Revert "Use keyword arguments in _add_split_node calls"
samronsin e06806a
Factorize common regression and classification logic of constraints c…
samronsin 7bfb603
Revert "Qualify Splitter.monotonic_cst as const and switch to MemoryV…
samronsin 8065ab7
Qualify Splitter.monotonic_cst as const
samronsin 1083303
Merge branch 'main' into monotonic-trees
samronsin c54eab9
Use MemoryViews for monotonic_cst instead of pointers
samronsin eb4ee0f
Use keyword arguments in _add_split_node calls
samronsin 1cbc5d8
CI Retrigger CI due to assert reproducibility of the faulty run
jjerphan 438d224
Remove unused get_sum_total
jjerphan 301fb4e
Replace positive/negative wording by increasing/decreasing and use bu…
samronsin a491f59
Fix docstrings
samronsin 1c7ac01
Fix docstrings
samronsin 3e9b3a8
Merge branch 'main' into monotonic-trees
jjerphan d65c437
Remove monotonic_cst for RandomTreesEmbedding
ogrisel 56966a6
Use np.int8 by default
ogrisel e00ab65
Apply suggestions from code review
ogrisel e047f52
Apply suggestions from code review
ogrisel 3ba9c10
Merge branch 'main' into monotonic-trees
ogrisel c70c1b6
Missing .. versionadded:: 1.2 & more consistent docstrings
ogrisel e41435f
Fix linter
ogrisel 3a46ff6
Monotonic increase
ogrisel 7a39219
Encode monotonicity constraints with cnp.int8
jjerphan dd5df85
Fix docstring format of ExtraTreesClassifier (double blank line)
ogrisel 7c2536f
Merge branch 'main' into HEAD
jjerphan 2b596ec
Remove monotonic_cst support for GradientBoosting for now
jjerphan b9c7a90
DOC Clarify wording for constraints
jjerphan 94d993c
TST Parametrize tests and simplify parameters' lists
jjerphan 41e443e
MAINT Format ala black
jjerphan bf0a106
Remove irrelevant changes
jjerphan ec9cb4a
fixup! DOC Clarify wording for constraints
jjerphan 0d58fe5
Use global_random_seed in data generation for tests
ogrisel 23d4497
English grammar
ogrisel bfe94af
Optim: protect check_monotonicity under monotonic_constraint != 0
ogrisel 9e1f8b1
Revert "Optim: protect check_monotonicity under monotonic_constraint …
ogrisel 3fdae14
Test clean-up
ogrisel 7e33b05
PERF Use monotonic_cst only is it is provided
jjerphan 1cae8ee
Improve comments in _get_middle_value
ogrisel 3558bfd
Only compute bounds' middle_value when needed
jjerphan 35ae0a3
More intuitive assert_nd_reg_tree_children_monotonic_bounded
ogrisel 5926abe
WIP try to test assert_nd_reg_tree_children_monotonic_bounded
ogrisel a650224
Apply suggestions from code review
ogrisel 68ccb72
Merge branch 'main' into monotonic-trees
samronsin 6809be7
Clean up
samronsin 104600e
Merge branch 'main' into monotonic-trees
samronsin 27895f5
Implement middle value as unweighted average of right and left childr…
samronsin a73c765
Merge branch 'main' into monotonic-trees
samronsin c6e27d6
Fix broken test caused by Splitter init change
samronsin 187a534
Clean up
samronsin b4142c8
Make cython-lint happy
jjerphan 55a0544
Improve and test assert_1d_reg_tree_children_monotonic_bounded
samronsin e92a10a
Remove excessive assertions from test_assert_nd_reg_tree_children_mon…
samronsin ca7f031
Add tree ensembles to estimator tests
samronsin e49a58b
Clean up tests
samronsin e89fa57
Optimize Criterion modifications
samronsin 80594a2
Black stuff + check that float value is not cast too early to int8
samronsin 7f9dc71
Add test with opposite monotonicity data and constraints
samronsin 4e3edac
Implement value clipping
samronsin 4e1d784
Remove redundant tests: splitter kwarg is equivalent to choice of {De…
samronsin cec0207
Merge branch 'main' into monotonic-trees
samronsin 4e509fe
Extend test coverage to random splitters
samronsin c0483da
Add support for absolute error regression criterion
samronsin 87bae8b
Merge branch 'main' into monotonic-trees
samronsin 16a8863
Mark missing values as unsupported
samronsin c08c4bf
Update docstrings to specify training data with missing values is not…
samronsin e77c505
DOC Add changelog entries
jjerphan 75242d9
Merge branch 'main' into monotonic-trees
jjerphan 9b3bc22
Add comment regarding monotonic_cst sign flipping for classification …
samronsin 816778d
Use np.isin to validate monotonic_cst
samronsin 88ae965
Update whats_new
samronsin 31d5edb
Fix lign too long
samronsin e763020
Merge branch 'main' into monotonic-trees
samronsin 57c78a5
Add pointers to user guide
samronsin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.