-
Notifications
You must be signed in to change notification settings - Fork 17
Implement configurable options for comps algorithm methodology #449
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
wagnerlmichael
merged 34 commits into
master
from
405-persist-all-possible-significant-sales-algorithms-to-the-code
Feb 26, 2026
+282
−41
Merged
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
5bf04c5
4 working functions
Damonamajor 22e38e5
Update comps docs
wagnerlmichael 5b655cf
Add algorithm param for extract_tree_weights
wagnerlmichael 6f0ece5
Add input checking
wagnerlmichael 363b108
Adjust tree_weights shape checking
wagnerlmichael 123dd81
Test vector inclusion
wagnerlmichael 4c0d8cc
Attempt using only 1 get_top_comps function
wagnerlmichael b52fbd8
Fix message
wagnerlmichael 1923e19
Switch boolean check
wagnerlmichael 972772c
Style
wagnerlmichael 1f6bf19
Format
wagnerlmichael 365dee4
Lint
wagnerlmichael fa8ce67
Lint
wagnerlmichael b433e60
Merge branch 'master' into 405-persist-all-possible-significant-sales…
wagnerlmichael d32eb89
Update R/helpers.R
wagnerlmichael 441c4cd
Update R/helpers.R
wagnerlmichael 5ca1ed7
Update R/helpers.R
wagnerlmichael 1e32a95
Update tests to accomdate vector weight support
wagnerlmichael 899450c
Remove redundant test
wagnerlmichael 4e269fc
Fix failing Python test infrastructure on CI
jeancochrane 3396b13
improve commenting
Damonamajor f0d3540
Merge branch 'master' into 405-persist-all-possible-significant-sales…
wagnerlmichael 7136808
Make sure to install test dependencies in `test` workflow
jeancochrane 82605f8
Fix incorrect path reference in interpret stage
jeancochrane 1200ea3
CHeck to make sure weights sum to 1
wagnerlmichael 39d4d03
Merge branch '405-persist-all-possible-significant-sales-algorithms-t…
wagnerlmichael 51c582c
Merge branch 'jeancochrane/fix-failing-test-workflow' into 405-persis…
wagnerlmichael 1cfb285
Update helpers.R
Damonamajor 6bb28ec
Merge branch 'master' into 405-persist-all-possible-significant-sales…
jeancochrane dc09147
Add param to finalize.R
Damonamajor 2215b3d
alphabetize
Damonamajor 0d55dc1
Add in-place adustment
wagnerlmichael a775f6e
Merge branch '405-persist-all-possible-significant-sales-algorithms-t…
wagnerlmichael ffa4f1b
Remove space
wagnerlmichael 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,8 +28,6 @@ reticulate::py_require( | |
| purrr::walk(list.files("R/", "\\.R$", full.names = TRUE), source) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # 2. Load Data ----------------------------------------------------------------- | ||
| #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|
|
@@ -155,8 +153,6 @@ if (shap_enable) { | |
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # 4. Calculate Feature Importance ---------------------------------------------- | ||
| #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|
|
@@ -176,8 +172,6 @@ lightgbm::lgb.importance(lgbm_final_full_fit$fit) %>% | |
| write_parquet(paths$output$feature_importance$local) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # 5. Find Comparables --------------------------------------------------------- | ||
| #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|
|
@@ -271,19 +265,33 @@ if (comp_enable) { | |
| model = lgbm_final_full_fit$fit, | ||
| leaf_idx = as.matrix(training_leaf_nodes), | ||
| init_score = mean(training_data$meta_sale_price, na.rm = TRUE), | ||
| algorithm = params$comp$algorithm, | ||
| outcome = training_data$meta_sale_price | ||
| ) | ||
|
|
||
| if (length(tree_weights) == 0) { | ||
| message("Warning: tree_weights are empty") | ||
| } | ||
| if (all(rowSums(tree_weights) %in% c(0, 1))) { | ||
| message("Warning: tree_weights do not sum to 1 or 0 for each row") | ||
| message("First 5 weights:") | ||
| print(head(tree_weights, 5)) | ||
| if (is.matrix(tree_weights)) { | ||
| if (!all(rowSums(tree_weights) %in% c(0, 1))) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the negation here because unless I'm reading incorrectly, I think that we had this backwards? |
||
| message("Warning: tree_weights do not sum to 1 or 0 for each row") | ||
| message("First 5 weights:") | ||
| print(head(tree_weights, 5)) | ||
| } | ||
| } else { | ||
| tree_weights_sum <- sum(tree_weights) | ||
| if (!isTRUE(all.equal(tree_weights_sum, 1))) { | ||
| stop( | ||
| "Tree weights vector does not sum to 1 (got ", tree_weights_sum, "). ", | ||
| "All sales would have a score of 0 if weights sum to 0." | ||
| ) | ||
| } | ||
| message( | ||
| "Tree weights are a vector of length ", length(tree_weights), | ||
| " (same weights for all training observations)" | ||
| ) | ||
jeancochrane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
|
|
||
| # Make sure that the leaf node tibbles are all integers, which is what | ||
| # the comps algorithm expects | ||
| leaf_nodes <- leaf_nodes %>% | ||
|
|
||
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.
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.