[WIP] Locality Sensitive Hashing for approximate nearest neighbor search(GSoC)

I think heuristic switching is a bad idea. I've realised that underlyingly,
np.linalg.norm doesn't use a particularly efficient approach (perhaps in
order to generalise to higher dimensions). What you should be using is
sklearn.utils.extmath.row_norms which can still occasionally be slower than
the Python loop for many features, but which is often faster than both the
approaches you have tried and which supports sparse matrices as well. I
would also suggest removing _simple_euclidean_distance and putting the
row_norms call straight in _compute_distances


On 14 August 2014 15:23, Maheshakya Wijewardena <notifications@github.com>
wrote:

>  In sklearn/neighbors/lsh_forest.py:
>
> > +    while lo < hi:
> > +        mid = (lo+hi)//2
> > +
> > +        k = _find_matching_indices(bit_string_array, query,
> > +                                   left_masks[mid],
> > +                                   right_masks[mid]).shape[0]
> > +        if k > 0:
> > +            lo = mid + 1
> > +            res = mid
> > +        else:
> > +            hi = mid
> > +
> > +    return res
> > +
> > +
> > +def _simple_euclidean_distance(query, candidates):
>
> This change starts to happen at n_features is around 3500. I guess it's
> better if I use that as a heuristic to switch between loop and the
> vectorized method. @jnothman <https://github.com/jnothman> , any idea?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/scikit-learn/scikit-learn/pull/3304/files#r16221650>.
>