Class: LearnKit::Knn

Inherits:
Object
  • Object
show all
Includes:
Predict
Defined in:
lib/learn_kit/knn.rb,
lib/learn_kit/knn/predict.rb

Overview

K-Nearest Neighbors algorithm

Defined Under Namespace

Modules: Predict Classes: LearnFailure

Constant Summary

Constants included from Predict

Predict::UNIFORM_WEIGHT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Predict

#predict

Constructor Details

#initialize(args = {}) ⇒ Knn

input data { label1: [[f1, f2, f3], [f1, f2, f3]], label2: [[f4, f5, f6], [f4, f5, f6]] }



14
15
16
17
# File 'lib/learn_kit/knn.rb', line 14

def initialize(args = {})
  @data_set = args[:data_set]
  @points = []
end

Instance Attribute Details

#data_setObject (readonly)

Returns the value of attribute data_set.



10
11
12
# File 'lib/learn_kit/knn.rb', line 10

def data_set
  @data_set
end

#pointsObject (readonly)

Returns the value of attribute points.



10
11
12
# File 'lib/learn_kit/knn.rb', line 10

def points
  @points
end