library(DMwR)
library(process)
library(rbenchmark)
library(ggplot2)
perf.test <- function(rows, cols, k)
{
  data <- matrix(rnorm(rows*cols), nrow = rows)
  res <- benchmark(lofactor(data, k), lof(data, k), replications = 3)[['elapsed']]
  res
}

time0 <- sapply(c(50, 100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000, 4000, 10000), 
                perf.test, cols = 4, k = 4)
time1 <- sapply(c(50, 100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000, 4000, 10000), 
                perf.test, cols = 8, k = 4)

time <- data.frame(label = rep(c('lof_4', 'lofactor_4', 'lof_8', 'lofactor_8'), each = 12), 
                   numberofnodes = rep(c(50, 100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000, 4000, 10000), 4), 
                   time = c(time0[1,], time0[2,], time1[1,], time1[2,]))
ggplot(time, aes(x = numberofnodes, y= log(time + 0.001))) +
  geom_line(aes(color = label))


evanwang1990/process documentation built on May 16, 2019, 9:38 a.m.