mlpack: a scalable c++ machine learning library
mlpack  2.0.2
refined_start.hpp
Go to the documentation of this file.
1 
16 #ifndef mlpack_METHODS_KMEANS_REFINED_START_HPP
17 #define mlpack_METHODS_KMEANS_REFINED_START_HPP
18 
19 #include <mlpack/core.hpp>
20 
21 namespace mlpack {
22 namespace kmeans {
23 
40 {
41  public:
47  RefinedStart(const size_t samplings = 100,
48  const double percentage = 0.02) :
50 
61  template<typename MatType>
62  void Cluster(const MatType& data,
63  const size_t clusters,
64  arma::mat& centroids) const;
65 
77  template<typename MatType>
78  void Cluster(const MatType& data,
79  const size_t clusters,
80  arma::Row<size_t>& assignments) const;
81 
83  size_t Samplings() const { return samplings; }
85  size_t& Samplings() { return samplings; }
86 
88  double Percentage() const { return percentage; }
90  double& Percentage() { return percentage; }
91 
93  template<typename Archive>
94  void Serialize(Archive& ar, const unsigned int /* version */)
95  {
96  ar & data::CreateNVP(samplings, "samplings");
97  ar & data::CreateNVP(percentage, "percentage");
98  }
99 
100  private:
102  size_t samplings;
104  double percentage;
105 };
106 
107 } // namespace kmeans
108 } // namespace mlpack
109 
110 // Include implementation.
111 #include "refined_start_impl.hpp"
112 
113 #endif
void Serialize(Archive &ar, const unsigned int)
Serialize the object.
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
RefinedStart(const size_t samplings=100, const double percentage=0.02)
Create the RefinedStart object, optionally specifying parameters for the number of samplings to perfo...
double & Percentage()
Modify the percentage of the data used by each subsampling.
double Percentage() const
Get the percentage of the data used by each subsampling.
double percentage
The percentage of the data to use for each subsampling.
void Cluster(const MatType &data, const size_t clusters, arma::mat &centroids) const
Partition the given dataset into the given number of clusters according to the random sampling scheme...
size_t Samplings() const
Get the number of samplings that will be performed.
size_t samplings
The number of samplings to perform.
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
A refined approach for choosing initial points for k-means clustering.
size_t & Samplings()
Modify the number of samplings that will be performed.