Class: Datasets::Iris

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

#initializeIris

Returns a new instance of Iris.



13
14
15
16
17
18
19
20
21
22
# File 'lib/datasets/iris.rb', line 13

def initialize
  super()
  @metadata.id = "iris"
  @metadata.name = "Iris"
  @metadata.url = "https://archive.ics.uci.edu/ml/datasets/Iris"
  @metadata.licenses = ["CC-BY-4.0"]
  @metadata.description = lambda do
    read_names
  end
end

Instance Method Details

#eachObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/datasets/iris.rb', line 24

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