我一直得到未初始化的常量ID3(NameError)

时间:2015-03-07 20:36:42

标签: ruby

我想要做的就是将csv文件放入此程序中并使用规则获得是或否答案,即使我将ID3.new分配给我,我也会继续获得已知的常量...请告知这一点非常令人沮丧一整天

require 'rubygems'
require 'ai4r'
require 'csv'


data_set = []

  CSV.open('id5.csv', 'r') do |row|
    data_set << row
  end
  data_labels = data_set.shift

  id3 = ID3.new(data_set, data_labels)




id3.get_rules
     if age_range=='<30' then marketing_target='Y'
          elsif age_range=='[30-50)' and city=='Chicago' then marketing_target='Y'
          elsif age_range=='[30-50)' and city=='New York' then marketing_target='N'
          elsif age_range=='[50-80]' then marketing_target='N'
          elsif age_range=='>80' then marketing_target='Y'
          else raise 'There was not enough information during training to do a proper induction for this data element' end

  puts id3.eval(['New York', '<30', 'M'])
    # =>  'Y'

0 个答案:

没有答案