Clusters defined by centroids. More...
#include <shark/Models/Clustering/Centroids.h>
 Inheritance diagram for shark::Centroids:
 Inheritance diagram for shark::Centroids:| Public Member Functions | |
| SHARK_EXPORT_SYMBOL | Centroids () | 
| Default constructor. | |
| SHARK_EXPORT_SYMBOL | Centroids (std::size_t centroids, std::size_t dimension) | 
| SHARK_EXPORT_SYMBOL | Centroids (Data< RealVector > const ¢roids) | 
| std::string | name () const | 
| From INameable: return the class name. | |
| SHARK_EXPORT_SYMBOL RealVector | parameterVector () const | 
| from IParameterizable | |
| SHARK_EXPORT_SYMBOL void | setParameterVector (RealVector const &newParameters) | 
| from IParameterizable | |
| SHARK_EXPORT_SYMBOL std::size_t | numberOfParameters () const | 
| from IParameterizable | |
| Shape | inputShape () const | 
| return the dimension of the inputs | |
| SHARK_EXPORT_SYMBOL std::size_t | numberOfClusters () const | 
| return the number of centroids in the model | |
| Data< RealVector > const & | centroids () const | 
| read access to the centroid vectors | |
| void | setCentroids (Data< RealVector > const &newCentroids) | 
| overwrite the centroid vectors | |
| SHARK_EXPORT_SYMBOL void | read (InArchive &archive) | 
| from ISerializable | |
| SHARK_EXPORT_SYMBOL void | write (OutArchive &archive) const | 
| from ISerializable | |
| SHARK_EXPORT_SYMBOL RealVector | softMembership (RealVector const &pattern) const | 
| from AbstractClustering: Compute cluster memberships. | |
| SHARK_EXPORT_SYMBOL RealMatrix | softMembership (BatchInputType const &patterns) const | 
| From AbstractClustering: Compute cluster memberships for a batch of patterns. | |
| SHARK_EXPORT_SYMBOL RealMatrix | distances (BatchInputType const &patterns) const | 
| Computes the distances of each pattern to all cluster centers. | |
| SHARK_EXPORT_SYMBOL void | initFromData (ClassificationDataset const &data, std::size_t noClusters=0, std::size_t noClasses=0) | 
| SHARK_EXPORT_SYMBOL void | initFromData (Data< RealVector > const &dataset, std::size_t noClusters) | 
|  Public Member Functions inherited from shark::AbstractClustering< RealVector > | |
| const Features & | features () const | 
| virtual void | updateFeatures () | 
| bool | hasSoftMembershipFunction () const | 
| virtual unsigned int | hardMembership (InputType const &pattern) const | 
| Compute best matching cluster. | |
| virtual BatchOutputType | hardMembership (BatchInputType const &patterns) const | 
| Compute best matching cluster for a batch of inputs. | |
|  Public Member Functions inherited from shark::INameable | |
| virtual | ~INameable () | 
|  Public Member Functions inherited from shark::IParameterizable< VectorType > | |
| virtual | ~IParameterizable () | 
|  Public Member Functions inherited from shark::ISerializable | |
| virtual | ~ISerializable () | 
| Virtual d'tor. | |
| void | load (InArchive &archive, unsigned int version) | 
| Versioned loading of components, calls read(...). | |
| void | save (OutArchive &archive, unsigned int version) const | 
| Versioned storing of components, calls write(...). | |
| BOOST_SERIALIZATION_SPLIT_MEMBER () | |
| Protected Member Functions | |
| virtual SHARK_EXPORT_SYMBOL double | membershipKernel (double dist) const | 
| Protected Attributes | |
| Data< RealVector > | m_centroids | 
| centroid vectors | |
|  Protected Attributes inherited from shark::AbstractClustering< RealVector > | |
| Features | m_features | 
| Additional Inherited Members | |
|  Public Types inherited from shark::AbstractClustering< RealVector > | |
| enum | Feature | 
| typedef RealVector | InputType | 
| typedef unsigned int | OutputType | 
| typedef Batch< InputType >::type | BatchInputType | 
| typedef Batch< OutputType >::type | BatchOutputType | 
| typedef TypedFlags< Feature > | Features | 
| typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException | 
|  Public Types inherited from shark::IParameterizable< VectorType > | |
| typedef VectorType | ParameterVectorType | 
Clusters defined by centroids.
Definition at line 59 of file Centroids.h.
| SHARK_EXPORT_SYMBOL shark::Centroids::Centroids | ( | ) | 
Default constructor.
| SHARK_EXPORT_SYMBOL shark::Centroids::Centroids | ( | std::size_t | centroids, | 
| std::size_t | dimension | ||
| ) | 
Constructor
| centroids | number of centroids in the model (initially zero) | 
| dimension | dimension of the input space, and thus of the centroids | 
| SHARK_EXPORT_SYMBOL shark::Centroids::Centroids | ( | Data< RealVector > const & | centroids | ) | 
Constructor
| centroids | centroid vectors | 
| 
 | inline | 
