Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-10 Thread Mark Regan
Thanks Fred and all. Appreciate the help. On Fri Jan 10 2014 at 1:26:13 PM, Fred Mailhot wrote: There are a few implementations of DTW in Cython floating around...I think mblondel has one. Maybe you could tweak one of these and see whether it yields a useful speed-up? https://github.com/SnippyH

Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-10 Thread Fred Mailhot
There are a few implementations of DTW in Cython floating around...I think mblondel has one. Maybe you could tweak one of these and see whether it yields a useful speed-up? https://github.com/SnippyHolloW/DTW_Cython http://www.mblondel.org/journal/2009/08/31/dynamic-time-warping-theory/ https://gi

Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-10 Thread Mark Regan
Am I correct to assume the only algorithm that will work with a custom distance metric is "brute"? DWT with 1NN is performing pretty slow with just 10,000 observations. New to Python, perhaps I could write the distance metric function more efficiently? # Define function to compute dynamic time wa

Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-10 Thread Gael Varoquaux
Fully agreed with Lars. On Fri, Jan 10, 2014 at 02:44:40PM +0100, Lars Buitinck wrote: > 2014/1/10 Robert Layton : > > I wonder if that check could be removed -- as long as the input is > > fancy-indexable, the code should otherwise not have an issue (until it hits > > the distance metric, in whic

Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-10 Thread Mark Regan
Thanks Joel! Great suggestion. This is now working for my use case. On Fri Jan 10 2014 at 5:46:17 AM, Lars Buitinck wrote: > 2014/1/10 Robert Layton : > > I wonder if that check could be removed -- as long as the input is > > fancy-indexable, the code should otherwise not have an issue (until it

Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-10 Thread Lars Buitinck
2014/1/10 Robert Layton : > I wonder if that check could be removed -- as long as the input is > fancy-indexable, the code should otherwise not have an issue (until it hits > the distance metric, in which case you have that covered). -1. Since high-d data is usually a mistake and NumPy offers easy

Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-09 Thread Robert Layton
I'd recommend Joel's suggestion for the short term. I wonder if that check could be removed -- as long as the input is fancy-indexable, the code should otherwise not have an issue (until it hits the distance metric, in which case you have that covered). On 10 January 2014 13:09, Joel Nothman wr

Re: [Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-09 Thread Joel Nothman
Can you just reshape your 3d array to a 2d array, and then reshape when input by your distance metric? On 10 January 2014 12:59, Mark Regan wrote: > Hi all, > > tldr: Is there a way for me to pass a 3D array to KNearestNeighbour? > > I have constructed a custom distance metric to be used with K

[Scikit-learn-general] K Nearest Neighbour with 3d array and custom distance metric

2014-01-09 Thread Mark Regan
Hi all, tldr: Is there a way for me to pass a 3D array to KNearestNeighbour? I have constructed a custom distance metric to be used with KNN. It takes *two 2D arrays* and returns a float. I believe this fits the requirements for a distance metric in sklearn. However, I am unable to pass a 3D arr