[mlpack] How to keep object when searching neighbors?

Ryan Curtin gth671b at mail.gatech.edu
Wed Jan 15 23:19:32 EST 2014


On Thu, Jan 16, 2014 at 11:57:00AM +0800, Li Dong wrote:
> > The AllkNN object (which is a typedef for NeighborSearch) will build and
> > internally hold the tree for the reference points, and because
> > singleMode == true, it won't build the tree for the query points.  It is
> > possible to make your own tree and pass that in, too, if that is what
> > you prefer.
> 
> 
> I found the following constructors with referenceTree:
> 
> RangeSearch (TreeType *referenceTree, const typename TreeType::Mat &referenceSet, const bool singleMode=false, const MetricTypemetric=MetricType())
> 
> RangeSearch (TreeType *referenceTree, TreeType *queryTree, const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const bool singleMode=false, const MetricTypemetric=MetricType())
> 
> It looks like I need to construct queryTree since the reference set and query set are not the same. I see no other place to pass trees. Correct me if I am wrong.

Why not use this constructor?

RangeSearch(const typename TreeType::Mat& referenceSet,
            const typename TreeType::Mat& querySet,
            const bool naive = false,
            const bool singleMode = false,
            const size_t leafSize = 20,
            const MetricType metric = MetricType());

It will automatically build the trees for you, and if you specify
singleMode = true, then the query tree wil not be built.

If you want to use the constructors where you manually pass trees, you
can pass queryTree = NULL if singleMode = true.

-- 
Ryan Curtin    | "What? Facts?"
ryan at ratml.org |   - Joe Cairo



More information about the mlpack mailing list