summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-03-15 18:46:34 +0100
committerChristoph Helma <helma@in-silico.ch>2016-03-15 18:46:34 +0100
commitabc3526e318a2bfa24dfe033d8879e7657c2ae5c (patch)
treeb11500952085d6a771f845431258c7befae5fd04 /lib
parent7c3bd90c26dfeea2db3cf74a1cefc23d8dece7c0 (diff)
single tests pass
Diffstat (limited to 'lib')
-rw-r--r--lib/lazar.rb2
-rw-r--r--lib/model.rb3
-rw-r--r--lib/physchem.rb6
-rw-r--r--lib/regression.rb2
4 files changed, 4 insertions, 9 deletions
diff --git a/lib/lazar.rb b/lib/lazar.rb
index 0125d27..b4293e9 100644
--- a/lib/lazar.rb
+++ b/lib/lazar.rb
@@ -86,4 +86,4 @@ CLASSES = ["Feature","Compound","Dataset","Validation","CrossValidation","LeaveO
"leave-one-out-validation.rb",
"experiment.rb",
].each{ |f| require_relative f }
-
+OpenTox::PhysChem.descriptors # load descriptor features
diff --git a/lib/model.rb b/lib/model.rb
index f21ea54..5da5dc8 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -66,6 +66,7 @@ module OpenTox
prediction.merge!({:value => nil,:confidence => nil,:warning => "Could not find similar compounds with experimental data in the training dataset."})
else
prediction.merge!(Algorithm.run(prediction_algorithm, compound, {:neighbors => neighbors,:training_dataset_id=> training_dataset_id,:prediction_feature_id => prediction_feature.id}))
+ prediction[:neighbors] = neighbors
end
prediction
end
@@ -95,7 +96,7 @@ module OpenTox
case object.class.to_s
when "OpenTox::Compound"
prediction = predictions.first
- prediction[:neighbors] = neighbors.sort{|a,b| b[1] <=> a[1]} # sort according to similarity
+ prediction[:neighbors].sort!{|a,b| b[1] <=> a[1]} # sort according to similarity
return prediction
when "Array"
return predictions
diff --git a/lib/physchem.rb b/lib/physchem.rb
index 067cd59..f7b880f 100644
--- a/lib/physchem.rb
+++ b/lib/physchem.rb
@@ -37,15 +37,9 @@ module OpenTox
DESCRIPTORS = OBDESCRIPTORS.merge(CDKDESCRIPTORS.merge(JOELIBDESCRIPTORS))
- DESCRIPTORS.each do |name,description|
- lib,desc = name.split('.',2)
- self.find_or_create_by(:name => name, :library => lib, :descriptor => desc, :description => description, :measured => false, :calculated => true, :numeric => true, :nominal => false)
- end
-
require_relative "unique_descriptors.rb"
def self.descriptors desc=DESCRIPTORS
- # TODO create PhysChem features @startup
desc.collect do |name,description|
lib,desc = name.split('.',2)
self.find_or_create_by(:name => name, :library => lib, :descriptor => desc, :description => description, :measured => false, :calculated => true, :numeric => true, :nominal => false)
diff --git a/lib/regression.rb b/lib/regression.rb
index b8efd30..6b08fd8 100644
--- a/lib/regression.rb
+++ b/lib/regression.rb
@@ -62,7 +62,7 @@ module OpenTox
else
compound_features = variables.collect{|f| compound.fingerprint.include?(f) ? "T" : "F"}
prediction = r_model_prediction method, data_frame, variables, weights, compound_features
- if prediction.nil?
+ if prediction.nil? or prediction[:value].nil?
prediction = local_weighted_average(compound, params)
prediction[:warning] = "Could not create local PLS model. Using weighted average of similar compounds."
return prediction