read access to the centroid vectors
Definition at line 100 of file Centroids.h.
References m_centroids.
Referenced by main().
| SHARK_EXPORT_SYMBOL RealMatrix shark::Centroids::distances | ( | BatchInputType const & | patterns | ) | const | 
Computes the distances of each pattern to all cluster centers.
| SHARK_EXPORT_SYMBOL void shark::Centroids::initFromData | ( | ClassificationDataset const & | data, | 
| std::size_t | noClusters = 0, | ||
| std::size_t | noClasses = 0 | ||
| ) | 
initialize centroids from labeled data: take the first data points with different labels; if there are more centroids than classes, the remaining centroids are filled with the first elements in the data set
| data | dataset from which to take the centroids | 
| noClusters | number of centroids in the model, default 0 is mapped to the number of classes in the data set | 
| noClasses | number of clases in the dataset, default 0 means that the number is computed | 
| SHARK_EXPORT_SYMBOL void shark::Centroids::initFromData | ( | Data< RealVector > const & | dataset, | 
| std::size_t | noClusters | ||
| ) | 
initialize centroids from unlabeled data: take a random subset of data points
| dataset | dataset from which to take the centroids | 
| noClusters | number of centroids in the model | 
| 
 | inlinevirtual | 
return the dimension of the inputs
Implements shark::AbstractClustering< RealVector >.
Definition at line 92 of file Centroids.h.
References shark::dataDimension(), and m_centroids.
| 
 | protectedvirtual | 
Compute unnormalized membership from distance. The default implementation is to return exp(-distance)
| 
 | inlinevirtual | 
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 79 of file Centroids.h.
| 
 | virtual | 
return the number of centroids in the model
Implements shark::AbstractClustering< RealVector >.
| 
 | virtual | 
from IParameterizable
Reimplemented from shark::IParameterizable< VectorType >.
| 
 | virtual | 
from IParameterizable
Reimplemented from shark::IParameterizable< VectorType >.
| 
 | virtual | 
from ISerializable
Reimplemented from shark::AbstractClustering< RealVector >.
| 
 | inline | 
| 
 | virtual | 
from IParameterizable
Reimplemented from shark::IParameterizable< VectorType >.
| 
 | virtual | 
From AbstractClustering: Compute cluster memberships for a batch of patterns.
Reimplemented from shark::AbstractClustering< RealVector >.
| 
 | virtual | 
from AbstractClustering: Compute cluster memberships.
Reimplemented from shark::AbstractClustering< RealVector >.
| 
 | virtual | 
from ISerializable
Reimplemented from shark::AbstractClustering< RealVector >.
| 
 | protected | 
centroid vectors
Definition at line 147 of file Centroids.h.
Referenced by centroids(), inputShape(), and setCentroids().