We should think about whether we want to pass this rather strange behavior
on to the NearestNeighbor interface. Remember, NearestNeighbor supports
different algorithms (it might for example use brute force to look up the
neighbors within a radius).  So if I use the "radius_neighbors" method of
NearestNeighbors using the "brute" algorithm, the return type is not in the
"object" dtype, but if I use the "ball_tree" algorithm, it is.

This is all unnecessarily confusing for the user of NearestNeighbor,
especially becaue the documentation of "radius_neighbors" suggests that
you're only looking up the neighbors of a single point.  Thus the "special
case" you mentioned above (looking up the radius neighbors of a single
point), is the suggested default case according to the documentation, and
behaves oddly.

Maybe the best thing to do would be to only support looking up the radius
neighbors of one point at a time.  Then we don't have to worry about the
fact that different points will have different numbers of neighbors within
a give radius.


On Wed, Nov 21, 2012 at 5:49 PM, Lars Buitinck <[email protected]> wrote:

> 2012/11/21 Conrad Lee <[email protected]>:
> > The strange thing is that idxs is of dtype "object".  I thus can't use
> it in
> > the way I'd normally use it if it were an integer array.  I can't do
> > idxs.ravel() to get a flat list of the indices.  idxs.shape returns (1,),
> > which is awkward.  If I run `idxs.astype("u8") I get an error
> (ValueError:
> > setting an array element with a sequence.).
> >
> > Is this behavior intended?  Can it be improved?  How can I convert the
> array
> > of dtype "object" into an integer array?
>
> I would say this is a bug. dtype=object is annoying and unnecessary
> when the array contains integers.
>
> --
> Lars Buitinck
> Scientific programmer, ILPS
> University of Amsterdam
>
>
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to