q()
library(lattice)
?levelplot
?lm
q()
ls()
rm(list = ls(all = TRUE))
ls
x <- sample(c(0,1), 100, replace=TRUE)
x
y <- sample(c(0,1), 100, replace = TRUE)
y
x
x <- sample(c(0,1), 100, replace = TRUE)#
y <- sample(c(0,1), 100, replace = TRUE)#
p <- runif(100)#
cuts <- seq(0,1, length.out = 100)
cuts
labels <- sample(c(0,1), 100, replace = TRUE)#
pred <- sample(c(0,1), 100, replace = TRUE)#
p <- runif(100)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.aux <- function(labels, pred, p, cuts) {#
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1L) { ### true positive#
        if((1-p[i]) < cut[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[i]) < cut[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
  }#
}
true_pos
false_pos
labels <- sample(c(0,1), 200, replace = TRUE)#
pred <- sample(c(0,1), 200, replace = TRUE)#
p <- runif(200)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.aux <- function(labels, pred, p, cuts) {#
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cut[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cut[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
  }#
}
true_pos
false_pos
labels <- sample(c(0,1), 200, replace = TRUE)#
pred <- sample(c(0,1), 200, replace = TRUE)#
p <- runif(200)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.aux <- function(labels, pred, p, cuts) {#
  #
  N <- length(labels)#
  x <- vector('list', length(cuts))#
  #
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cut[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cut[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
    x[[i]] <- c(true_pos / N, false_pos / N)#
  }#
}#
#
calculate.auc(labels, pred, p, cuts)
labels <- sample(c(0,1), 200, replace = TRUE)#
pred <- sample(c(0,1), 200, replace = TRUE)#
p <- runif(200)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.auc <- function(labels, pred, p, cuts) {#
  #
  N <- length(labels)#
  x <- vector('list', length(cuts))#
  #
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cut[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cut[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
    x[[i]] <- c(true_pos / N, false_pos / N)#
  }#
}#
#
calculate.auc(labels, pred, p, cuts)
labels <- sample(c(0,1), 200, replace = TRUE)#
pred <- sample(c(0,1), 200, replace = TRUE)#
p <- runif(200)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.auc <- function(labels, pred, p, cuts) {#
  #
  N <- length(labels)#
  x <- vector('list', length(cuts))#
  #
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
    x[[i]] <- c(true_pos / N, false_pos / N)#
  }#
}#
#
calculate.auc(labels, pred, p, cuts)
labels <- sample(c(0,1), 200, replace = TRUE)#
pred <- sample(c(0,1), 200, replace = TRUE)#
p <- runif(200)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.auc <- function(labels, pred, p, cuts) {#
  #
  N <- length(labels)#
  x <- vector('list', length(cuts))#
  #
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
    x[[i]] <- c(true_pos / N, false_pos / N)#
  }#
  return(x)#
}#
#
calculate.auc(labels, pred, p, cuts)
labels <- sample(c(0,1), 200, replace = TRUE)#
pred <- sample(c(0,1), 200, replace = TRUE)#
p <- runif(200)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.auc <- function(labels, pred, p, cuts) {#
  #
  N <- length(labels)#
  x <- vector('list', length(cuts))#
  #
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
    x[[i]] <- c(true_pos / N, false_pos / N)#
  }#
  return(x)#
}#
#
x <- calculate.auc(labels, pred, p, cuts)#
x <- do.call("rbind", x)
x
plot(x[,1], x[,2])
datasize <- 1000#
#
labels <- sample(c(0,1), datasize, replace = TRUE)#
pred <- sample(c(0,1), datasize, replace = TRUE)#
p <- runif(datasize)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.auc <- function(labels, pred, p, cuts) {#
  #
  N <- length(labels)#
  x <- vector('list', length(cuts))#
  #
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
    x[[i]] <- c(true_pos / N, false_pos / N)#
  }#
  return(x)#
}#
#
x <- calculate.auc(labels, pred, p, cuts)#
x <- do.call("rbind", x)
x
datasize <- 100000#
#
labels <- sample(c(0,1), datasize, replace = TRUE)#
pred <- sample(c(0,1), datasize, replace = TRUE)#
p <- runif(datasize)#
cuts <- seq(0,1, length.out = 100)#
#
true_pos <- false_pos <- 0#
#
calculate.auc <- function(labels, pred, p, cuts) {#
  #
  N <- length(labels)#
  x <- vector('list', length(cuts))#
  #
  for(i in seq_along(cuts)) {#
    for(j in seq_along(labels)) {#
      if(labels[j] == 1) { ### true positive#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          true_pos <- true_pos + 1           #
        }#
      } else { ### true negative#
        if((1-p[j]) < cuts[i]) { ### classified as true#
          false_pos <- false_pos + 1#
        }	#
      }#
    }#
    x[[i]] <- c(true_pos / N, false_pos / N)#
  }#
  return(x)#
}#
#
x <- calculate.auc(labels, pred, p, cuts)#
x <- do.call("rbind", x)
cuts
diff(cuts)
rm(list = ls(all = TRUE))
q(save = "y")
q(save = "yes")
library(RSofia)
?RSofia
seq_len
q()
sofia
sofia.formula
q()
library(RUnit)
checkEquals
?checkEquals
q()
ls
ls()
"x" <- function(a, b, c) a + b + c
x
paste("a","b", sep ="") <- function(a, b, c) a * b * c
create_function_text <- function(learner, loop) {#
#
  function_txt <- ""#
  #
  function_txt <- paste("LOOP_TYPE = ", loop, #
                        "LEARNER_TYPE = ", learner,#
                        "\n",#
                        "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED",#
                        ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights",#
                        ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = "_")]]",#
                        "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)")#
                        #
  cat(function_txt)#
