Class: OpenTox::Feature

Inherits:
Object show all
Defined in:
lib/feature.rb

Instance Method Summary collapse

Instance Method Details

#accept_valuesObject

Get accept values

@return Accept values


21
22
23
# File 'lib/feature.rb', line 21

def accept_values
  self[RDF::OT.acceptValue] ? self[RDF::OT.acceptValue].sort : nil
end

#feature_typeString

Find out feature type Classification takes precedence

Returns:


8
9
10
11
12
13
14
15
16
# File 'lib/feature.rb', line 8

def feature_type
  if self[RDF.type].include?(RDF::OT.NominalFeature)
    "classification"
  elsif self[RDF.type].include?(RDF::OT.NumericFeature)
    "regression"
  else
    "unknown"
  end
end

#value_mapHash

Create value map

Parameters:

Returns:

  • (Hash)

    A hash with keys 1…feature.training_classes.size and values training classes


28
29
30
31
32
33
# File 'lib/feature.rb', line 28

def value_map
  unless defined? @value_map
    accept_values ? @value_map = accept_values.each_index.inject({}) { |h,idx| h[idx+1]=accept_values[idx]; h } : @value_map = nil
  end
  @value_map
end