From ac3b06da43f5a8baa65fec761e7f61b0f533c109 Mon Sep 17 00:00:00 2001 From: davor Date: Wed, 24 Oct 2012 13:01:27 +0200 Subject: Added modified weights to local_svm_prop (classification). --- lib/algorithm/neighbors.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/algorithm/neighbors.rb b/lib/algorithm/neighbors.rb index 0001608..332e83c 100644 --- a/lib/algorithm/neighbors.rb +++ b/lib/algorithm/neighbors.rb @@ -167,10 +167,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 @@ -193,7 +194,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 ) -- cgit v1.2.3