Module: Nimbus::LossFunctions

Defined in:
lib/nimbus/loss_functions.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) average(ids, value_table)



6
7
8
# File 'lib/nimbus/loss_functions.rb', line 6

def average(ids, value_table)
  ids.inject(0.0){|sum, i| sum + value_table[i]} / ids.size
end

+ (Object) mean_squared_error(ids, value_table, mean = nil)



10
11
12
13
# File 'lib/nimbus/loss_functions.rb', line 10

def mean_squared_error(ids, value_table, mean = nil)
  mean ||= self.average ids, value_table
  ids.inject(0.0){|sum, i| sum + ((value_table[i] - mean)**2) }
end

+ (Object) quadratic_loss(ids, value_table, mean = nil)



15
16
17
# File 'lib/nimbus/loss_functions.rb', line 15

def quadratic_loss(ids, value_table, mean = nil)
  self.mean_squared_error(ids, value_table, mean) / ids.size
end