class VowpalWabbit::Classifier
Public Class Methods
new(**params)
click to toggle source
Calls superclass method
# File lib/vowpalwabbit/classifier.rb, line 3 def initialize(**params) super(loss_function: "logistic", **params) end
Public Instance Methods
predict(x)
click to toggle source
Calls superclass method
# File lib/vowpalwabbit/classifier.rb, line 7 def predict(x) predictions = super predictions.map { |v| v >= 0 ? 1 : -1 } end
score(x, y = nil)
click to toggle source
# File lib/vowpalwabbit/classifier.rb, line 12 def score(x, y = nil) y_pred, y = predict_for_score(x, y) y_pred.map! { |v| v >= 0 ? 1 : -1 } y_pred.zip(y).select { |yp, yt| yp == yt }.count / y.count.to_f end