#
	#
}
create_function_text <- function(learner, loop) {#
#
  function_txt <- paste("LOOP_TYPE = ", loop, #
      "LEARNER_TYPE = ", learner,#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)")#
                        #
  cat(function_txt)#
#
	#
}
create_function_text <- function(learner, loop) {#
#
  function_txt <- paste("LOOP_TYPE = ", loop, #
      "LEARNER_TYPE = ", learner,#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
x <- "hello-this-is"
x
gsub("-","_",x)
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub(learner,"-","_"),"."#
    , gsub(loop, "-","_")#
    , "{ \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE = ", loop, #
      "LEARNER_TYPE = ", learner,#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "\n")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub(learner,"-","_"),"."#
    , gsub(loop, "-","_")#
    , "{ \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE = ", loop, "\n",#
      "LEARNER_TYPE = ", learner, "\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = " ")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub(learner,"-","_"),"."#
    , gsub(loop, "-","_")#
    , "{ \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- ", loop, "\n",#
      "LEARNER_TYPE <- ", learner, "\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = " ")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
gsub
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , "{ \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- ", loop, "\n",#
      "LEARNER_TYPE <- ", learner, "\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = " ")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- ", loop, "\n",#
      "LEARNER_TYPE <- ", learner, "\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = " ")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- ", loop, "\n",#
      "LEARNER_TYPE <- ", learner, "\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- ", loop, "\n",#
      "LEARNER_TYPE <- \'", learner, "'\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- ", loop, "\n",#
      "LEARNER_TYPE <- '", learner, "'\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- '", loop, "'\n",#
      "LEARNER_TYPE <- '", learner, "'\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- '", loop, "'\n",#
      "LEARNER_TYPE <- '", learner, "'\n\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop)#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- '", loop, "'\n",#
      "LEARNER_TYPE <- '", learner, "'\n\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), " <- function()",#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- '", loop, "'\n",#
      "LEARNER_TYPE <- '", learner, "'\n\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("LOOP_TYPE <- '", loop, "'\n",#
      "LEARNER_TYPE <- '", learner, "'\n\n",#
      "weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      ", learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n",#
      ", weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste("  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n\n",#
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic")
create_function_text <- function(learner, loop, eta) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta)," <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic", "pegasos")
sofia
library(RSofia)
sofia.fit
?sofia.fit
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic", "pegasos")
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE)$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic", "pegasos", 1)
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic", "pegasos", 1)
logical(1)
as.logical(1)
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic", "pegasos", TRUE)
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic", "pegasos", FALSE)
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
create_function_text("pegasos", "stochastic", "pegasos", FALSE)
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  cat(function_txt)#
#
	#
}#
#
x <- create_function_text("pegasos", "stochastic", "pegasos", FALSE)
x
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  return(function_txt)#
#
	#
}#
#
x <- create_function_text("pegasos", "stochastic", "pegasos", FALSE)
x
parse(x)
parse
parse(text = x)
x.parsed <- parse(text = x)
x
str(x)
x.parsed
x.parsed(1)
eval(x.parsed)
test.sofia.pegasos.stochastic.pegasos.bias0
test.sofia.pegasos.stochastic.pegasos.bias0(1)
LEARNER_TYPE=c( "pegasos", "sgd-svm", "passive-aggressive", "margin-perceptron", "romma", "logreg-pegasos" )#
LOOP_TYPE=c( "stochastic", "balanced-stochastic", "rank", "roc", "query-norm-rank", "combined-ranking", "combined-roc" )#
ETA_TYPE=c( "pegasos", "basic", "constant" )#
#
#
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  return(function_txt)#
#
	#
}#
#
x <- create_function_text("pegasos", "stochastic", "pegasos", FALSE)
l
LEARNER_TYPE <- c( "pegasos", "sgd-svm", "passive-aggressive", "margin-perceptron", "romma", "logreg-pegasos" )#
LOOP_TYPE    <- c( "stochastic", "balanced-stochastic", "rank", "roc", "query-norm-rank", "combined-ranking", "combined-roc" )#
ETA_TYPE     <- c( "pegasos", "basic", "constant" )#
NO_BIAS_TERM <- c( TRUE, FALSE)#
#
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  return(function_txt)#
#
	#
}#
#
x <- vector("list")#
#
for(i in LEARNER_TYPE)#
  for(j in LOOP_TYPE)#
    for(k in ETA_TYPE)#
      for(l in NO_BIAS_TERM)#
        create_function_text(i,j,k,l)
