Skip to content

Commit

Permalink
Create data processing file
Browse files Browse the repository at this point in the history
  • Loading branch information
Damonamajor committed Jul 30, 2024
1 parent 3945e85 commit 362e8ba
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions data_processing.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
target_feature_value <- params$added_feature
target_feature_shap <- params$added_feature_shap
nbhd <- ccao::nbhd_shp

# Selecting and joining relevant data
card_individual <- shap %>%
select(meta_pin, meta_card_num, pred_card_shap_baseline_fmv, {{ target_feature_value }}) %>%

Check warning on line 7 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=7,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 94 characters.
rename(!!target_feature_shap := !!target_feature_value) %>%
inner_join(assessment_card, by = c("meta_pin", "meta_card_num")) %>%
inner_join(
assessment_data %>%
select(meta_pin, meta_card_num, meta_nbhd_code, loc_longitude, loc_latitude, meta_township_name),

Check warning on line 12 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=12,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 103 characters.
by = c("meta_pin", "meta_card_num")
)


# Summarizing data by neighborhood code
card_nbhd <- card_individual %>%
group_by(meta_nbhd_code) %>%
summarize(
avg_target_feature_shap = mean(!!sym({{target_feature_shap}}), na.rm = TRUE),

Check warning on line 21 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=21,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 83 characters.
avg_pred_card_shap_baseline_fmv = mean(pred_card_shap_baseline_fmv, na.rm = TRUE)

Check warning on line 22 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=22,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 85 characters.
) %>%
ungroup()


pin_individual <- assessment_pin %>%
select(meta_pin, pred_pin_final_fmv, pred_pin_initial_fmv) %>%
rename(
pred_pin_final_fmv_new = pred_pin_final_fmv,
pred_pin_initial_fmv_new = pred_pin_initial_fmv
) %>%
inner_join(
assessment_pin_comparison %>%
select(meta_pin, pred_pin_final_fmv, pred_pin_initial_fmv),
by = "meta_pin"
) %>%
rename(
pred_pin_final_fmv_comp = pred_pin_final_fmv,
pred_pin_initial_fmv_comp = pred_pin_initial_fmv
) %>%
mutate(
diff_pred_pin_final_fmv = round(((
pred_pin_final_fmv_new - pred_pin_final_fmv_comp) / pred_pin_final_fmv_comp) * 100, 2),

Check warning on line 44 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=44,col=6,[indentation_linter] Hanging indent should be 38 spaces but is 6 spaces.

Check warning on line 44 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=44,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.
pred_pin_final_fmv_new = dollar(pred_pin_final_fmv_new),
pred_pin_final_fmv_comp = dollar(pred_pin_final_fmv_comp),
diff_pred_pin_initial_fmv = round(((
pred_pin_initial_fmv_new - pred_pin_initial_fmv_comp) / pred_pin_initial_fmv_comp) * 100, 2),

Check warning on line 48 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=48,col=6,[indentation_linter] Hanging indent should be 40 spaces but is 6 spaces.

Check warning on line 48 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=48,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 99 characters.
pred_pin_initial_fmv_new = dollar(pred_pin_initial_fmv_new),
pred_pin_initial_fmv_comp = dollar(pred_pin_initial_fmv_comp)
) %>%
inner_join(
assessment_data %>%
select(meta_pin, meta_nbhd_code, loc_longitude, loc_latitude, meta_township_name, {{ target_feature_value }}),

Check warning on line 54 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=54,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 116 characters.
by = "meta_pin"
)

pin_nbhd <- pin_individual %>%
group_by(meta_nbhd_code) %>%
summarize(
!!paste0({{target_feature_value}}, "_neighborhood_mean") := mean(!!sym({{target_feature_value}}), na.rm = TRUE),

Check warning on line 61 in data_processing.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/data_processing.R,line=61,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 120 characters.
!!paste0({{target_feature_value}}, "_neighborhood_median") := median(!!sym({{target_feature_value}}), na.rm = TRUE),
!!paste0({{target_feature_value}}, "_neighborhood_90th") := quantile(!!sym({{target_feature_value}}), 0.9, na.rm = TRUE)
) %>%
ungroup() %>%
inner_join(
nbhd,
by = c("meta_nbhd_code" = "town_nbhd")
)

0 comments on commit 362e8ba

Please sign in to comment.