summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorot1 <andreas@maunz.de>2011-12-02 12:01:39 +0100
committerot1 <andreas@maunz.de>2011-12-02 12:01:39 +0100
commit7c7f2c830a5f27332051bc34675bed27b59634af (patch)
tree9d9911d2613f3751f90740bd33d065504f68dcf1
parente9071ab38fd81635dde42f64ad2e5a0ce516b3db (diff)
Several bugs fixed
Fixed nil prediction, adjusted step size to 1 for small neighbor sets, fixed R2 calculation bug
-rw-r--r--lib/algorithm.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index df3647c..9b69791 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -348,7 +348,7 @@ module OpenTox
prediction = pcr( {:n_prop => props[0], :q_prop => props[1], :sims => sims, :acts => acts, :maxcols => maxcols} )
#prediction = nil if prediction.infinite? || params[:prediction_min_max][1] < prediction || params[:prediction_min_max][0] > prediction
- prediction = nil if prediction.infinite?
+ prediction = nil if (!prediction.nil? && prediction.infinite?)
LOGGER.debug "Prediction is: '" + prediction.to_s + "'."
params[:conf_stdev] = false if params[:conf_stdev].nil?
@@ -488,7 +488,8 @@ module OpenTox
#for i in (maxcols+1)..(data_matrix.size1)
start_neighbors_size = [12,(data_matrix.size1)].min
- for current_neighbors_size in (start_neighbors_size..(data_matrix.size1)).step(2)
+ step_size = (data_matrix.size1 < 23) ? 1 : 2
+ for current_neighbors_size in (start_neighbors_size..(data_matrix.size1)).step(step_size)
# adjust x and y
@r.x = data_matrix.submatrix(0..(current_neighbors_size-1),nil).to_a.flatten
@r.y = acts.take(current_neighbors_size).to_a.flatten
@@ -504,8 +505,7 @@ module OpenTox
LOGGER.debug "R-Squared (internal LOO using #{current_neighbors_size} neighbors): #{@r.r2Loo.to_a.flatten.collect { |v| sprintf("%.2f", v) }.join(", ") }"
# get max R2
- @r.eval "ncompLoo <- which.max(r2Loo) - 1"
- @r.eval "ncompLoo <- ncompLoo + 1" if (@r.ncompLoo.to_i == 0)
+ @r.eval "ncompLoo <- which.max(r2Loo)"
#LOGGER.debug "Best position: #{@r.ncompLoo.to_i}"
# "Schleppzeiger"