-
Notifications
You must be signed in to change notification settings - Fork 17
Add meta_pin_num_card to proration grouping #381
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9a48f0b
update proration
Damonamajor acdfd84
testing file
Damonamajor 5d8583d
update testing file
Damonamajor 3ab75f8
Update 02-assess.R
Damonamajor 8388a71
Delete testing_file.R
Damonamajor d2ea209
Merge branch 'master' into 371-update-proration-modeling
Damonamajor 9c56cfd
Revert to original
Damonamajor 3134c14
update hook
Damonamajor b672aba
Merge branch '371-update-proration-modeling' of github.com:ccao-data/…
Damonamajor 20f78fa
test push
Damonamajor 1815930
use updated modeling technique
Damonamajor 1defccd
Delete testing_file.R
Damonamajor 8accb22
Update .pre-commit-config.yaml
Damonamajor 4e256e5
Merge branch 'master' into 371-update-proration-modeling
Damonamajor 64ddd77
Update 02-assess.R
Damonamajor 303729c
Update 02-assess.R
Damonamajor 1eaa24c
Update 02-assess.R
Damonamajor ad1701f
Add meta_pin_num_cards to grouping and revert
Damonamajor 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #–– PARAMETERS ––# | ||
| run_id_val <- "2025-05-30-exciting-dan" | ||
| grouping_col <- "char_bldg_sf" | ||
|
|
||
| # 2025-02-11-charming-eric | ||
|
|
||
|
|
||
| #–– SETUP ––# | ||
| tictoc::tic.clearlog() | ||
| tictoc::tic("Ingest") | ||
|
|
||
| purrr::walk(list.files("R/", "\\.R$", full.names = TRUE), source) | ||
|
|
||
| suppressPackageStartupMessages({ | ||
| library(DBI) | ||
| library(igraph) | ||
| library(noctua) | ||
| library(glue) | ||
| library(dplyr) | ||
| }) | ||
|
|
||
| noctua_options(unload = TRUE) | ||
|
|
||
| AWS_ATHENA_CONN_NOCTUA <- dbConnect( | ||
| noctua::athena(), | ||
| rstudio_conn_tab = FALSE | ||
| ) | ||
|
|
||
|
|
||
| #–– LOAD DATA WITH PARAMETERIZED run_id ––# | ||
| data <- dbGetQuery( | ||
| conn = AWS_ATHENA_CONN_NOCTUA, | ||
| glue(" | ||
| SELECT | ||
| v.meta_tieback_key_pin, | ||
| card.meta_pin, | ||
| card.meta_card_num, | ||
| card.char_bldg_sf, | ||
| card.char_land_sf, | ||
| v.meta_tieback_proration_rate, | ||
| card.pred_card_initial_fmv AS pred_card_initial_fmv, | ||
| card.pred_card_final_fmv AS pred_card_final_fmv, | ||
| pin.pred_pin_initial_fmv AS pred_pin_initial_fmv, | ||
| pin.pred_pin_final_fmv AS pred_pin_final_fmv | ||
| FROM model.assessment_card AS card | ||
| JOIN model.vw_card_res_input AS v | ||
| ON CAST(card.meta_card_num AS VARCHAR) = CAST(v.meta_card_num AS VARCHAR) | ||
| AND CAST(card.meta_pin AS VARCHAR) = v.meta_pin | ||
| AND v.year = '2025' | ||
| JOIN model.assessment_pin AS pin | ||
| ON card.meta_pin = pin.meta_pin | ||
| AND card.run_id = pin.run_id | ||
| WHERE | ||
| v.meta_tieback_key_pin IS NOT NULL | ||
| AND card.run_id = '{run_id_val}' | ||
| ") | ||
| ) | ||
|
|
||
|
|
||
| group_cols <- c("meta_tieback_key_pin", grouping_col, "meta_card_num") | ||
|
|
||
|
|
||
| test <- data %>% | ||
| group_by(across(all_of(group_cols))) %>% | ||
| filter(n_distinct(pred_pin_initial_fmv) != 1) %>% | ||
| mutate(group_label = cur_group_id()) %>% | ||
| ungroup() | ||
|
|
||
|
|
||
| test_1 <- data %>% | ||
| group_by(across(all_of(group_cols))) %>% | ||
| filter(n_distinct(pred_card_initial_fmv) != 1) %>% | ||
| mutate(group_label = cur_group_id()) %>% | ||
| ungroup() | ||
|
|
||
|
|
||
| test_2 <- data %>% | ||
| group_by(across(all_of(group_cols))) %>% | ||
| filter(n_distinct(pred_card_final_fmv) != 1) %>% | ||
| mutate(group_label = cur_group_id()) %>% | ||
| ungroup() | ||
|
|
||
|
|
||
| test_3 <- data %>% | ||
| group_by(across(all_of(group_cols))) %>% | ||
| filter(n_distinct(pred_pin_final_fmv) != 1) %>% | ||
| mutate(group_label = cur_group_id()) %>% | ||
| ungroup() | ||
|
|
||
|
|
||
| tictoc::toc() | ||
|
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to then use our 2 / 3 card technique below this, which I'm not sure is how we want it to interact with prorated pins.