class VowpalWabbit::Regressor

Public Instance Methods

intercept() click to toggle source
# File lib/vowpalwabbit/regressor.rb, line 12
def intercept
  FFI.VW_Get_Weight(handle, 116060, 0)
end
score(x, y = nil) click to toggle source
# File lib/vowpalwabbit/regressor.rb, line 3
def score(x, y = nil)
  y_pred, y = predict_for_score(x, y)

  # r2
  sse = y_pred.zip(y).map { |yp, yt| (yp - yt) ** 2 }.sum
  sst = y.map { |yi| yi ** 2 }.sum - (y.sum ** 2) / y.size
  1 - sse / sst
end