Sha256: 3fdc42eddbc31bbe89def6c9f255a203a8eda43ded69e0f7760706871b8e988e

Contents?: true

Size: 359 Bytes

Versions: 6

Compression:

Stored size: 359 Bytes

Contents

module VowpalWabbit
  class Regressor < Model
    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

    def intercept
      FFI.VW_Get_Weight(handle, 116060, 0)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vowpalwabbit-0.3.0 lib/vowpalwabbit/regressor.rb
vowpalwabbit-0.2.0 lib/vowpalwabbit/regressor.rb
vowpalwabbit-0.1.3 lib/vowpalwabbit/regressor.rb
vowpalwabbit-0.1.2 lib/vowpalwabbit/regressor.rb
vowpalwabbit-0.1.1 lib/vowpalwabbit/regressor.rb
vowpalwabbit-0.1.0 lib/vowpalwabbit/regressor.rb