Class: Datasets::Wine

Inherits:
Dataset show all
Defined in:
lib/datasets/wine.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

#initializeWine

Returns a new instance of Wine.



22
23
24
25
26
27
28
29
# File 'lib/datasets/wine.rb', line 22

def initialize
  super
  @metadata.id = 'wine'
  @metadata.name = 'Wine'
  @metadata.url = 'https://archive.ics.uci.edu/ml/datasets/wine'
  @metadata.licenses = ["CC-BY-4.0"]
  @metadata.description = -> { read_names }
end

Instance Method Details

#eachObject



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

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)
      yield(record)
    end
  end
end