From dce530c27024faf332f60c1ae0bc67f797336add Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Mon, 7 Nov 2011 12:57:22 +0100 Subject: Init to numeric branch --- last-utils | 2 +- lazar.rb | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- libfminer | 2 +- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/last-utils b/last-utils index 04bd1b7..8c02f7e 160000 --- a/last-utils +++ b/last-utils @@ -1 +1 @@ -Subproject commit 04bd1b73f54bb7422d3c08bb5a81bc02af04f6ff +Subproject commit 8c02f7e71450cac6d8c5d7d34ecb620046b4ea46 diff --git a/lazar.rb b/lazar.rb index 9750a56..98734e4 100644 --- a/lazar.rb +++ b/lazar.rb @@ -63,6 +63,10 @@ post '/lazar/?' do lazar = OpenTox::Model::Lazar.new lazar.min_sim = params[:min_sim].to_f if params[:min_sim] + + + + # AM: Manage endpoint related variables. if prediction_feature.feature_type == "classification" @training_classes = training_activities.accept_values(prediction_feature.uri).sort @training_classes.each_with_index { |c,i| @@ -82,9 +86,23 @@ post '/lazar/?' do end params[:nr_hits] = "true" if lazar.nr_hits + + + + + task.progress 10 - if params[:feature_dataset_uri] + + + + # + # AM: features + # + # + + # READ OR CREATE + if params[:feature_dataset_uri] feature_dataset_uri = params[:feature_dataset_uri] training_features = OpenTox::Dataset.new(feature_dataset_uri) case training_features.feature_type(@subjectid) @@ -109,6 +127,9 @@ post '/lazar/?' do training_features = OpenTox::Dataset.new(feature_dataset_uri) end + + + # WRITE IN MODEL training_features.load_all(@subjectid) raise OpenTox::NotFoundError.new "Dataset #{feature_dataset_uri} not found." if training_features.nil? @@ -119,6 +140,8 @@ post '/lazar/?' do training_features.data_entries.each do |compound,entry| lazar.fingerprints[compound] = {} unless lazar.fingerprints[compound] entry.keys.each do |feature| + + # CASE 1: Substructure if lazar.feature_calculation_algorithm == "Substructure.match" if training_features.features[feature] smarts = training_features.features[feature][OT.smarts] @@ -134,6 +157,8 @@ post '/lazar/?' do lazar.effects[smarts] = training_features.features[feature][OT.effect] end end + + # CASE 2: Others else case training_features.feature_type(@subjectid) when "classification" @@ -159,6 +184,15 @@ post '/lazar/?' do end task.progress 80 + + + + # + # AM: SETTINGS + # + # + # + # AM: allow settings override by user lazar.prediction_algorithm = "Neighbors.#{params[:prediction_algorithm]}" unless params[:prediction_algorithm].nil? if prediction_feature.feature_type == "regression" @@ -169,6 +203,19 @@ post '/lazar/?' do lazar.conf_stdev = false lazar.conf_stdev = true if params[:conf_stdev] == "true" + + + + + + + + # + # AM TRANSFORMATIONS + # + # + # + # AM: Feed Data using Transformations if prediction_feature.feature_type == "regression" transformed_acts = [] @@ -200,6 +247,14 @@ post '/lazar/?' do end task.progress 90 + + + # + # AM: Metadata + # + # + # + lazar.metadata[DC.title] = "lazar model for #{URI.decode(File.basename(prediction_feature.uri))}" lazar.metadata[OT.dependentVariables] = prediction_feature.uri lazar.metadata[OT.trainingDataset] = dataset_uri diff --git a/libfminer b/libfminer index 07679a6..17932e8 160000 --- a/libfminer +++ b/libfminer @@ -1 +1 @@ -Subproject commit 07679a625a7acad864fd3abd80654a1a0a61e690 +Subproject commit 17932e809c35c93374ed3d5fd19a313325c35b41 -- cgit v1.2.3