diff options
-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 ) |