Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
# setwd('~/Dropbox/ImageSeq/')
|
| 2 |
|
|
|
|
| 3 |
library(shiny)
|
| 4 |
library(dplyr)
|
| 5 |
library(fields) # For image.plot in heatMap
|
|
@@ -104,7 +105,8 @@ ui <- fluidPage(
|
|
| 104 |
checkboxInput("compareToBest", "Compare to best single scale", value = FALSE)
|
| 105 |
),
|
| 106 |
mainPanel(
|
| 107 |
-
plotOutput("heatmapPlot", height = "600px")
|
|
|
|
| 108 |
)
|
| 109 |
)
|
| 110 |
)
|
|
@@ -230,12 +232,13 @@ server <- function(input, output) {
|
|
| 230 |
if (input$compareToBest) {
|
| 231 |
z <- grouped_data$improvement
|
| 232 |
main <- paste(input$application, "-", input$metric, "improvement over best single scale")
|
| 233 |
-
max_abs <- max(abs(z), na.rm = TRUE)
|
| 234 |
-
zlim <- if (!is.na(max_abs)) c(-max_abs, max_abs) else NULL
|
|
|
|
| 235 |
} else {
|
| 236 |
z <- grouped_data$mean_metric
|
| 237 |
main <- paste(input$application, "-", input$metric)
|
| 238 |
-
zlim <- range(z, na.rm = TRUE)
|
| 239 |
}
|
| 240 |
|
| 241 |
customPalette <- colorRampPalette(c("blue", "white", "red"))(50)
|
|
@@ -245,13 +248,57 @@ server <- function(input, output) {
|
|
| 245 |
N = 50,
|
| 246 |
main = main,
|
| 247 |
xlab = "Image Dimension 1",
|
| 248 |
-
ylab = "Image
|
| 249 |
useLog = "xy",
|
| 250 |
myCol = customPalette,
|
| 251 |
cex.lab = 1.4,
|
| 252 |
zlim = zlim,
|
| 253 |
optimal_point = interp_data$optimal_point)
|
| 254 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
}
|
| 256 |
|
| 257 |
# Run the Shiny App
|
|
|
|
| 1 |
# setwd('~/Dropbox/ImageSeq/')
|
| 2 |
|
| 3 |
+
options(error = NULL)
|
| 4 |
library(shiny)
|
| 5 |
library(dplyr)
|
| 6 |
library(fields) # For image.plot in heatMap
|
|
|
|
| 105 |
checkboxInput("compareToBest", "Compare to best single scale", value = FALSE)
|
| 106 |
),
|
| 107 |
mainPanel(
|
| 108 |
+
plotOutput("heatmapPlot", height = "600px"),
|
| 109 |
+
div(style = "margin-top: 10px; font-style: italic;", uiOutput("contextNote"))
|
| 110 |
)
|
| 111 |
)
|
| 112 |
)
|
|
|
|
| 232 |
if (input$compareToBest) {
|
| 233 |
z <- grouped_data$improvement
|
| 234 |
main <- paste(input$application, "-", input$metric, "improvement over best single scale")
|
| 235 |
+
#max_abs <- max(abs(z), na.rm = TRUE)
|
| 236 |
+
#zlim <- if (!is.na(max_abs)) c(-max_abs, max_abs) else NULL
|
| 237 |
+
zlim <- range(z, na.rm = TRUE)
|
| 238 |
} else {
|
| 239 |
z <- grouped_data$mean_metric
|
| 240 |
main <- paste(input$application, "-", input$metric)
|
| 241 |
+
zlim <- range(z, na.rm = TRUE)
|
| 242 |
}
|
| 243 |
|
| 244 |
customPalette <- colorRampPalette(c("blue", "white", "red"))(50)
|
|
|
|
| 248 |
N = 50,
|
| 249 |
main = main,
|
| 250 |
xlab = "Image Dimension 1",
|
| 251 |
+
ylab = "Image Dimension 2",
|
| 252 |
useLog = "xy",
|
| 253 |
myCol = customPalette,
|
| 254 |
cex.lab = 1.4,
|
| 255 |
zlim = zlim,
|
| 256 |
optimal_point = interp_data$optimal_point)
|
| 257 |
})
|
| 258 |
+
|
| 259 |
+
# Contextual Note Output
|
| 260 |
+
output$contextNote <- renderText({
|
| 261 |
+
if (input$compareToBest) {
|
| 262 |
+
paste("This heatmap shows the improvement in", input$metric,
|
| 263 |
+
"over the best single scale for", input$application,
|
| 264 |
+
"using the", input$model, "model. The green star marks the optimal point.",
|
| 265 |
+
"The Peru RCT involves a multifaceted graduation program treatment to reduce poverty outcomes.",
|
| 266 |
+
"The Uganda RCT involves a cash grant program to stimulate human capital and living conditions among the poor.",
|
| 267 |
+
"For more information, see <a href='https://arxiv.org/abs/2411.02134' target='_blank'>https://arxiv.org/abs/2411.02134</a>",
|
| 268 |
+
"<div style='font-size: 10px; line-height: 1.5;'>",
|
| 269 |
+
"<b>Glossary:</b><br>",
|
| 270 |
+
"• <b>Model:</b> The neural-network backbone (e.g., clip-rsicd) transforming satellite images into numerical representations.<br>",
|
| 271 |
+
"• <b>Metric:</b> The criterion (e.g., RATE Ratio, RMSE) measuring performance or heterogeneity detection.<br>",
|
| 272 |
+
"• <b>Compare to best single-scale:</b> Toggle showing metric improvement relative to the best single-scale baseline.<br>",
|
| 273 |
+
"• <b>ImageDim1, ImageDim2:</b> Image sizes (e.g., 64×64, 128×128) for multi-scale analysis.<br>",
|
| 274 |
+
"• <b>RATE Ratio:</b> Statistic indicating how well the model detects treatment-effect variation.<br>",
|
| 275 |
+
"• <b>PC:</b> Principal Components; a compression step of neural representations.<br>",
|
| 276 |
+
"• <b>MeanDiff, MeanDiff_pc:</b> Gain in RATE Ratio from multi-scale vs. single-scale, with '_pc' for compressed data.<br>",
|
| 277 |
+
"• <b>RMSE:</b> Root Mean Squared Error, measuring prediction accuracy in simulations.<br>",
|
| 278 |
+
"</div>"
|
| 279 |
+
)
|
| 280 |
+
} else {
|
| 281 |
+
paste("This heatmap displays", input$metric,
|
| 282 |
+
"for", input$application,
|
| 283 |
+
"using the", input$model,
|
| 284 |
+
"model across different image dimension combinations. The green star marks the optimal point.",
|
| 285 |
+
"The Peru RCT involves a multifaceted graduation program treatment to reduce poverty outcomes.",
|
| 286 |
+
"The Uganda RCT involves a cash grant program to stimulate human capital and living conditions among the poor.",
|
| 287 |
+
"For more information, see <a href='https://arxiv.org/abs/2411.02134' target='_blank'>https://arxiv.org/abs/2411.02134</a>",
|
| 288 |
+
"<div style='font-size: 10px; line-height: 1.5;'>",
|
| 289 |
+
"<b>Glossary:</b><br>",
|
| 290 |
+
"• <b>Model:</b> The neural-network backbone (e.g., clip-rsicd) transforming satellite images into numerical representations.<br>",
|
| 291 |
+
"• <b>Metric:</b> The criterion (e.g., RATE Ratio, RMSE) measuring performance or heterogeneity detection.<br>",
|
| 292 |
+
"• <b>Compare to best single-scale:</b> Toggle showing metric improvement relative to the best single-scale baseline.<br>",
|
| 293 |
+
"• <b>ImageDim1, ImageDim2:</b> Image sizes (e.g., 64×64, 128×128) for multi-scale analysis.<br>",
|
| 294 |
+
"• <b>RATE Ratio:</b> Statistic indicating how well the model detects treatment-effect variation.<br>",
|
| 295 |
+
"• <b>PC:</b> Principal Components; a compression step of neural representations.<br>",
|
| 296 |
+
"• <b>MeanDiff, MeanDiff_pc:</b> Gain in RATE Ratio from multi-scale vs. single-scale, with '_pc' for compressed data.<br>",
|
| 297 |
+
"• <b>RMSE:</b> Root Mean Squared Error, measuring prediction accuracy in simulations.<br>",
|
| 298 |
+
"</div>"
|
| 299 |
+
)
|
| 300 |
+
}
|
| 301 |
+
})
|
| 302 |
}
|
| 303 |
|
| 304 |
# Run the Shiny App
|