[mlpack] Custom metric question

Alasdair Newson alasdairnewson at gmail.com
Mon Feb 8 16:23:18 EST 2016


Hello Ryan,

Thanks for your reply ! I tried to declare the following nearest neighbor
search tree :

typedef NeighborSearch<
    NearestNeighborSort,
    customMetric,
    BinarySpaceTree<BallBound<2>,
                          QueryStat<NearestNeighborSort> >
> customNeighborSearch;

Where custom metric is as follows :

    class customMetric
    {
        public:
        /***
        * Default constructor does nothing, but is required to satisfy the
Metric
        * policy.
        */
        customMetric(){}
        template<typename VecTypeA, typename VecTypeB>
         double Evaluate(const VecTypeA& a, const VecTypeB& b);
    };

When I compile, I receive the following message :

error: type/value mismatch at argument 1 in template parameter list for
‘template<class VecType, class TMetricType> class mlpack::bound::BallBound’
     BinarySpaceTree<BallBound<2>,

I am sure I am doing something silly, but I do not know exactly what. I
tried to follow the example on the following web page :

http://www.mlpack.org/docs/mlpack-2.0.1/doxygen.php?doc=nstutorial.html#neighborsearch_nstut

Thank you very much for your help,

Kind regards,

Alasdair

On 8 February 2016 at 15:53, Ryan Curtin <ryan at ratml.org> wrote:

> On Sun, Feb 07, 2016 at 02:49:21PM +0100, Alasdair Newson wrote:
> > Dear all,
> >
> > I recently downloaded mlpack, and I am trying to use it for a knnsearch,
> > with a customised metric. I am having some trouble coding this, so I
> > wondered if anyone has tried this before, and might have some example
> code.
> >
> > At the moment, I am trying to define a NeighborSearch class which uses a
> > custom metric. I had tried with the default options, but apparently a
> > custom metric is not compatible with the HRect bound type. I am trying
> with
> > a BallBound, but I am still having compilation problems. Has anyone done
> > this before ?
> >
> > Kind regards,
> >
> > Alasdair Newson
>
> Hi Alasdair,
>
> You're right that a custom metric isn't compatible with the HRectBound
> type.  This is because the HRectBound is written specifically for an
> LMetric.
>
> The BallBound is more flexible, though, and should be able to handle
> other types of metrics.  Can you paste the compilation problems that you
> are having?  That would shed some light on the issue.
>
> Thanks,
>
> Ryan
>
> --
> Ryan Curtin    | "Are those... live rounds?"
> ryan at ratml.org | "Seven-six-two millimeter.  Full metal jacket."
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack/attachments/20160208/fb0a133f/attachment.html>


More information about the mlpack mailing list