Class: SupervisedLearning::LogisticRegression

Inherits:
Object
  • Object
show all
Defined in:
lib/supervised_learning.rb

Overview

This class uses logistic regression to make discrete predictions (true or false) based on a training set. The algorithms in #predict were provided by Andrew Ng (Stanford University).

Author:

  • Michael Imstepf

Instance Method Summary collapse

Constructor Details

#initialize(training_set) ⇒ LogisticRegression

Initializes a LogisticRegression object with a training set

Parameters:

  • training_set (Matrix)

    training_set, each feature/dimension has one column and the last column is the output column (type of value #predict will return)

Raises:

  • (ArgumentError)

    if training_set is not a Matrix or does not have at least two columns and one row



157
158
159
160
161
# File 'lib/supervised_learning.rb', line 157

def initialize(training_set)
  @training_set = training_set
  raise ArgumentError, 'input is not a Matrix' unless @training_set.is_a? Matrix
  raise ArgumentError, 'Matrix must have at least 2 columns and 1 row' unless @training_set.column_size > 1
end