All Projects → ankane → faiss-ruby

ankane / faiss-ruby

Licence: MIT license
Efficient similarity search and clustering for Ruby

Programming Languages

C++
36643 projects - #6 most used programming language
ruby
36898 projects - #4 most used programming language
python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to faiss-ruby

osm-data-classification
Migrated to: https://gitlab.com/Oslandia/osm-data-classification
Stars: ✭ 23 (-62.9%)
Mutual labels:  pca, kmeans
deepvis
machine learning algorithms in Swift
Stars: ✭ 54 (-12.9%)
Mutual labels:  pca, kmeans
Ailearning
AiLearning: 机器学习 - MachineLearning - ML、深度学习 - DeepLearning - DL、自然语言处理 NLP
Stars: ✭ 32,316 (+52022.58%)
Mutual labels:  pca, kmeans
ml-simulations
Animated Visualizations of Popular Machine Learning Algorithms
Stars: ✭ 33 (-46.77%)
Mutual labels:  pca, kmeans
Vizuka
Explore high-dimensional datasets and how your algo handles specific regions.
Stars: ✭ 100 (+61.29%)
Mutual labels:  pca, kmeans
AnnA Anki neuronal Appendix
Using machine learning on your anki collection to enhance the scheduling via semantic clustering and semantic similarity
Stars: ✭ 39 (-37.1%)
Mutual labels:  pca, kmeans
Machine-Learning-Models
In This repository I made some simple to complex methods in machine learning. Here I try to build template style code.
Stars: ✭ 30 (-51.61%)
Mutual labels:  pca, ann
MachineLearning
Implementations of machine learning algorithm by Python 3
Stars: ✭ 16 (-74.19%)
Mutual labels:  pca, kmeans
ml
经典机器学习算法的极简实现
Stars: ✭ 130 (+109.68%)
Mutual labels:  pca, kmeans
Patternrecognition matlab
Feature reduction projections and classifier models are learned by training dataset and applied to classify testing dataset. A few approaches of feature reduction have been compared in this paper: principle component analysis (PCA), linear discriminant analysis (LDA) and their kernel methods (KPCA,KLDA). Correspondingly, a few approaches of classification algorithm are implemented: Support Vector Machine (SVM), Gaussian Quadratic Maximum Likelihood and K-nearest neighbors (KNN) and Gaussian Mixture Model(GMM).
Stars: ✭ 33 (-46.77%)
Mutual labels:  pca
Machine Learning In R
Workshop (6 hours): preprocessing, cross-validation, lasso, decision trees, random forest, xgboost, superlearner ensembles
Stars: ✭ 144 (+132.26%)
Mutual labels:  pca
Plnmodels
A collection of Poisson lognormal models for multivariate count data analysis
Stars: ✭ 31 (-50%)
Mutual labels:  pca
Ml code
A repository for recording the machine learning code
Stars: ✭ 75 (+20.97%)
Mutual labels:  pca
Miscellaneous R Code
Code that might be useful to others for learning/demonstration purposes, specifically along the lines of modeling and various algorithms. Now almost entirely superseded by the models-by-example repo.
Stars: ✭ 146 (+135.48%)
Mutual labels:  pca
Machine Failure Detection
PCA and DBSCAN based anomaly and outlier detection method for time series data.
Stars: ✭ 32 (-48.39%)
Mutual labels:  pca
Pca Magic
PCA that iteratively replaces missing data
Stars: ✭ 185 (+198.39%)
Mutual labels:  pca
Digital Image Processing Algorithms
SJTU CS386 Digital Image Processing
Stars: ✭ 20 (-67.74%)
Mutual labels:  pca
python-neuron
Neuron class provides LNU, QNU, RBF, MLP, MLP-ELM neurons
Stars: ✭ 38 (-38.71%)
Mutual labels:  ann
Parameters
📊 Computation and processing of models' parameters
Stars: ✭ 181 (+191.94%)
Mutual labels:  pca
Msmbuilder
🏗 Statistical models for biomolecular dynamics 🏗
Stars: ✭ 118 (+90.32%)
Mutual labels:  pca

Faiss Ruby

Faiss - efficient similarity search and clustering - for Ruby

Learn more about Faiss

Build Status

Installation

First, ensure BLAS, LAPACK, and OpenMP are installed. For Mac, use:

brew install libomp

For Ubuntu, use:

sudo apt-get install libblas-dev liblapack-dev

Then add this line to your application’s Gemfile:

gem "faiss"

It can take a few minutes to compile the gem. Windows is not currently supported.

Getting Started

Prep your data

objects = [
  [1, 1, 2, 1],
  [5, 4, 6, 5],
  [1, 2, 1, 2]
]

Build an index

index = Faiss::IndexFlatL2.new(4)
index.add(objects)

Search

distances, ids = index.search(objects, 3)

Save an index

index.save("index.bin")

Load an index

index = Faiss::Index.load("index.bin")

Use Faiss::IndexBinary to load binary indexes

Basic Indexes

Exact search for L2

Faiss::IndexFlatL2.new(d)

Exact search for inner product

Faiss::IndexFlatIP.new(d)

Hierarchical navigable small world graph exploration

Faiss::IndexHNSWFlat.new(d, m)

Inverted file with exact post-verification

Faiss::IndexIVFFlat.new(quantizer, d, nlists)

Locality-sensitive hashing

Faiss::IndexLSH.new(d, nbits)

Scalar quantizer (SQ) in flat mode

Faiss::IndexScalarQuantizer.new(d, qtype)

Product quantizer (PQ) in flat mode

Faiss::IndexPQ.new(d, m, nbits)

IVF and scalar quantizer

Faiss::IndexIVFScalarQuantizer.new(quantizer, d, nlists, qtype)

IVFADC (coarse quantizer+PQ on residuals)

Faiss::IndexIVFPQ.new(quantizer, d, nlists, m, nbits)

IVFADC+R (same as IVFADC with re-ranking based on codes)

Faiss::IndexIVFPQR.new(quantizer, d, nlists, m, nbits, m_refine, nbits_refine)

Binary Indexes

Index binary vectors

Faiss::IndexBinaryFlat.new(d)

Speed up search with an inverse vector file

Faiss::IndexBinaryIVF.new(quantizer, d, nlists)

K-means Clustering

Train

kmeans = Faiss::Kmeans.new(4, 2)
kmeans.train(objects)

Get the centroids

kmeans.centroids

PCA

Train

mat = Faiss::PCAMatrix.new(40, 10)
mat.train(objects)

Apply

mat.apply(mt)

Product Quantizer

Train

pq = Faiss::ProductQuantizer.new(32, 4, 8)
pq.train(objects)

Encode

pq.compute_codes(objects)

Decode

pq.decode(codes)

Save a quantizer

pq.save("pq.bin")

Load a quantizer

pq = Faiss::ProductQuantizer.load("pq.bin")

Data

Data can be an array of arrays

[[1, 2, 3], [4, 5, 6]]

Or a Numo array

Numo::NArray.cast([[1, 2, 3], [4, 5, 6]])

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone --recursive https://github.com/ankane/faiss-ruby.git
cd faiss-ruby
bundle install
bundle exec rake compile
bundle exec rake test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].