diff options
author | Andreas Maunz <andreas@maunz.de> | 2011-06-27 08:54:53 +0200 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2011-06-27 08:54:53 +0200 |
commit | 5ce30c81a486896aca129bf779b917dd93007adc (patch) | |
tree | fcd186260aee55f85f063dd425ee94b725888256 | |
parent | 96ef56a05efffdbfa8f78a58cdeb6f7a37e9452f (diff) |
Removed map lookup, using sort order for activity
-rw-r--r-- | lib/algorithm.rb | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 1f0ef2a..41e08ab 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -151,26 +151,23 @@ module OpenTox neighbor_weight = Algorithm.gauss(neighbor[:similarity]).to_f neighbor_contribution += neighbor[:activity].to_f * neighbor_weight - if params[:value_map].size == 2 # provide compat to binary classification - map_entry = params[:value_map][neighbor[:activity].to_i].to_s # access original neighbor activity - case map_entry - when TRUE_REGEXP - confidence_sum += neighbor_weight - positive_map_value = neighbor[:activity] - when FALSE_REGEXP + if params[:value_map].size == 2 # AM: provide compat to binary classification: 1=>false 2=>true + case neighbor[:activity] + when 1 confidence_sum -= neighbor_weight - negative_map_value = neighbor[:activity] + when 2 + confidence_sum += neighbor_weight end else - confidence_sum += neighbor_weight # AM: new multinomial confidence + confidence_sum += neighbor_weight end end - if params[:value_map].size == 2 # provide compat to binary classification + if params[:value_map].size == 2 if confidence_sum >= 0.0 - prediction = positive_map_value unless neighbors.size==0 + prediction = 2 unless neighbors.size==0 elsif confidence_sum < 0.0 - prediction = negative_map_value unless neighbors.size==0 + prediction = 1 unless neighbors.size==0 end else prediction = (neighbor_contribution/confidence_sum).round unless neighbors.size==0 # AM: new multinomial prediction |