Class KMeansClusterer
Defined in File kmeans.h
Inheritance Relationships
Base Types
public cpphots::interfaces::Clonable< KMeansClusterer, interfaces::Clusterer >(Template Struct Clonable)public cpphots::ClustererHistogramMixin(Class ClustererHistogramMixin)public cpphots::ClustererOfflineMixin(Class ClustererOfflineMixin)
Class Documentation
-
class cpphots::KMeansClusterer : public cpphots::interfaces::Clonable<KMeansClusterer, interfaces::Clusterer>, public cpphots::ClustererHistogramMixin, public cpphots::ClustererOfflineMixin
Public Functions
-
KMeansClusterer()
-
KMeansClusterer(uint16_t clusters, uint16_t max_iterations = 1000)
-
virtual uint16_t cluster(const TimeSurfaceType &surface) override
Performs clustering.
In case of online clustering algorithms, also updates the clusters, if learning is enabled.
- Parameters
surface – the timesurface to cluster
- Returns
id of the cluster
-
virtual uint16_t getNumClusters() const override
Get the number of clusters.
- Returns
the number of clusters
-
virtual void addCentroid(const TimeSurfaceType ¢roid) override
Add a new centroid to the clusterer.
This function should not be used manually, seeding should be done via a ClustererSeeding function.
If the Clusterer already has enough centroids, an exception is raised.
- Parameters
centroid – the centroid to add
-
virtual const std::vector<TimeSurfaceType> &getCentroids() const override
Get the list of centroids.
- Returns
the list of centroids
-
virtual void clearCentroids() override
Remove all centroids.
-
virtual bool hasCentroids() const override
Check if clusterer has enough centroids.
A clusterer has centroids if there is a number of centroids equal to the number of clusters.
- Returns
true if clusterer has centroids
- Returns
false otherwise
-
virtual void train(const std::vector<TimeSurfaceType> &tss) override
Fit a set of time surfaces.
Udpate the centroids by clustering the set of time surfaces.
- Parameters
tss – set of time surfaces
-
virtual void toStream(std::ostream &out) const override
Insert to stream.
Insert parameters of the clusterer and centroids on the stream.
- Parameters
out – stream where to insert to
-
virtual void fromStream(std::istream &in) override
Extract from stream.
Parameters/current state is expected to be overwritten or invalidated.
Reads parameters and centroids from the stream.
- Parameters
in – stream where to extract from
-
KMeansClusterer()