class Predicate
Public Class Methods
new(pred_xml)
click to toggle source
# File lib/predicate.rb, line 6 def initialize(pred_xml) attributes = pred_xml.attributes @pred = NumericalPredicate.new(attributes) if attributes['operator'] @pred = CategoricalPredicate.new(pred_xml) if attributes['booleanOperator'] end
Public Instance Methods
field()
click to toggle source
# File lib/predicate.rb, line 12 def field @pred.field end
missing_feature?(features)
click to toggle source
# File lib/predicate.rb, line 22 def missing_feature?(features) return false if features.has_key? field RandomForester.logger.error "Missing feature #{field}" true end
nil_feature?(features)
click to toggle source
# File lib/predicate.rb, line 28 def nil_feature?(features) return false unless features[field].nil? RandomForester.logger.error "Feature #{field} value is nil" true end
true?(features)
click to toggle source
# File lib/predicate.rb, line 16 def true?(features) return if missing_feature?(features) return if nil_feature?(features) @pred.true?(features) end