|
2 | 2 | source("../_setup.R") |
3 | 3 | ``` |
4 | 4 |
|
| 5 | +```{r _subset_warning, results='asis'} |
| 6 | +if (isTRUE(metadata$input_subset_enable)) { |
| 7 | + cat(paste0( |
| 8 | + "\n\n::: {.callout-warning}\n", |
| 9 | + "## Subset Mode Active\n\n", |
| 10 | + "This model was trained on a **", |
| 11 | + scales::percent(metadata$input_subset_fraction, accuracy = 1), |
| 12 | + " stratified subset** of the training data. ", |
| 13 | + "Test set performance metrics are based on the subset and may not ", |
| 14 | + "reflect full model performance. Assessment set performance uses the ", |
| 15 | + "full assessment data.\n", |
| 16 | + ":::\n\n" |
| 17 | + )) |
| 18 | +} |
| 19 | +``` |
| 20 | + |
5 | 21 | # Model |
6 | 22 |
|
7 | 23 | The following document describes performance for ```r metadata$run_id```, a ```r model_parameter_final$engine``` model built to re-assess the ```r metadata$assessment_triad``` triad in ```r metadata$assessment_year```. The document uses four sets of data to measure performance: |
@@ -188,7 +204,7 @@ model_township_stats_assessment_df %>% |
188 | 204 |
|
189 | 205 | ::: |
190 | 206 |
|
191 | | -Prior year values (latest stage available for each year) compared to target year sales and estimates. |
| 207 | +Prior year values (latest stage available for each year) compared to ***target year*** sales and estimates. |
192 | 208 | The median percent change is comparing the nearest assessed value to the estimated value. |
193 | 209 | PIN and sale counts include residential, regression-class properties only. |
194 | 210 |
|
@@ -281,9 +297,11 @@ model_ratio_distribution_df <- model_performance_test_quantile_merged %>% |
281 | 297 | ) |
282 | 298 | ) |
283 | 299 |
|
284 | | -model_ratio_distribution_labels <- model_ratio_distribution_df %>% |
| 300 | +model_ratio_distribution <- model_ratio_distribution_df %>% |
285 | 301 | filter(stage == "Main Model") %>% |
286 | | - pull(custom_label) |
| 302 | + arrange(quantile) |
| 303 | +model_ratio_distribution_breaks <- model_ratio_distribution$quantile |
| 304 | +model_ratio_distribution_labels <- model_ratio_distribution$custom_label |
287 | 305 |
|
288 | 306 | # Manually set axes to highest and lowest contained in the data |
289 | 307 | model_ratio_distribution_lims <- model_performance_test_quantile_merged %>% |
@@ -318,7 +336,10 @@ model_ratio_distribution_triad_plot <- ggplot( |
318 | 336 | ) + |
319 | 337 | geom_hline(yintercept = 1, linetype = "dashed", color = "darkgray") + |
320 | 338 | labs(x = "Decile", y = "Median Ratio", color = "Model Type") + |
321 | | - scale_x_continuous(breaks = 1:10, labels = model_ratio_distribution_labels) + |
| 339 | + scale_x_continuous( |
| 340 | + breaks = model_ratio_distribution_breaks, |
| 341 | + labels = model_ratio_distribution_labels |
| 342 | + ) + |
322 | 343 | scale_color_manual( |
323 | 344 | values = c( |
324 | 345 | "Main Model" = plot_colors$main, |
@@ -366,9 +387,11 @@ generate_model_ratio_township_graph <- function(data, township, lims) { |
366 | 387 | ) |
367 | 388 | ) |
368 | 389 |
|
369 | | - data_to_plot_labels <- data_to_plot %>% |
| 390 | + data_to_plot_main <- data_to_plot %>% |
370 | 391 | filter(stage == "Main Model") %>% |
371 | | - pull(custom_label) |
| 392 | + arrange(quantile) |
| 393 | + data_to_plot_breaks <- data_to_plot_main$quantile |
| 394 | + data_to_plot_labels <- data_to_plot_main$custom_label |
372 | 395 |
|
373 | 396 | ggplot( |
374 | 397 | data = data_to_plot, |
@@ -400,7 +423,10 @@ generate_model_ratio_township_graph <- function(data, township, lims) { |
400 | 423 | lims$min_value, |
401 | 424 | lims$max_value + 0.08 |
402 | 425 | )) + |
403 | | - scale_x_continuous(breaks = 1:10, labels = data_to_plot_labels) + |
| 426 | + scale_x_continuous( |
| 427 | + breaks = data_to_plot_breaks, |
| 428 | + labels = data_to_plot_labels |
| 429 | + ) + |
404 | 430 | scale_color_manual( |
405 | 431 | values = c( |
406 | 432 | "Main Model" = plot_colors$main, |
@@ -937,11 +963,10 @@ model_big_misses_test <- test_card %>% |
937 | 963 | ) %>% |
938 | 964 | mutate( |
939 | 965 | Difference = abs(`Sale Price` - `Est. FMV`), |
940 | | - `Qnt.` = cut( |
941 | | - `Sale Price`, |
942 | | - breaks = quantile(`Sale Price`, probs = c(0, 0.25, 0.5, 0.75, 1)), |
943 | | - labels = c("Q1", "Q2", "Q3", "Q4"), |
944 | | - include.lowest = TRUE |
| 966 | + `Qnt.` = factor( |
| 967 | + ntile(`Sale Price`, n = 4), |
| 968 | + levels = 1:4, |
| 969 | + labels = c("Q1", "Q2", "Q3", "Q4") |
945 | 970 | ), |
946 | 971 | .by = Town |
947 | 972 | ) %>% |
@@ -995,11 +1020,10 @@ model_big_misses_assessment <- assessment_pin %>% |
995 | 1020 | ) %>% |
996 | 1021 | mutate( |
997 | 1022 | Difference = abs(`Sale 1 Price` - `Est. FMV`), |
998 | | - `Qnt.` = cut( |
999 | | - `Sale 1 Price`, |
1000 | | - breaks = quantile(`Sale 1 Price`, probs = c(0, 0.25, 0.5, 0.75, 1)), |
1001 | | - labels = c("Q1", "Q2", "Q3", "Q4"), |
1002 | | - include.lowest = TRUE |
| 1023 | + `Qnt.` = factor( |
| 1024 | + ntile(`Sale 1 Price`, n = 4), |
| 1025 | + levels = 1:4, |
| 1026 | + labels = c("Q1", "Q2", "Q3", "Q4") |
1003 | 1027 | ), |
1004 | 1028 | .by = Town |
1005 | 1029 | ) %>% |
|
0 commit comments