summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-05-26 08:38:21 +0200
committerAndreas Maunz <andreas@maunz.de>2011-05-26 08:38:21 +0200
commit77c885b7394aa11ba5e59eb60884205332efa31a (patch)
tree1993a7fdfffc85adc16910667b36f9f5eaf1aca8
parent2b12d07bec101df8c10b7ab5aff1491b0997a6c7 (diff)
7th v
-rw-r--r--lib/algorithm.rb2
-rw-r--r--lib/model.rb4
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index e089184..91e075a 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -227,6 +227,7 @@ module OpenTox
# @param [Array] props, propositionalization of neighbors and query structure e.g. [ Array_for_q, two-nested-Arrays_for_n ]
# @return [Numeric] A prediction value.
def self.local_svm(neighbors, acts, sims, type, params)
+ LOGGER.debug "Local SVM (Weighted Tanimoto Kernel)."
neighbor_matches = neighbors.collect{ |n| n[:features] } # URIs of matches
gram_matrix = [] # square matrix of similarities between neighbors; implements weighted tanimoto kernel
if neighbor_matches.size == 0
@@ -299,6 +300,7 @@ module OpenTox
# @return [Numeric] A prediction value.
def self.local_svm_prop(props, acts, type, params)
+ LOGGER.debug "Local SVM (Propositionalization / Kernlab Kernel)."
n_prop = props[0] # is a matrix, i.e. two nested Arrays.
q_prop = props[1] # is an Array.
diff --git a/lib/model.rb b/lib/model.rb
index 1a5aa37..921335c 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -214,7 +214,7 @@ module OpenTox
(i == modulo[0]) && (slack>0) ? lr_size = s.size + slack : lr_size = s.size + addon # determine fraction
LOGGER.info "BLAZAR: Neighbors round #{i}: #{position} + #{lr_size}."
neighbors_balanced(s, l, position, lr_size) # get ratio fraction of larger part
- props = get_props
+ (@prediction_algorithm.include? "svm" and params[:prop_kernel] == "true") ? props = get_props : props = nil
prediction = eval("#{@prediction_algorithm}(@neighbors,{:similarity_algorithm => @similarity_algorithm, :p_values => @p_values}, props)")
if prediction_best.nil? || prediction[:confidence].abs > prediction_best[:confidence].abs
prediction_best=prediction
@@ -232,7 +232,7 @@ module OpenTox
else # no balancing as before
neighbors
- props = get_props
+ (@prediction_algorithm.include? "svm" and params[:prop_kernel] == "true") ? props = get_props : props = nil
prediction = eval("#{@prediction_algorithm}(@neighbors,{:similarity_algorithm => @similarity_algorithm, :p_values => @p_values}, props)")
end