devtools::load_all()
library(magrittr)

Introduction

This notebook can be used to create a (large) number of random QRMon pipelines, summarize the results pipelines' evaluations, and if needed examine 'failing' pipelines for debugging purposes.

Random pipelines making

set.seed(5427)
numberOfPipelines <- 120
pipelineLevels <-
  list( level1 = c( "QRMonUnit()",
                    "QRMonUnit( dfDistributionData )",
                    "QRMonUnit( dfFinancialData )",
                    "QRMonUnit( dfTemperatureData )" ),

        level2 = c( "QRMonRescale",
                    "QRMonRescale(TRUE)",
                    "QRMonRescale(FALSE, TRUE)",
                    "QRMonEchoDataSummary",
                    "QRMonEchoDataSummary()" ),

        level3 = c( "QRMonQuantileRegression",
                    "QRMonQuantileRegression( df = 6, degree = 7, probabilities = 0.5)",
                    "QRMonQuantileRegression( df = 12, probabilities = c(0.1,0.9))",
                    "QRMonQuantileRegression( df = 2, probabilities = 1:5/6)",
                    "QRMonQuantileRegression( df = 3, probabilities = runif( runif(1, min = 1, max = 6), min = 0, max = 1) )"),

        level4 = c( "QRMonPredict()",
                    "QRMonPredict",
                    "QRMonErrors()",
                    "QRMonErrors",
                    "QRMonOutliers()",
                    "QRMonPickPathPoints(0.2)",
                    "QRMonConditionalCDF( 0 )" )
  )
randomPipelines <- 
  purrr::map( 1:numberOfPipelines, 
              function(x) { 
                rp <- Reduce( function(a,x) { c( a, sample(x,1) )}, init = c(), x = pipelineLevels ) 
                parse( text = paste( rp, collapse = " %>% " ))
              })
system.time(
  qrMonRes <- purrr::map( randomPipelines, purrr::safely(eval))
)
checkRes <- purrr::map_lgl( qrMonRes, function(x) is.na(x$result) || is.list(x$result) && class(x$result) == "QRMon" )
summary(checkRes)
mean(is.na(purrr::map( qrMonRes, "result")))

Debug

pos <- which( checkRes %in% c(NA) )
pos
randomPipelines[pos]


antononcube/QRMon-R documentation built on July 26, 2021, 1:07 p.m.