Class: Datasets::Mushroom

Inherits:
Dataset
  • Object
show all
Defined in:
lib/datasets/mushroom.rb

Defined Under Namespace

Classes: Record

Instance Attribute Summary

Attributes inherited from Dataset

#metadata

Instance Method Summary collapse

Methods inherited from Dataset

#clear_cache!, #to_table

Constructor Details

#initializeMushroom

Returns a new instance of Mushroom.



33
34
35
36
37
38
39
40
41
# File 'lib/datasets/mushroom.rb', line 33

def initialize
  super()
  @metadata.id = "mushroom"
  @metadata.name = "Mushroom"
  @metadata.url = "https://archive.ics.uci.edu/ml/datasets/mushroom"
  @metadata.description = lambda do
    read_names
  end
end

Instance Method Details

#eachObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/datasets/mushroom.rb', line 43

def each
  return to_enum(__method__) unless block_given?

  open_data do |csv|
    csv.each do |row|
      next if row[0].nil?
      record = Record.new(*row)
      record.members.each do |member|
        record[member] = CONVERTERS[member][record[member]]
      end
      yield(record)
    end
  end
end