LEARNER_TYPE <- c( "pegasos", "sgd-svm", "passive-aggressive", "margin-perceptron", "romma", "logreg-pegasos" )#
LOOP_TYPE    <- c( "stochastic", "balanced-stochastic", "rank", "roc", "query-norm-rank", "combined-ranking", "combined-roc" )#
ETA_TYPE     <- c( "pegasos", "basic", "constant" )#
NO_BIAS_TERM <- c( TRUE, FALSE)#
#
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  return(function_txt)#
#
	#
}#
#
x <- vector("list")#
p <- 1#
#
for(i in LEARNER_TYPE)#
  for(j in LOOP_TYPE)#
    for(k in ETA_TYPE)#
      for(l in NO_BIAS_TERM)#
{#
 x[[p]]   <-    create_function_text(i,j,k,l)#
  p <- p+1#
}
x
LEARNER_TYPE <- c( "pegasos", "sgd-svm", "passive-aggressive", "margin-perceptron", "romma", "logreg-pegasos" )#
LOOP_TYPE    <- c( "stochastic", "balanced-stochastic", "rank", "roc", "query-norm-rank", "combined-ranking", "combined-roc" )#
ETA_TYPE     <- c( "pegasos", "basic", "constant" )#
NO_BIAS_TERM <- c( TRUE, FALSE)#
#
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,")$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  return(function_txt)#
#
	#
}#
#
x <- vector("list")#
p <- 1#
#
for(i in LEARNER_TYPE)#
  for(j in LOOP_TYPE)#
    for(k in ETA_TYPE)#
      for(l in NO_BIAS_TERM)#
        eval(parse(text = create_function_text(i,j,k,l)))
ls()
LEARNER_TYPE <- c( "pegasos", "sgd-svm", "passive-aggressive", "margin-perceptron", "romma", "logreg-pegasos" )#
LOOP_TYPE    <- c( "stochastic", "balanced-stochastic", "rank", "roc", "query-norm-rank", "combined-ranking", "combined-roc" )#
ETA_TYPE     <- c( "pegasos", "basic", "constant" )#
NO_BIAS_TERM <- c( TRUE, FALSE)#
#
create_function_text <- function(learner, loop, eta, no_bias_term) {#
#
  function_txt.name <- paste("test.sofia."#
    , gsub("-","_",learner),"."#
    , gsub("-","_",loop), "."#
    , gsub("-","_",eta), "."#
    , ifelse(no_bias_term, "bias1", "bias0"), " <- function()"#
    , " { \n", sep ="")#
#
  function_txt.body <- paste(#
      #
      "  LOOP_TYPE <- '", loop, "'\n",#
      "  LEARNER_TYPE <- '", learner, "'\n",#
      "  ETA_TYPE <- '", eta, "'\n\n" ,#
      #
      "  weights.RSofia <- sofia(Is.Virginica ~ ., irismod, random_seed = RANDOM_SEED", "\n",#
      "  , eta_type = ETA_TYPE, learner_type = LEARNER_TYPE, loop_type = LOOP_TYPE, no_bias_term = ",no_bias_term,#
      "  )$weights", "\n\n",#
      "  weights.sofia_ml <- sofia_ml_test_results[[paste(LEARNER_TYPE, LOOP_TYPE, sep = '_')]]","\n\n",#
      "  checkEqualsNumeric(weights.RSofia, weights.sofia_ml, tolerance = TOLERANCE)", sep = "")#
                      #
  function_txt.end <- "\n}"#
                        #
  function_txt <- paste(function_txt.name, function_txt.body, function_txt.end, sep = "\n")#
                        #
  return(function_txt)#
#
}#
#
for(i in LEARNER_TYPE)#
  for(j in LOOP_TYPE)#
    for(k in ETA_TYPE)#
      for(l in NO_BIAS_TERM)#
        eval(parse(text = create_function_text(i,j,k,l)))
