summaryrefslogtreecommitdiff
path: root/lib/dataset.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2011-04-05 19:14:37 +0200
committerChristoph Helma <helma@in-silico.ch>2011-04-05 19:14:37 +0200
commit7749e5dae00e0ef4a28ba9dd39182f6a5905a6bf (patch)
tree97a16e629d1ec1f3073c47635df2b180a128255c /lib/dataset.rb
parentc0bef2dc83d2ce1fea6434ca73586d49865bb810 (diff)
parent80c2562c0f84f65b0e3ed02c3293c530d0dc4ce2 (diff)
Merge branch 'feature/external' into development
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))