mlpack  master
dbscan.hpp
Go to the documentation of this file.
1 
8 #ifndef MLPACK_METHODS_DBSCAN_DBSCAN_HPP
9 #define MLPACK_METHODS_DBSCAN_DBSCAN_HPP
10 
11 #include <mlpack/core.hpp>
14 #include <boost/dynamic_bitset.hpp>
15 
16 namespace mlpack {
17 namespace dbscan {
18 
44 template<typename RangeSearchType = range::RangeSearch<>,
45  typename PointSelectionPolicy = RandomPointSelection>
46 class DBSCAN
47 {
48  public:
57  DBSCAN(const double epsilon,
58  const size_t minPoints,
59  RangeSearchType rangeSearch = RangeSearchType(),
60  PointSelectionPolicy pointSelector = PointSelectionPolicy());
61 
70  template<typename MatType>
71  size_t Cluster(const MatType& data,
72  arma::mat& centroids);
73 
82  template<typename MatType>
83  size_t Cluster(const MatType& data,
84  arma::Row<size_t>& assignments);
85 
97  template<typename MatType>
98  size_t Cluster(const MatType& data,
99  arma::Row<size_t>& assignments,
100  arma::mat& centroids);
101 
102  private:
104  double epsilon;
105 
108  size_t minPoints;
109 
111  RangeSearchType rangeSearch;
112 
114  PointSelectionPolicy pointSelector;
115 
135  template<typename MatType>
136  size_t ProcessPoint(const MatType& data,
137  boost::dynamic_bitset<>& unvisited,
138  const size_t index,
139  arma::Row<size_t>& assignments,
140  const size_t currentCluster,
141  const std::vector<std::vector<size_t>>& neighbors,
142  const std::vector<std::vector<double>>& distances,
143  const bool topLevel = true);
144 };
145 
146 } // namespace dbscan
147 } // namespace mlpack
148 
149 // Include implementation.
150 #include "dbscan_impl.hpp"
151 
152 #endif
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a clustering technique descri...
Definition: dbscan.hpp:46
double epsilon
Maximum distance between two points to be part of same cluster.
Definition: dbscan.hpp:104
PointSelectionPolicy pointSelector
Instantiated point selection policy.
Definition: dbscan.hpp:114
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
size_t ProcessPoint(const MatType &data, boost::dynamic_bitset<> &unvisited, const size_t index, arma::Row< size_t > &assignments, const size_t currentCluster, const std::vector< std::vector< size_t >> &neighbors, const std::vector< std::vector< double >> &distances, const bool topLevel=true)
This function processes the point at index.
size_t Cluster(const MatType &data, arma::mat &centroids)
Performs DBSCAN clustering on the data, returning number of clusters and also the centroid of each cl...
RangeSearchType rangeSearch
Instantiated range search policy.
Definition: dbscan.hpp:111
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
size_t minPoints
Minimum number of points to be in the epsilon-neighborhood (including itself) for the point to be a c...
Definition: dbscan.hpp:108
DBSCAN(const double epsilon, const size_t minPoints, RangeSearchType rangeSearch=RangeSearchType(), PointSelectionPolicy pointSelector=PointSelectionPolicy())
Construct the DBSCAN object with the given parameters.