KModesT Class |
Namespace: Accord.MachineLearning
[SerializableAttribute] public class KModes<T> : ParallelLearningBase, IUnsupervisedLearning<KModesClusterCollection<T>, T[], int>, IClusteringAlgorithm<T[]>, IUnsupervisedLearning<IClusterCollection<T[]>, T[], int>
The KModesT type exposes the following members.
Name | Description | |
---|---|---|
KModesT(Int32, IDistanceT) |
Initializes a new instance of KModes algorithm
| |
KModesT(Int32, FuncT, T, Double) | Obsolete.
Initializes a new instance of KModes algorithm
|
Name | Description | |
---|---|---|
Clusters |
Gets the clusters found by K-modes.
| |
ComputeError |
Gets or sets whether the clustering distortion error (the
average distance between all data points and the cluster
centroids) should be computed at the end of the algorithm.
The result will be stored in Error. Default is true.
| |
Dimension |
Gets the dimensionality of the data space.
| |
Distance |
Gets or sets the distance function used
as a distance metric between data points.
| |
Error |
Gets the cluster distortion error (the average distance
between data points and the cluster centroids) after the
last call to this class' Compute methods.
| |
Initialization |
Gets or sets the strategy used to initialize the
centroids of the clustering algorithm. Default is
KMeansPlusPlus.
| |
Iterations |
Gets the number of iterations performed in the
last call to this class' Compute methods.
| |
K |
Gets the number of clusters.
| |
MaxIterations |
Gets or sets the maximum number of iterations to
be performed by the method. If set to zero, no
iteration limit will be imposed. Default is 0.
| |
ParallelOptions |
Gets or sets the parallelization options for this algorithm.
(Inherited from ParallelLearningBase.) | |
Token |
Gets or sets a cancellation token that can be used
to cancel the algorithm while it is running.
(Inherited from ParallelLearningBase.) | |
Tolerance |
Gets or sets the relative convergence threshold
for stopping the algorithm. Default is 1e-5.
|
Name | Description | |
---|---|---|
Compute | Obsolete.
Divides the input data into K clusters.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Learn |
Learns a model that can map the given inputs to the desired outputs.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
Accord.Math.Random.Generator.Seed = 0; // Declare some observations byte[][] observations = new[] { new byte[] { 0, 0 }, // a new byte[] { 0, 1 }, // a new byte[] { 0, 1 }, // a new byte[] { 1, 1 }, // a new byte[] { 5, 3 }, // b new byte[] { 6, 8 }, // b new byte[] { 6, 8 }, // b new byte[] { 6, 7 }, // b new byte[] { 5, 8 }, // b new byte[] { 12, 14 }, // c new byte[] { 12, 14 }, // c new byte[] { 13, 14 }, // c }; // Create a new 3-Modes algorithm using the Hamming distance var kmodes = new KModes<byte>(k: 3, distance: new Hamming()) { MaxIterations = 100 }; // Compute and retrieve the data centroids var clusters = kmodes.Learn(observations); // Use the centroids to parition all the data int[] labels = clusters.Decide(observations);