machine learning - Classification using Approximate Nearest Neighbors in Scikit-Learn -


i have labeled dataset having 46d featureset , around 5000 samples want classify using approximate nearest neighbors.

since i'm familiar scikit-learn, want utilize achieve goal.

the scikit documentations lists lshforest 1 of probable methods ann, it's unclear me how apply classification purposes.

very nice question. unfortunately scikit-learn not seem support custom neighbor model now, can, implement simple wrapper on own, such as

from sklearn.neighbors import lshforest import numpy np scipy.stats import mode  class lsh_knn:      def __init__(self, **kwargs):         self.n_neighbors = kwargs['n_neighbors']         self.lsh = lshforest(**kwargs)      def fit(self, x, y):         self.y = y         self.lsh.fit(x)      def predict(self, x):         _, indices = self.lsh.kneighbors(x, n_neighbors = self.n_neighbors)         votes, _ = mode(self.y[indices], axis=1)         return votes.flatten() 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -