library(ERTMon) library(magrittr)
set.seed(342) numberOfPipelines <- 300 testData <- ERTMonSimpleTestData( numberOfEntities = 4, numberOfVariables = 5, timeInterval = 900, numberOfTimeCells = 12, randomStartTimesQ = T, variableFunction = "random", exportDirectoryName = NULL) testData2 <- ERTMonSimpleTestData( numberOfEntities = 2, numberOfVariables = 5, timeInterval = 900, numberOfTimeCells = 12, randomStartTimesQ = T, variableFunction = "random", exportDirectoryName = NULL)
formulaSpecDF <- data.frame( "FormulaID" = c(1), "TermID" = c(1,1,1,2,2), "TermCoefficient" = c( 0.5, 0.5, 0.5, 1.2, 1.2), "FeatureName" = c("Var.1.Mean", "Var.2.Mean", "Var.3.Mean", "Var.4.Mean", "Var.5.Mean"), "ReduceFunction" = c("+"), "Coefficient" = c(1, 2, 3, 1, 1), "Exponent" = c(1.5, 1, 2, 1, 1), "RatioPart" = c( "Numerator", "Denominator", "Denominator", "Numerator", "Denominator"), stringsAsFactors = FALSE)
pipelineLevels <- list( level1 = c( "ERTMonUnit()", "ERTMonUnit( testData$EventRecords, testData$EntityAttributes, testData$ComputationSpecification )", "ERTMonUnit( testData2$EventRecords, testData2$EntityAttributes, testData2$ComputationSpecification )"), level2 = c( "ERTMonSetEventRecords(testData$EventRecords)", "ERTMonSetEntityAttributes(testData$EntityAttributes)", "ERTMonSetComputationSpecification(testData$ComputationSpecification)" ), level3 = c( "ERTMonProcessEventRecords( echoStepsQ = FALSE )", "ERTMonProcessEventRecords( alignmentSpec = 'MinTime', echoStepsQ = FALSE )", "ERTMonProcessEventRecords( alignmentSpec = min(testData$EventRecords$ObservationTime), echoStepsQ = FALSE )" ), level4 = c( "ERTMonExtractFeatures( testData2$EventRecords, testData2$EntityAttributes, echoStepsQ = FALSE )", "ERTMonExtractFeatures( testData2$EventRecords, testData2$EntityAttributes, testData2$ComputationSpecification )", "ERTMonTakeFeatureMatrix()", "ERTMonComputeFormula(formulaSpecDF)" ) )
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( ertRes <- purrr::map( randomPipelines, purrr::safely(eval)) )
checkRes <- purrr::map_lgl( ertRes, function(x) is.na(x$result) || is.list(x$result) && class(x$result) == "ERTMon" )
summary(checkRes)
mean(is.na(purrr::map( ertRes, "result")))
obj<- ERTMonUnit() %>% ERTMonSetEventRecords(testData$EventRecords) %>% ERTMonSetEntityAttributes(testData$EntityAttributes) %>% ERTMonSetComputationSpecification(testData$ComputationSpecification) %>% ERTMonProcessEventRecords( alignmentSpec = 'MinTime', echoStepsQ = FALSE ) %>% ERTMonExtractFeatures( testData2$EventRecords, testData2$EntityAttributes, echoStepsQ = FALSE ) %>% ERTMonPlotFeatureMatrices() %>% (function( ertMon ) { print( ggplot( ertMon %>% ERTMonTakeTrasformedData ) + geom_histogram( aes(x=AValue) ) + facet_wrap( ~MatrixName, scales = "free" ) ) ertMon }) %>% ERTMonExport(directoryName = "~/Desktop", modelID = "DemoModMed2")
ggplot( obj %>% ERTMonTakeTrasformedData ) + geom_histogram( aes(x=AValue) ) + facet_wrap( ~MatrixName, scales = "free" )
obj <- ERTMonUnit() obj <- ERTMonSetEventRecords(obj, testData$EventRecords) obj <- ERTMonSetEntityAttributes(obj, testData$EntityAttributes) obj <- ERTMonSetComputationSpecification(obj, testData$ComputationSpecification) obj <- ERTMonProcessEventRecords( obj, alignmentSpec = 'MinTime', echoStepsQ = FALSE ) ERTMonTakeFeatureMatrix(obj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.