Class: KNN
- Inherits:
-
Object
- Object
- KNN
- Defined in:
- lib/knn.rb
Instance Method Summary collapse
-
#initialize(data, options = {}) ⇒ KNN
constructor
A new instance of KNN.
- #nearest_neighbours(input, k = 4) ⇒ Object
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, ={}) @data = data @distance_measure = [: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 |