ls()
q()
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Models")#
files <- list.files()#
sofia_ml_train <- lapply(files, scan)#
names(sofia_ml_train) <- substr(files, 1, regexpr(".out", files) - 1)#
save(sofia_ml_train, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_train.RData")#
#
#
#
#
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Tests")#
files <- list.files()#
sofia_ml_test <- lapply(files, function(x) read.delim(x, header = FALSE)[,1])#
names(sofia_ml_test) <- substr(files, 1, regexpr(".test", files) - 1)#
save(sofia_ml_test, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_test.RData")
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Models")#
files <- list.files()#
sofia_ml_train <- lapply(files, scan)#
names(sofia_ml_train) <- substr(files, 1, regexpr(".out", files) - 1)#
save(sofia_ml_train, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_train.RData")#
#
#
#
#
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Tests")#
files <- list.files()#
sofia_ml_test <- lapply(files, function(x) read.delim(x, header = FALSE)[,1])#
names(sofia_ml_test) <- substr(files, 1, regexpr(".test", files) - 1)#
save(sofia_ml_test, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_test.RData")
library(RSofia)
sofia_ml_test[["pegasos_stochastic_pegasos_bias1"]]
sofia_ml_test[["pegasos_stochastic_pegasos_bias0"]]
sofia.pegasos.stochastic.pegasos.bias0 <- sofia(Is.Virginica ~ -1 + .#
 , irismod, learner_type = "pegasos", loop_type = "stochastic"#
 , eta_type = "pegasos", random_seed = RANDOM_SEED)
data(irismod)
sofia.pegasos.stochastic.pegasos.bias0 <- sofia(Is.Virginica ~ -1 + .#
 , irismod, learner_type = "pegasos", loop_type = "stochastic"#
 , eta_type = "pegasos", random_seed = RANDOM_SEED)
RANDOM_SEED <- 1
sofia.pegasos.stochastic.pegasos.bias0 <- sofia(Is.Virginica ~ -1 + .#
 , irismod, learner_type = "pegasos", loop_type = "stochastic"#
 , eta_type = "pegasos", random_seed = RANDOM_SEED)
sofia.pegasos.stochastic.pegasos.bias0
predict(sofia.pegasos.stochastic.pegasos.bias0, irismod)
sofia_ml_test[["pegasos_stochastic_pegasos_bias0"]]
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Models")#
files <- list.files()#
sofia_ml_train <- lapply(files, scan)#
names(sofia_ml_train) <- substr(files, 1, regexpr(".out", files) - 1)#
save(sofia_ml_train, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_train.RData")#
#
#
#
#
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Tests")#
files <- list.files()#
sofia_ml_test <- lapply(files, function(x) read.delim(x, header = FALSE)[,1])#
names(sofia_ml_test) <- substr(files, 1, regexpr(".test", files) - 1)#
save(sofia_ml_test, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_test.RData")
sofia.logreg_pegasos.stochastic.pegasos.nobias1 <- sofia(Is.Virginica ~ -1 + .#
 , irismod, learner_type = "logreg-pegasos", loop_type = "stochastic"#
 , eta_type = "pegasos", random_seed = RANDOM_SEED)
sofia.logreg_pegasos.stochastic.pegasos.nobias1
predict(sofia.logreg_pegasos.stochastic.pegasos.nobias1, irismod, "linear")
predict(sofia.logreg_pegasos.stochastic.pegasos.nobias1, irismod, "logistic")
sofia_ml_test[["logreg.pegasos.stochastic.pegasos.nobias1"]]
sofia_ml_test[["log-reg.pegasos.stochastic.pegasos.nobias1"]]
names(sofia_ml_test)
sofia_ml_test[["log-reg_pegasos_stochastic_pegasos_nobias1"]]
sofia_ml_test[["logreg-pegasos_stochastic_pegasos_nobias1"]]
predict(sofia.logreg_pegasos.stochastic.pegasos.nobias1, irismod, "linear")
q()
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Models")#
files <- list.files()#
sofia_ml_train <- lapply(files, scan)#
names(sofia_ml_train) <- substr(files, 1, regexpr(".out", files) - 1)#
save(sofia_ml_train, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_train.RData")#
#
setwd("/Users/mike/git_sofia/RSofia/inst/SofiaModels/Tests")#
files <- list.files()#
sofia_ml_test <- lapply(files, function(x) read.delim(x, header = FALSE)[,1])#
names(sofia_ml_test) <- substr(files, 1, regexpr(".test", files) - 1)#
save(sofia_ml_test, file = "/Users/mike/git_sofia/RSofia/data/sofia_ml_test.RData")
lm
lm.fit
tmp <- temp.file()
tempfile()
write.svmlight
training_data <- data.frame(#
  Y  = c(-1,  1,  -1, 1   ),#
  X1 = c(.1, .2,  .3, .4  ),#
  X2 = c(1 , 10, 100, 1000),#
  X3 = c(4 ,  3,   2, 1   )#
)
training_data
tmp <- tempfile()
write.svmlight()
parse_formula(Y ~ ., training_data)
q()
parse_formula(Y ~ -1 + ., training_data)
training_data
write.svmlight
read.svmlight
q()
x <- list(a = 1, b = TRUE, c = c(1,1,0))
x
y <- list(a = 1, b = TRUE, c = (1,1,0))
y <- list(a = 1, b = TRUE, c = (1,1,0))
y <- list(a = 1, b = TRUE, c = c(1,1,0))
y
x
checkEquals(x,y)
checkEqualsNumeric(x,y)
src <- ' Rcpp::NumericMatrix x(2,2); x.fill(42);	// or more interesting values Rcpp::List dimnms =	// two vec. with static names#
Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));#
// and assign it x.attr("dimnames") = dimnms; return(x);#
'#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") > fun()
library(inline)
install.packages("inline")
library(inline)
src <- ' Rcpp::NumericMatrix x(2,2); x.fill(42);	// or more interesting values Rcpp::List dimnms =	// two vec. with static names
Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));
// and assign it x.attr("dimnames") = dimnms; return(x);
'
> fun <- cxxfunction(signature(), body=src, plugin="Rcpp") > fun()
src <- ' Rcpp::NumericMatrix x(2,2); x.fill(42);	// or more interesting values Rcpp::List dimnms =	// two vec. with static names#
Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));#
// and assign it x.attr("dimnames") = dimnms; return(x);#
'#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") > fun()
fun
src <- ' Rcpp::NumericMatrix x(2,2); x.fill(42);	// or more interesting values Rcpp::List dimnms =	// two vec. with static names#
Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));#
// and assign it x.attr("dimnames") = dimnms; return(x);#
'#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun
fin()
fun()
src <- ' Rcpp::NumericMatrix x(2,2); x.fill(42);#
Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));#
// and assign it x.attr("dimnames") = dimnms;#
 return(x);#
