[mlpack-git] [mlpack/mlpack] Modeling LSH For Performance Tuning (#749)
notifications at github.com
Tue Aug 30 09:08:16 EDT 2016
> + Timer::Start("pairwise_distances");
> + arma::vec distances(numSamples * (numSamples - 1) / 2);
> + size_t d = 0; // Index of where to store next.
> + for (size_t i = 0; i < numSamples; ++i)
> + for (size_t j = i + 1; j < numSamples; ++j)
> + distances(d++) = metric::EuclideanDistance::Evaluate(
> + sampleSet.unsafe_col(i), sampleSet.unsafe_col(j));
> + Log::Info << "Computed " << d << " pointwise distances." << std::endl;
> + Timer::Stop("pairwise_distances");
> + // Step 3. Estimate statistics of these distances: log(mean(d)), mean(log(d)),
> + // mean(d).
> + distances = arma::pow(distances, 2);
> + this->meanDist = arma::mean(distances);
> + this->logMeanDist = std::log(meanDist);
> + this->meanLogDist = arma::mean(arma::log(distances));
I think for the geometric mean calculation, you should do the same hack as the one I suggested for the full distances distribution: "fake" a small nonzero value. The gamma distribution doesn't have any probability mass at 0, so really it's not even the right distribution to use when there are zero distances. But I'm not sure of what other alternatives might be, so I think just using this hack to make it work for now should be okay...
If you have a better idea for how to modify the distances away from 0, do it---the idea I wrote down was just the first thing I could think of that seemed to work.
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