class Uranai::Data

Attributes

data[R]

Public Class Methods

new(csv) click to toggle source
# File lib/uranai/data.rb, line 6
def initialize(csv)
  @data = CSV.read(csv).map { |arr| arr.map(&:to_f) }.transpose
end

Public Instance Methods

column_size() click to toggle source
# File lib/uranai/data.rb, line 10
def column_size
  data.length
end
feature_size() click to toggle source
# File lib/uranai/data.rb, line 19
def feature_size
  column_size - 1
end
matrix_x() click to toggle source
# File lib/uranai/data.rb, line 33
def matrix_x
  Matrix.columns(x)
end
matrix_y() click to toggle source
# File lib/uranai/data.rb, line 45
def matrix_y
  Matrix.columns(y)
end
normalized_matrix_x() click to toggle source
# File lib/uranai/data.rb, line 37
def normalized_matrix_x
  Matrix.columns(normalized_x)
end
normalized_x() click to toggle source
# File lib/uranai/data.rb, line 27
def normalized_x
  FeatureNormalizer.new(raw_x)
    .normalize
    .insert(0, [1] * row_size)
end
row_size() click to toggle source
# File lib/uranai/data.rb, line 14
def row_size
  data.transpose.length
end
Also aliased as: training_example_size
training_example_size()
Alias for: row_size
x() click to toggle source
# File lib/uranai/data.rb, line 23
def x
  raw_x.insert(0, [1] * row_size)
end
y() click to toggle source
# File lib/uranai/data.rb, line 41
def y
  [data[-1]]
end

Private Instance Methods

raw_x() click to toggle source
# File lib/uranai/data.rb, line 53
def raw_x
  data[0...column_size-1]
end