class Datasets::Hepatitis

Public Class Methods

new() click to toggle source
Calls superclass method Datasets::Dataset::new
# File lib/datasets/hepatitis.rb, line 161
def initialize
  super()
  @metadata.id = "hepatitis"
  @metadata.name = "Hepatitis"
  @metadata.url = "https://archive.ics.uci.edu/ml/datasets/hepatitis"
  @metadata.description = lambda do
    read_names
  end
end

Public Instance Methods

each() { |record| ... } click to toggle source
# File lib/datasets/hepatitis.rb, line 171
def each
  return to_enum(__method__) unless block_given?

  open_data do |csv|
    csv.each do |row|
      record = Record.new(*row)
      yield(record)
    end
  end
end

Private Instance Methods

base_url() click to toggle source
# File lib/datasets/hepatitis.rb, line 183
def base_url
  "https://archive.ics.uci.edu/ml/machine-learning-databases/hepatitis"
end
open_data() { |csv| ... } click to toggle source
# File lib/datasets/hepatitis.rb, line 187
def open_data
  data_path = cache_dir_path + "hepatitis.csv"
  unless data_path.exist?
    data_url = "#{base_url}/hepatitis.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/hepatitis.rb, line 198
def read_names
  names_path = cache_dir_path + "hepatitis.names"
  unless names_path.exist?
    names_url = "#{base_url}/hepatitis.names"
    download(names_path, names_url)
  end
  names_path.read
end