13 #ifndef MLPACK_METHODS_KDE_KDE_HPP 14 #define MLPACK_METHODS_KDE_KDE_HPP 47 typename MatType = arma::mat,
48 template<
typename TreeMetricType,
49 typename TreeStatType,
51 template<
typename RuleType>
class DualTreeTraversalType =
54 MatType>::template DualTreeTraverser,
55 template<
typename RuleType>
class SingleTreeTraversalType =
58 MatType>::template SingleTreeTraverser>
63 typedef TreeType<MetricType, kde::KDEStat, MatType>
Tree;
74 KDE(
const double relError = 0.05,
75 const double absError = 0,
76 KernelType kernel = KernelType(),
78 MetricType metric = MetricType());
117 void Train(MatType referenceSet);
129 void Train(Tree* referenceTree, std::vector<size_t>* oldFromNewReferences);
145 void Evaluate(MatType querySet, arma::vec& estimations);
163 const std::vector<size_t>& oldFromNewQueries,
164 arma::vec& estimations);
176 void Evaluate(arma::vec& estimations);
179 const KernelType&
Kernel()
const {
return kernel; }
185 const MetricType&
Metric()
const {
return metric; }
218 template<
typename Archive>
219 void serialize(Archive& ar,
const unsigned int );
232 std::vector<size_t>* oldFromNewReferences;
241 bool ownsReferenceTree;
250 static void CheckErrorValues(
const double relError,
const double absError);
253 static void RearrangeEstimations(
const std::vector<size_t>& oldFromNew,
254 arma::vec& estimations);
261 #include "kde_impl.hpp" 263 #endif // MLPACK_METHODS_KDE_KDE_HPP KernelType & Kernel()
Modify the kernel.
KDEMode
KDEMode represents the ways in which KDE algorithm can be executed.
bool IsTrained() const
Check whether KDE model is trained or not.
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.
KDE & operator=(KDE other)
Copy a KDE model.
KDE(const double relError=0.05, const double absError=0, KernelType kernel=KernelType(), const KDEMode mode=DUAL_TREE_MODE, MetricType metric=MetricType())
Initialize KDE object using custom instantiated Metric and Kernel objects.
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.
void Train(MatType referenceSet)
Trains the KDE model.
void serialize(Archive &ar, const unsigned int)
Serialize the model.
MetricType & Metric()
Modify the metric.
void Evaluate(MatType querySet, arma::vec &estimations)
Estimate density of each point in the query set given the data of the reference set.
double RelativeError() const
Get relative error tolerance.
The KDE class is a template class for performing Kernel Density Estimations.
~KDE()
Destroy the KDE object.
The standard Gaussian kernel.
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.