k-Nearest Neighbor is probably the most frequently used algorithm for real-time online recommendations.
In NumPy / SciPy you have several options [note: the answer was updated on December 12 to reflect updates in the sklearn library]:
nearest neighbors module in scikit-learn (aka sklearn ); This is a complex implementation of kNN, which includes the offset and voting of a neighbor, as well as a very efficient storage / retrieval component (spherical tree);
scipy.spatial . I used this for several projects, although it is unlikely that I will use it for my next, which is now available for sklearn, which is a more modern implementation of kNN. However, the spatial module has the kd-tree class (instead of the standard numpy array, kd-tree is used by this module to store data, which along w / Voronoi teselation is the most common specialized data structure for storing very large data sets for kNN); in addition, it has methods for several distance metrics (other than Euclidean distance).
source share