diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-03-14 16:08:02 +0100 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-03-14 16:08:02 +0100 |
commit | f02a9ff3c7bcb8471f2a0ffd6de2a9d752202b87 (patch) | |
tree | b0282e580814de3e388ee5f745d07569ea63545b | |
parent | 268f8096aa7737dd6d8f28224fd9c1f205712a6a (diff) |
Two fixes related to transformation and model building
train() failure for censoring predictions (algorithm.rb),
transformation log for creating n_prop and q_prop fixed (transform.rb)
-rw-r--r-- | lib/algorithm.rb | 7 | ||||
-rw-r--r-- | lib/transform.rb | 4 |
2 files changed, 5 insertions, 6 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb index c026c56..9dcf6a8 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -381,10 +381,10 @@ module OpenTox else #LOGGER.debug gram_matrix.to_yaml @r = RinRuby.new(false,false) # global R instance leads to Socket errors after a large number of requests - @r.eval "set.seed(1)" @r.eval "suppressPackageStartupMessages(library('caret'))" # requires R packages "caret" and "kernlab" @r.eval "suppressPackageStartupMessages(library('doMC'))" # requires R packages "multicore" @r.eval "registerDoMC()" # switch on parallel processing + @r.eval "set.seed(1)" begin # set data @@ -417,7 +417,7 @@ module OpenTox # model + support vectors LOGGER.debug "Creating R SVM model ..." - @r.eval <<-EOR + train_success = @r.eval <<-EOR model = train(prop_matrix,y,method="svmradial",tuneLength=8,trControl=trainControl(method="LGOCV",number=10),preProcess=c("center", "scale")) perf = ifelse ( class(y)!='numeric', max(model$results$Accuracy), model$results[which.min(model$results$RMSE),]$Rsquared ) EOR @@ -431,6 +431,7 @@ module OpenTox # censoring prediction = nil if ( @r.perf.nan? || @r.perf < min_train_performance ) + prediction = nil unless train_success LOGGER.debug "Performance: #{sprintf("%.2f", @r.perf)}" rescue Exception => e LOGGER.debug "#{e.class}: #{e.message}" @@ -459,12 +460,12 @@ module OpenTox # need packs 'randomForest', 'RANN' @r.eval <<-EOR - set.seed(1) suppressPackageStartupMessages(library('caret')) suppressPackageStartupMessages(library('randomForest')) suppressPackageStartupMessages(library('RANN')) suppressPackageStartupMessages(library('doMC')) registerDoMC() + set.seed(1) acts = read.csv(ds_csv_file, check.names=F) feats = read.csv(fds_csv_file, check.names=F) diff --git a/lib/transform.rb b/lib/transform.rb index 5c485fb..f6f769d 100644 --- a/lib/transform.rb +++ b/lib/transform.rb @@ -396,9 +396,7 @@ module OpenTox @q_prop = gsl_q_prop_orig.row(0).to_a end - if (@n_prop && @q_prop) - LOGGER.debug "F: #{@n_prop.size}x#{@n_prop[0].size}; R: #{@q_prop.size}" - end + LOGGER.debug "F: #{@n_prop.size}x#{@n_prop[0].size}; R: #{@q_prop.size}" if (@n_prop && @n_prop[0] && @q_prop) LOGGER.debug "Sims: #{@sims.size}, Acts: #{@acts.size}" if (@sims && @acts) @sims = [ gram_matrix, @sims ] |