lib/svmkit/linear_model/logistic_regression.rb in svmkit-0.2.5 vs lib/svmkit/linear_model/logistic_regression.rb in svmkit-0.2.6
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'svmkit/base/base_estimator'
require 'svmkit/base/classifier'
module SVMKit
# This module consists of the classes that implement generalized linear models.
@@ -131,20 +133,9 @@
n_samples, = x.shape
proba = Numo::DFloat.zeros(n_samples, 2)
proba[true, 1] = sigmoid(decision_function(x))
proba[true, 0] = 1.0 - proba[true, 1]
proba
- end
-
- # Claculate the mean accuracy of the given testing data.
- #
- # @param x [Numo::DFloat] (shape: [n_samples, n_features]) Testing data.
- # @param y [Numo::Int32] (shape: [n_samples]) True labels for testing data.
- # @return [Float] Mean accuracy
- def score(x, y)
- p = predict(x)
- n_hits = (y.to_a.map.with_index { |l, n| l == p[n] ? 1 : 0 }).inject(:+)
- n_hits / y.size.to_f
end
# Dump marshal data.
# @return [Hash] The marshal data about LogisticRegression.
def marshal_dump