[mlpack-git] [mlpack/mlpack] Modeling LSH For Performance Tuning (#749)
notifications at github.com
Tue Aug 30 04:58:40 EDT 2016
> + // Reference set for kNN
> + arma::mat refMat = sampleSet.cols(refSetStart, refSetEnd);
> + referenceSizes(i) = refMat.n_cols;
> + arma::Mat<size_t> neighbors; // Not going to be used but required.
> + arma::mat kNNDistances; // What we need.
> + KNN naive(refMat, true); // true: train and use naive kNN.
> + naive.Search(queryMat, k, neighbors, kNNDistances);
> + // Store the squared distances (what we need).
> + kNNDistances = arma::pow(kNNDistances, 2);
> + // Compute Arithmetic and Geometric mean of the distances.
> + Ek.row(i) = arma::mean(kNNDistances.t());
> + Gk.row(i) = arma::exp(arma::mean(arma::log(kNNDistances.t()), 0));
Yes, I'm using an alternative way to compute it:
pow(prod(x_i)), 1/N) =
exp(log(pow(prod(x_i)), 1/N))) =
exp(1/N * [ log(prod(x_i))]) =
exp(1/N * sum( log(x_i))) =
Computing the geometric mean this way allows me to use arma::mean(), which can calculate the row-wise, column-wise or overall mean. In this case we have a `queryMat.n_rows` x `k` matrix, and we want the average of each column - or at least, that's my understanding of the paper.
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mlpack-git