Class: Faiss::Kmeans
- Inherits:
-
Object
- Object
- Faiss::Kmeans
- Defined in:
- lib/faiss/kmeans.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/faiss/kmeans.rb', line 3 def index @index end |
Instance Method Details
#centroids ⇒ Object
11 12 13 |
# File 'lib/faiss/kmeans.rb', line 11 def centroids Numo::SFloat.from_binary(_centroids).reshape(k, d) end |
#train(objects) ⇒ Object
5 6 7 8 9 |
# File 'lib/faiss/kmeans.rb', line 5 def train(objects) objects = Numo::SFloat.cast(objects) unless objects.is_a?(Numo::SFloat) @index = IndexFlatL2.new(d) _train(objects.shape[0], objects, @index) end |