Class: KNN

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

Instance Method Summary collapse

Constructor Details

#initialize(data, options = {}) ⇒ KNN

Returns a new instance of KNN.



4
5
6
7
# File 'lib/knn.rb', line 4

def initialize(data, options={})
  @data = data
  @distance_measure = options[:distance_measure] || :euclidean_distance
end

Instance Method Details

#nearest_neighbours(input, k = 4) ⇒ Object



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

def nearest_neighbours(input, k=4)
  find_closest_data(input, k)
end