14 #ifndef MLPACK_METHODS_RANN_RA_SEARCH_RULES_HPP 15 #define MLPACK_METHODS_RANN_RA_SEARCH_RULES_HPP 30 template<
typename SortPolicy,
typename MetricType,
typename TreeType>
60 const double alpha = 0.95,
61 const bool naive =
false,
74 void GetResults(arma::Mat<size_t>& neighbors, arma::mat& distances);
83 double BaseCase(
const size_t queryIndex,
const size_t referenceIndex);
107 double Score(
const size_t queryIndex, TreeType& referenceNode);
132 double Score(
const size_t queryIndex,
133 TreeType& referenceNode,
134 const double baseCaseResult);
153 double Rescore(
const size_t queryIndex,
154 TreeType& referenceNode,
155 const double oldScore);
175 double Score(TreeType& queryNode, TreeType& referenceNode);
197 double Score(TreeType& queryNode,
198 TreeType& referenceNode,
199 const double baseCaseResult);
223 double Rescore(TreeType& queryNode,
224 TreeType& referenceNode,
225 const double oldScore);
256 return !SortPolicy::IsBetter(c2.first, c1.first);
261 typedef std::priority_queue<Candidate, std::vector<Candidate>,
CandidateCmp>
307 const size_t neighbor,
308 const double distance);
313 double Score(
const size_t queryIndex,
314 TreeType& referenceNode,
315 const double distance,
316 const double bestDistance);
321 double Score(TreeType& queryNode,
322 TreeType& referenceNode,
323 const double distance,
324 const double bestDistance);
327 "must provide a unique number of descendants points.");
334 #include "ra_search_rules_impl.hpp" 336 #endif // MLPACK_METHODS_RANN_RA_SEARCH_RULES_HPP void GetResults(arma::Mat< size_t > &neighbors, arma::mat &distances)
Store the list of candidates for each query point in the given matrices.
std::priority_queue< Candidate, std::vector< Candidate >, CandidateCmp > CandidateList
Use a priority queue to represent the list of candidate neighbors.
tree::TraversalInfo< TreeType > TraversalInfoType
bool firstLeafExact
Whether to do exact computation on the first leaf before any sampling.
The TraversalInfo class holds traversal information which is used in dual-tree (and single-tree) trav...
bool operator()(const Candidate &c1, const Candidate &c2)
double samplingRatio
The sampling ratio.
Linear algebra utility functions, generally performed on matrices or vectors.
size_t numSamplesReqd
The minimum number of samples required per query.
MetricType & metric
The instantiated metric.
double Rescore(const size_t queryIndex, TreeType &referenceNode, const double oldScore)
Re-evaluate the score for recursion order.
double Score(const size_t queryIndex, TreeType &referenceNode)
Get the score for recursion order.
TraversalInfoType traversalInfo
std::pair< double, size_t > Candidate
Candidate represents a possible candidate neighbor (distance, index).
arma::Col< size_t > numSamplesMade
The number of samples made for every query.
const TraversalInfoType & TraversalInfo() const
const arma::mat & querySet
The query set.
const size_t k
Number of neighbors to search for.
std::vector< CandidateList > candidates
Set of candidate neighbors for each point.
void InsertNeighbor(const size_t queryIndex, const size_t neighbor, const double distance)
Helper function to insert a point into the list of candidate points.
bool sampleAtLeaves
Whether to sample at leaves or just use all of it.
const arma::mat & referenceSet
The reference set.
TraversalInfoType & TraversalInfo()
The TreeTraits class provides compile-time information on the characteristics of a given tree type...
bool sameSet
If the query and reference set are identical, this is true.
see subsection cli_alt_reg_tut Alternate DET regularization The usual regularized error f $R_ alpha(t)\f $of a node\f $t\f $is given by
size_t singleSampleLimit
The limit on the largest node that can be approximated by sampling.
double BaseCase(const size_t queryIndex, const size_t referenceIndex)
Get the distance from the query point to the reference point.
RASearchRules(const arma::mat &referenceSet, const arma::mat &querySet, const size_t k, MetricType &metric, const double tau=5, const double alpha=0.95, const bool naive=false, const bool sampleAtLeaves=false, const bool firstLeafExact=false, const size_t singleSampleLimit=20, const bool sameSet=false)
Construct the RASearchRules object.
The RASearchRules class is a template helper class used by RASearch class when performing rank-approx...
size_t NumEffectiveSamples()
size_t NumDistComputations()
Compare two candidates based on the distance.
size_t numDistComputations