diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-10-24 15:47:24 +0200 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-10-24 15:47:24 +0200 |
commit | 21e314b4d5fdd764ffb95d49751fa96b6b76371f (patch) | |
tree | b4d2e7f3f85fe64345e72dd6639e38e364da297f | |
parent | b382c84a3dcad1bf321907848f1869ecbb3056b9 (diff) | |
parent | ac3b06da43f5a8baa65fec761e7f61b0f533c109 (diff) |
Merge branch 'development' of github.com:opentox/algorithm into development
-rw-r--r-- | lib/algorithm/neighbors.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/algorithm/neighbors.rb b/lib/algorithm/neighbors.rb index 1ea6c25..cdfc5b7 100644 --- a/lib/algorithm/neighbors.rb +++ b/lib/algorithm/neighbors.rb @@ -170,10 +170,11 @@ module OpenTox $logger.debug "Preparing R data ..." @r.eval <<-EOR weights=NULL - if (class(y) == 'character') { + if (!(class(y) == 'numeric')) { y = factor(y) suppressPackageStartupMessages(library('class')) weights=unlist(as.list(prop.table(table(y)))) + weights=(weights-1)^2 } EOR @@ -196,7 +197,7 @@ module OpenTox model = train(prop_matrix,y, method="svmradial", preProcess=c("center", "scale"), - class.weights=1.0-weights, + class.weights=weights, trControl=trainControl(method="LGOCV",number=10), tuneLength=8 ) |