class Datasets::Mushroom
Constants
- CONVERTERS
- Record
Public Class Methods
new()
click to toggle source
Calls superclass method
Datasets::Dataset::new
# 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
Public Instance Methods
each() { |record| ... }
click to toggle source
# 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
Private Instance Methods
open_data() { |csv| ... }
click to toggle source
# File lib/datasets/mushroom.rb, line 59 def open_data data_path = cache_dir_path + "agaricus-lepiota.data" unless data_path.exist? data_url = "http://archive.ics.uci.edu/ml/machine-learning-databases/mushroom/agaricus-lepiota.data" download(data_path, data_url) end CSV.open(data_path) do |csv| yield(csv) end end
read_names()
click to toggle source
# File lib/datasets/mushroom.rb, line 70 def read_names names_path = cache_dir_path + "agaricus-lepiota.names" unless names_path.exist? names_url = "https://archive.ics.uci.edu/ml/machine-learning-databases//mushroom/agaricus-lepiota.names" download(names_path, names_url) end names_path.read end