summaryrefslogtreecommitdiff
path: root/lib/dataset.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2011-04-04 18:46:22 +0200
committerChristoph Helma <helma@in-silico.ch>2011-04-04 18:46:22 +0200
commit1daec5badcff31c591377017b32055aac775dbb7 (patch)
treea9dc4c5a1df87d13dd5127528b366081b403a1e2 /lib/dataset.rb
parent2fcaf3cd3c68b8e679ecf77f70285778495d78c2 (diff)
OT.isA substituted by RDF.type, identification of feature_types by RDF.type
Diffstat (limited to 'lib/dataset.rb')
-rw-r--r--lib/dataset.rb31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/dataset.rb b/lib/dataset.rb
index c61d86f..93fce18 100644
--- a/lib/dataset.rb
+++ b/lib/dataset.rb
@@ -163,24 +163,33 @@ module OpenTox
@features
end
+ def feature_classes(feature)
+ if Feature.find(feature).feature_type == "classification"
+ classes = []
+ @data_entries.each do |c,e|
+ e[feature].each { |v| classes << v.to_s }
+ end
+ classes.uniq.sort
+ else
+ nil
+ end
+ end
+
+=begin
# Detect feature type(s) in the dataset
# @return [String] `classification", "regression", "mixed" or unknown`
def feature_type(subjectid=nil)
load_features(subjectid)
- feature_types = @features.collect{|f,metadata| metadata[OT.isA]}.uniq
- if feature_types.size > 1
- "mixed"
+ feature_types = @features.collect{|f,metadata| metadata[RDF.type]}.flatten.uniq
+ if feature_types.include?(OT.NominalFeature)
+ "classification"
+ elsif feature_types.include?(OT.NumericFeature)
+ "regression"
else
- case feature_types.first
- when /NominalFeature/
- "classification"
- when /NumericFeature/
- "regression"
- else
- "unknown"
- end
+ "unknown"
end
end
+=end
# Get Spreadsheet representation
# @return [Spreadsheet::Workbook] Workbook which can be written with the spreadsheet gem (data_entries only, metadata will will be discarded))