13 #ifndef MLPACK_METHODS_KDE_KDE_HPP 14 #define MLPACK_METHODS_KDE_KDE_HPP 48 static constexpr
double mcProb = 0.95;
76 typename MatType = arma::mat,
77 template<
typename TreeMetricType,
78 typename TreeStatType,
80 template<
typename RuleType>
class DualTreeTraversalType =
83 MatType>::template DualTreeTraverser,
84 template<
typename RuleType>
class SingleTreeTraversalType =
87 MatType>::template SingleTreeTraverser>
92 typedef TreeType<MetricType, kde::KDEStat, MatType>
Tree;
116 KernelType kernel = KernelType(),
118 MetricType metric = MetricType(),
145 KDE& operator=(
const KDE& other);
152 KDE& operator=(
KDE&& other);
167 void Train(MatType referenceSet);
179 void Train(Tree* referenceTree, std::vector<size_t>* oldFromNewReferences);
195 void Evaluate(MatType querySet, arma::vec& estimations);
212 void Evaluate(Tree* queryTree,
213 const std::vector<size_t>& oldFromNewQueries,
214 arma::vec& estimations);
226 void Evaluate(arma::vec& estimations);
229 const KernelType&
Kernel()
const {
return kernel; }
235 const MetricType&
Metric()
const {
return metric; }
247 void RelativeError(
const double newError);
253 void AbsoluteError(
const double newError);
278 void MCProb(
const double newProb);
290 void MCEntryCoef(
const double newCoef);
296 void MCBreakCoef(
const double newCoef);
299 template<
typename Archive>
300 void serialize(Archive& ar,
const uint32_t version);
313 std::vector<size_t>* oldFromNewReferences;
322 bool ownsReferenceTree;
350 static void CheckErrorValues(
const double relError,
const double absError);
353 static void RearrangeEstimations(
const std::vector<size_t>& oldFromNew,
354 arma::vec& estimations);
361 #include "kde_impl.hpp" 363 #endif // MLPACK_METHODS_KDE_KDE_HPP KernelType & Kernel()
Modify the kernel.
static constexpr double relError
Relative error tolerance.
bool & MonteCarlo()
Modify whether Monte Carlo estimations are being used or not.
Linear algebra utility functions, generally performed on matrices or vectors.
double MCProb() const
Get Monte Carlo probability of error being bounded by relative error.
KDEMode
KDEMode represents the ways in which KDE algorithm can be executed.
bool IsTrained() const
Check whether KDE model is trained or not.
static constexpr double mcBreakCoef
Monte Carlo break coefficient.
const KernelType & Kernel() const
Get the kernel.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const MetricType & Metric() const
Get the metric.
size_t MCInitialSampleSize() const
Get Monte Carlo initial sample size.
Extra data for each node in the tree for the task of kernel density estimation.
KDEMode & Mode()
Modify the mode of KDE.
KDEMode Mode() const
Get the mode of KDE.
TreeType< MetricType, kde::KDEStat, MatType > Tree
Convenience typedef.
static constexpr KDEMode mode
KDE algorithm mode.
MetricType & Metric()
Modify the metric.
static constexpr double absError
Absolute error tolerance.
double RelativeError() const
Get relative error tolerance.
The KDE class is a template class for performing Kernel Density Estimations.
static constexpr bool monteCarlo
Whether to use Monte Carlo estimations when possible.
bool MonteCarlo() const
Get whether Monte Carlo estimations are being used or not.
static constexpr size_t initialSampleSize
Initial sample size for Monte Carlo estimations.
static constexpr double mcEntryCoef
Monte Carlo entry coefficient.
KDEDefaultParams contains the default input parameter values for KDE.
static constexpr double mcProb
Probability of a Monte Carlo estimation to be bounded by the relative error tolerance.
double MCEntryCoef() const
Get Monte Carlo entry coefficient.
size_t & MCInitialSampleSize()
Modify Monte Carlo initial sample size.
The standard Gaussian kernel.
double MCBreakCoef() const
Get Monte Carlo break coefficient.
BinarySpaceTree< MetricType, StatisticType, MatType, bound::HRectBound, MidpointSplit > KDTree
The standard midpoint-split kd-tree.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
Tree * ReferenceTree()
Get the reference tree.
bool OwnsReferenceTree() const
Check whether reference tree is owned by the KDE model.
double AbsoluteError() const
Get absolute error tolerance.