[mlpack-git] [mlpack/mlpack] Vantage point tree (#708)

Ryan Curtin notifications at github.com
Thu Jul 21 19:32:23 EDT 2016


> +{
> +  std::vector<SortStruct<ElemType>> sorted(samples.n_rows);
> +
> +  for (size_t i = 0; i < samples.n_rows; i++)
> +  {
> +    sorted[i].point = samples[i];
> +    sorted[i].dist = bound.Metric().Evaluate(data.col(vantagePoint),
> +        data.col(samples[i]));
> +  }
> +
> +  //  Sort samples according to the distance to the vantage point
> +  std::sort(sorted.begin(), sorted.end(), StructComp<ElemType>);
> +
> +  //  Get the midian value
> +  mu = bound.Metric().Evaluate(data.col(vantagePoint),
> +      data.col(sorted[sorted.size() / 2].point));

Could you instead use Armadillo's `median()` function here?  You don't need the index of the median, just the median value itself, so I think Armadillo could work fine, and I think it would be less code (and possibly faster too).

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/708/files/300882ac96e7a663e3e303ca0c45c14c6fafe1a6#r71806108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160721/d1958570/attachment-0001.html>


More information about the mlpack-git mailing list