'#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun
fun()
src <- ' Rcpp::NumericMatrix x(2,2); x.fill(42);#
Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));#
x.attr("dimnames") = dimnms;#
 return(x);#
'#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));#
         x.attr("dimnames") = dimnms;#
         return(x);#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun
fun()
x <- fun()
x
str(x)
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         Rcpp::List dimnms = Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"), Rcpp::CharacterVector::create("ee", "ff"));#
         x.attr("dimnames") = dimnms;#
         return(x);#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("colnames") = Rcpp::CharacterVector::create("a","b","c");#
         #
         #
         #
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(a = x, b = xx));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("colnames") = Rcpp::CharacterVector::create("a","b","c");#
         #
         #
         #
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(Rcpp::named("a") = x, Rcpp::named("b") = xx));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("colnames") = Rcpp::CharacterVector::create("a","b","c");#
         #
         #
         #
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(Rcpp::Named("a") = x, Rcpp::Named("b") = xx));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun()
xx <- fun()
xx
str(xx)
xx$b
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         #
         #
         #
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(Rcpp::Named("a") = x, Rcpp::Named("b") = xx));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
fun()
cxx
cxxfunction
?cxxfunction
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         #
         Rcpp::NumericMatrix aaa(aa);#
         #
         Rcpp::CharacterVector aaa = aa.attr("colnames");#
         #
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx,#
           Rcpp::Named("c") = aaa));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         #
         Rcpp::NumericMatrix aaa(aa);#
         #
         Rcpp::CharacterVector aaaa = aaa.attr("colnames");#
         #
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx,#
           Rcpp::Named("c") = aaaa));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
