From 606858c0f840c5311ce57dcad7e1ede69d494a1b Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 12 Jul 2013 18:13:11 +0200 Subject: value type identification/conversion fixed --- lib/lazar.rb | 2 +- lib/similarity.rb | 4 ++-- lib/transform.rb | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/lazar.rb b/lib/lazar.rb index f88c695..f849a48 100644 --- a/lib/lazar.rb +++ b/lib/lazar.rb @@ -149,7 +149,7 @@ module OpenTox # AM: transform to cosine space @min_sim = (@min_sim.to_f*2.0-1.0).to_s if @similarity_algorithm =~ /cosine/ @training_activities = @training_dataset.data_entries.collect{|entry| - act = entry[prediction_feature_pos] + act = entry[prediction_feature_pos] if entry @prediction_feature.feature_type=="classification" ? @prediction_feature.value_map.invert[act] : act } diff --git a/lib/similarity.rb b/lib/similarity.rb index cdac4b8..5f02577 100644 --- a/lib/similarity.rb +++ b/lib/similarity.rb @@ -20,8 +20,8 @@ module OpenTox size = [ a.size, b.size ].min $logger.warn "fingerprints don't have equal size" if a.size != b.size (0...size).each { |idx| - common_p_sum += [ a[idx], b[idx] ].min - all_p_sum += [ a[idx], b[idx] ].max + common_p_sum += [ a[idx].to_f, b[idx].to_f ].min + all_p_sum += [ a[idx].to_f, b[idx].to_f ].max } (all_p_sum > 0.0) ? (common_p_sum/all_p_sum) : 0.0 end diff --git a/lib/transform.rb b/lib/transform.rb index cb4fc87..752f448 100644 --- a/lib/transform.rb +++ b/lib/transform.rb @@ -242,6 +242,7 @@ module OpenTox # Transforms the model def transform get_matrices # creates @n_prop, @q_prop, @activities from ordered fingerprints + puts "MATRIX" @ids = (0..((@n_prop.length)-1)).to_a # surviving compounds; become neighbors if (@model.similarity_algorithm =~ /cosine/) @@ -276,13 +277,16 @@ module OpenTox @q_prop = svd.transform(gsl_q_prop).row(0).to_a $logger.debug "S: #{@n_prop.size}x#{@n_prop[0].size}; R: #{@q_prop.size}" else + puts "CONVERT NILS" convert_nils # convert nil cells (for tanimoto); leave @n_props, @q_props, @ids untouched end # neighbor calculation @ids = [] # surviving compounds become neighbors @sims = [] # calculated by neighbor routine + puts "NEIGHBORS" neighbors + puts "NEIGHBORS FINISHED" n_prop_tmp = []; @ids.each { |idx| n_prop_tmp << @n_prop[idx] }; @n_prop = n_prop_tmp # select neighbors from matrix acts_tmp = []; @ids.each { |idx| acts_tmp << @activities[idx] }; @activities = acts_tmp -- cgit v1.2.3