def get_rules
rules = []
rules << "votes = Hash.new {0}"
data = @data_set.data_items.first
labels = @data_set.data_labels.collect {|l| l.to_s}
@pipes.each do |category, pipe|
pipe.each_with_index do |bounds, i|
rule = "votes['#{category}'] += 1 "
if data[i].is_a? Numeric
rule += "if #{labels[i]} >= #{bounds[:min]} && #{labels[i]} <= #{bounds[:max]}"
else
rule += "if #{bounds.inspect}[#{labels[i]}]"
end
rules << rule
end
end
rules << "#{labels.last} = votes.to_a.max {|x, y| x.last <=> y.last}.first"
return rules.join("\n")
end