fun()
aa <- matrix(1:9, 3)
x
aa
colnames(aa) <- c("a","aa","Aaa")
fun(aa)
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")         #
#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         );#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")         #
#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         );#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         );#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         ));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
fun()
fun(matrix(1:9))
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names")#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         ));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names");#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         ));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
fun()
fun(matrix(0))
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names");#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx,#
           Rcpp::Named("c") = dimnms2[1];#
         ));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names");#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx,#
           Rcpp::Named("c") = dimnms2[1]#
         ));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
fun(matrix(0))
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names");#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx,#
           Rcpp::Named("c") = dimnms2(1)#
         ));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
fun()
fun(matrix(1))
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names");#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx,#
           Rcpp::Named("c") = dimnms2(0)#
         ));#
       '#
fun <- cxxfunction(signature(aa="matrix"), body=src, plugin="Rcpp")
fun(matrix(0))
matrix(0)
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names");#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx,#
           Rcpp::Named("c") = dimnms2(0)#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp")
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
         #
         Rcpp::NumericVector xx(3);#
         xx.fill(1);#
         xx.attr("names") = Rcpp::CharacterVector::create("a","b","c");#
         Rcpp::CharacterVector z = xx.attr("names")        ; #
#
         Rcpp::List dimnms2 = x.attr("names");#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx //,#
          // Rcpp::Named("c") = dimnms2(0)#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
#
         Rcpp::List dimnms2 = x.attr("names");#
         dimnms2;#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp")
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
#
         Rcpp::List dimnms2 = x.attr("names");#
         dimnms2;#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x, #
           Rcpp::Named("b") = xx#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
#
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
#
         Rcpp::List dimnms2 = x.attr("names");#
         dimnms2;#
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
#
fun()
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
#
         Rcpp::List dimnms2 = x.attr("names");#
        #
#
         x.attr("dimnames") = dimnms;#
         return(Rcpp::List::create(#
           Rcpp::Named("a") = x,#
           Rcpp::Named("b") = dimnms2[0]#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
#
fun()
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
            #
         x.attr("dimnames") = dimnms;#
         Rcpp::List dimnms2 = x.attr("dimnames");#
        #
        return(Rcpp::List::create(#
           Rcpp::Named("a") = x,#
           Rcpp::Named("b") = dimnms2[0]#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
#
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
            #
         x.attr("dimnames") = dimnms;#
         Rcpp::List dimnms2 = x.attr("dimnames");#
         Rcpp::CharacterVector a = dimnms2[0];#
        #
        return(Rcpp::List::create(#
           Rcpp::Named("a") = x,#
           Rcpp::Named("b") = dimnms2[0]#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
#
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
            #
         x.attr("dimnames") = dimnms;#
         Rcpp::List dimnms2 = x.attr("dimnames");#
         Rcpp::CharacterVector a = dimnms2[0];#
        #
        return(Rcpp::List::create(#
           Rcpp::Named("a") = x,#
           Rcpp::Named("b") = dimnms2[0],#
           Rcpp::Named("c") = a;#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
#
fun()
src <- 'Rcpp::NumericMatrix x(2,2);#
         x.fill(42);#
         #
         Rcpp::List dimnms = Rcpp::List::create(#
           Rcpp::CharacterVector::create("cc", "dd"),#
           Rcpp::CharacterVector::create("ee", "ff")#
         );#
     #
            #
         x.attr("dimnames") = dimnms;#
         Rcpp::List dimnms2 = x.attr("dimnames");#
         Rcpp::CharacterVector a = dimnms2[0];#
        #
        return(Rcpp::List::create(#
           Rcpp::Named("a") = x,#
           Rcpp::Named("b") = dimnms2[0],#
           Rcpp::Named("c") = a#
         ));#
       '#
fun <- cxxfunction(signature(), body=src, plugin="Rcpp") #
#
fun()
x <- c(1,2,3)
names(x)
sttr(x)
attr(x)
x <- matrix(1:9)
dimnames(x) <-list( letters[1:3], letter[4:6])
dimnames(x) <-list( letters[1:3], letters[4:6])
x
x <- matrix(1:9, 3)
dimnames(x) <-list( letters[1:3], letters[4:6])
x
dimnames(x)
attr(x)
attributes(x)
colnames(x)
colnames
