Skip to content

Instantly share code, notes, and snippets.

@ramhiser
Created January 12, 2017 21:26
Show Gist options
  • Save ramhiser/ebd6a15004110c8a4748cc2aa46d6bfc to your computer and use it in GitHub Desktop.
Save ramhiser/ebd6a15004110c8a4748cc2aa46d6bfc to your computer and use it in GitHub Desktop.
Symmetric MAPE following visualization in Figure 3c of the MAAPE Paper
library(dplyr)
library(ggplot2)
A <- seq(0, 10, length=100)
F <- seq(0, 10, length=100)
symmetric_mape <- function(A, F) {
abs(F - A) / (abs(A) + abs(F))
}
smape_grid <- tbl_df(expand.grid(A=A, F=F)) %>%
mutate(smape=symmetric_mape(A, F))
p <- ggplot(smape_grid, aes(x=A, y=F)) + geom_raster(aes(fill=smape))
p <- p + scale_fill_gradientn(colors=c("#0000FFFF","#FFFFFFFF","#FF0000FF"))
p + ggtitle("Visualization of SMAPE in 2D")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment