Class CosineClusterer

Inheritance Relationships

Base Types

Class Documentation

class cpphots::CosineClusterer : public cpphots::interfaces::Clonable<CosineClusterer, interfaces::Clusterer>, public cpphots::ClustererHistogramMixin, public cpphots::ClustererOnlineMixin

HOTS basic clusterer.

Clusters time surface according to the HOTS formulation (cosine rule).

Public Functions

CosineClusterer()

Construct a new CosineClusterer.

This constructor should never be used to create a new object, it is provided only to create containers with Clusterer instances or to read parameters from a file.

CosineClusterer(uint16_t clusters, TimeSurfaceScalarType homeostasis = 0.0)

Construct a new CosineClusterer.

The constructor will not seed the centroids.

Parameters
  • clusters – number of clusters

  • homeostasis – homeostatic regulation

virtual uint16_t cluster(const TimeSurfaceType &surface) override

Performs clustering.

In case of online clustering algorithms, also updates the clusters, if learning is enabled.

If learning is enabled, this will update the centroids.

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 &centroid) 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 bool toggleLearning(bool enable = true) override

Enable or disable learning.

This affects whether the centroids are updated when Clusterer::cluster is called or not.

During the learning phase, output of Clusterer::cluster may be undefined, depending on the implementaton.

If learning is enabled centroids will be updatad online until learning is disabled.

Parameters

enable – true if learning should be active, false otherwise

Returns

the previous learning state

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