Mercurial > repos > nicolas > oghma
changeset 48:cea4a54c52d0 draft
Uploaded
author | nicolas |
---|---|
date | Wed, 26 Oct 2016 17:31:45 -0400 |
parents | 7b9b78352811 |
children | 6d6b76131103 |
files | aggregation.R |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/aggregation.R Wed Oct 26 02:33:15 2016 -0400 +++ b/aggregation.R Wed Oct 26 17:31:45 2016 -0400 @@ -12,9 +12,20 @@ suppressWarnings(suppressMessages(library(randomForest))) library(e1071) suppressWarnings(suppressMessages(library(glmnet))) +options(warn=-1) ############################ helper functions ####################### ##### Genetic algorithm + +# compute r2 by computing the classic formula +# compare the sum of square difference from target to prediciton +# to the sum of square difference from target to the mean of the target +r2 <- function(target, prediction) { + sst <- sum((target-mean(target))^2) + ssr <- sum((target-prediction)^2) + return(1-ssr/sst) +} + optimizeOneIndividual <- function(values, trueValue) { # change the value into a function f <- function(w) {sum(values * w/sum(w))} @@ -282,7 +293,7 @@ out = out, prediction = prediction, model=model) }, lasso={ - aggregateLASSO(classifiers = classifPrediction, target = phenotype, + aggregateLASSO(classifiers = data.matrix(classifPrediction), target = phenotype, out = out, prediction = prediction, model=model) }, rf={