summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-07-14 11:04:38 +0200
committerAndreas Maunz <andreas@maunz.de>2011-07-14 11:04:38 +0200
commiteb88a3e239964e39ece8261dd3320e8247ed095d (patch)
treefcb27bdec068e2ea233b9b8a3888b89d66558d3d
parent9f9e3e699c46dc26cf0048088dcc85ccb9b68412 (diff)
parent0da3b10c755384b81a45142631b8ac65acfecfaf (diff)
Merge branch 'log' into development
-rw-r--r--lazar.rb43
1 files changed, 30 insertions, 13 deletions
diff --git a/lazar.rb b/lazar.rb
index e2dde9a..b78b12a 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -142,24 +142,41 @@ post '/lazar/?' do
end
task.progress 80
- # AM: allow prediction_algorithm override by user for classification AND regression
+ # AM: allow settings override by user
lazar.prediction_algorithm = "Neighbors.#{params[:prediction_algorithm]}" unless params[:prediction_algorithm].nil?
+ lazar.transform["class"] = params[:activity_transform] unless params[:activity_transform].nil?
lazar.prop_kernel = true if (params[:local_svm_kernel] == "propositionalized" || params[:prediction_algorithm] == "local_mlr_prop")
lazar.balanced = true if params[:balanced] == "true"
- training_activities.data_entries.each do |compound,entry|
- lazar.activities[compound] = [] unless lazar.activities[compound]
- unless entry[prediction_feature.uri].empty?
- entry[prediction_feature.uri].each do |value|
- if prediction_feature.feature_type == "classification"
+ # AM: Feed Data using Transformations
+ if prediction_feature.feature_type == "regression"
+ transformed_acts = []
+ training_activities.data_entries.each do |compound,entry|
+ unless entry[prediction_feature.uri].empty?
+ entry[prediction_feature.uri].each do |value|
+ transformed_acts << value.to_f
+ end
+ end
+ end
+ transfomer = eval "OpenTox::Algorithm::Transform::#{lazar.transform["class"]}.new(transform_acts)"
+ transformed_acts = transformer.values
+ lazar.transform["offset"] = transformer.offset
+ t_count=0
+ training_activities.data_entries.each do |compound,entry|
+ lazar.activities[compound] = [] unless lazar.activities[compound]
+ unless entry[prediction_feature.uri].empty?
+ entry[prediction_feature.uri].each do |value|
+ lazar.activities[compound] << transformed_acts[t_count].to_s
+ t_count+=1
+ end
+ end
+ end
+ elsif prediction_feature.feature_type == "classification"
+ training_activities.data_entries.each do |compound,entry|
+ lazar.activities[compound] = [] unless lazar.activities[compound]
+ unless entry[prediction_feature.uri].empty?
+ entry[prediction_feature.uri].each do |value|
lazar.activities[compound] << lazar.value_map.invert[value] # insert mapped values, not originals
- elsif prediction_feature.feature_type == "regression"
- #never use halt in tasks, do not raise exception when, print warning instead
- if value.to_f==0
- LOGGER.warn "0 values not allowed in training dataset. log10 is calculated internally. skipping compound"
- else
- lazar.activities[compound] << value.to_f
- end
end
end
end