diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-04-11 13:27:53 +0200 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-04-11 13:27:53 +0200 |
commit | 00b89aba6823fe0577713e569891cf4ebfea1280 (patch) | |
tree | 334ff0ad683bf1d6aa89522ba05aa54375f6d73e | |
parent | cab2c3249e729cc9c6be3a4a306b05d60f8f9f2e (diff) |
pc_type and lib autodetection from feature dataset
-rw-r--r-- | lib/dataset.rb | 25 | ||||
-rw-r--r-- | lib/model.rb | 5 | ||||
-rw-r--r-- | lib/utils.rb | 2 |
3 files changed, 25 insertions, 7 deletions
diff --git a/lib/dataset.rb b/lib/dataset.rb index daa3470..aafa656 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -197,7 +197,12 @@ module OpenTox accept_values end - # Detect feature type(s) in the dataset + # Detect feature type (reduced to one across all features) + # Classification takes precedence over regression + # DEPRECATED -- + # HAS NO SENSE FOR DATASETS WITH MORE THAN 1 FEATURE + # FEATURES CAN HAVE MULTIPLE TYPES + # Replacement: see feature_types() # @return [String] `classification", "regression", "mixed" or unknown` def feature_type(subjectid=nil) load_features(subjectid) @@ -210,6 +215,24 @@ module OpenTox "unknown" end end + + + # Detect feature types. A feature can have multiple types. + # Returns types hashed by feature URI, with missing features omitted. + # Example (YAML): + # http://toxcreate3.in-silico.ch:8082/dataset/152/feature/nHal: + # - http://www.opentox.org/api/1.1#NumericFeature + # - http://www.opentox.org/api/1.1#NominalFeature + # ... + # + # @return [Hash] Keys: feature URIs, Values: Array of types + def feature_types(subjectid=nil) + load_features(subjectid) + @features.inject({}){ |h,(f,metadata)| + h[f]=metadata[RDF.type] unless metadata[RDF.type][0].include? "MissingFeature" + h + } + end =begin =end diff --git a/lib/model.rb b/lib/model.rb index 057c537..30c7b97 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -249,11 +249,6 @@ module OpenTox } ) end - if OpenTox::Feature.find(metadata[OT.dependentVariables], subjectid).feature_type == "regression" - all_activities = [] - all_activities = @activities.values.flatten.collect! { |i| i.to_f } - end - unless database_activity(subjectid) # adds database activity to @prediction_dataset # Calculation of needed values for query compound diff --git a/lib/utils.rb b/lib/utils.rb index 6689e94..0dbab37 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -88,7 +88,7 @@ module OpenTox LOGGER.debug master.collect { |row| row.join(",") }.join("\n") - ds = OpenTox::Dataset.find ( + ds = OpenTox::Dataset.find( OpenTox::RestClientWrapper.post( File.join(CONFIG[:services]["opentox-dataset"]), master.collect { |row| row.join(",") }.join("\n"), {:content_type => "text/csv"} ) |