Bearloga has submitted this change and it was merged.

Change subject: Fix exponentiating bug
......................................................................


Fix exponentiating bug

Forgot that exp isn't the inverse of log10. Back-transforming data
using the correct exp10(x) = 10^x function. D'oh.

Change-Id: I250a4ca73d7a3308c20aebf05cfc75c4dd3abe9e
---
M server.R
M utils.R
2 files changed, 11 insertions(+), 3 deletions(-)

Approvals:
  Bearloga: Verified; Looks good to me, approved



diff --git a/server.R b/server.R
index faa43e9..753164c 100644
--- a/server.R
+++ b/server.R
@@ -21,8 +21,8 @@
       conditional_transform(input$usage_logscale && 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage) != "day", 
log10) %>%
       # ...THEN smoothed:
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage), rename = 
FALSE) %>%
-      # ...and then exp-transformed back to the original scale:
-      conditional_transform(input$usage_logscale && 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage) != "day", 
exp) %>%
+      # ...and then exp10-transformed back to the original scale:
+      conditional_transform(input$usage_logscale && 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage) != "day", 
exp10) %>%
       polloi::subset_by_date_range(time_frame_range(input$usage_timeframe, 
input$usage_timeframe_daterange)) %>%
       polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Daily WDQS 
Homepage usage", group = "usage") %>%
       # ...because we're using dygraphs' native log-scaling:
@@ -37,7 +37,7 @@
       # See above for why we're conditional_transform'ing here.
       conditional_transform(input$usage_logscale && 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage) != "day", 
log10) %>%
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage), rename = 
FALSE) %>%
-      conditional_transform(input$usage_logscale && 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage) != "day", 
exp) %>%
+      conditional_transform(input$usage_logscale && 
polloi::smooth_switch(input$smoothing_global, input$smoothing_usage) != "day", 
exp10) %>%
       polloi::subset_by_date_range(time_frame_range(input$usage_timeframe, 
input$usage_timeframe_daterange)) %>%
       polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Daily 
SPARQL usage", group = "usage") %>%
       dyLegend(labelsDiv = "usage_legend") %>%
diff --git a/utils.R b/utils.R
index b3680f9..d488d78 100644
--- a/utils.R
+++ b/utils.R
@@ -47,3 +47,11 @@
   x[, col_names] <- .f(x[, col_names], ...)
   return(x)
 }
+
+pow <- function(base, exponent) {
+  return(base^exponent)
+}
+
+exp10 <- function(x) {
+  return(pow(10, x))
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/303614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I250a4ca73d7a3308c20aebf05cfc75c4dd3abe9e
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/twilightsparql
Gerrit-Branch: master
Gerrit-Owner: Bearloga <[email protected]>
Gerrit-Reviewer: Bearloga <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to