Agglomerative clustering. It is an unsupervised learning algorithm. It recursively merges the pair of clusters that minimally increase a given linkage distance.
Attention: Available only with Twin Activate commercial edition.
Syntax
parameters = agglomerativefit(X)
parameters = agglomerativefit(X,options)
Inputs
- X
- Training data.
- Type: double
- Dimension: vector | matrix
- options
- Type: struct
-
- n_clusters
- Number of clusters to find (default: 2).
- Type: integer
- Dimension: scalar
- affinity
- Metric used to compute the linkage. Allowed values are 'euclidean' (default), 'l1', 'l2', 'manhattan', 'cosine'. If linkage is 'ward', only 'euclidean' is accepted.
- Type: char
- Dimension: string
- linkage
- Linkage criterion to use. This determines which distance to use between set of observations. The algorithm will merge the pairs of cluster that minimize this criterion. Allowed values are 'ward', 'complete', 'average', 'single'.
- 'ward' minimizes the variance of cluster being merged (default).
- 'average' uses the average of the distances of each observation of the two sets.
- 'complete' uses the maximum distances between all observation of the two sets.
- 'single' uses the minimum of the distances between all observations of the two sets.
- Type: char
- Dimension: string
Outputs
- parameters
- Contains all the values passed to agglomerativefit method as options. Additionally it has below key-value pairs.
- Type: struct
-
- labels
- Cluster labels of each point.
- Type: double
- Dimension: vector
- n_leaves
- Number of leaves in hierarchical tree.
- Type: integer
- Dimension: scalar
- n_samples
- Number of rows in the training data.
- Type: integer
- Dimension: scalar
- n_features
- Number of columns in the training data.
- Type: integer
- Dimension: scalar
Example
Usage of agglomerativefit with options
rand('seed', 2);
XTrain = rand(14, 5);
XTest = rand(2, 5);
options = struct;
options.n_clusters = 2;
parameters = agglomerativefit(XTrain, options);
> parameters
parameters = struct [
affinity: euclidean
labels: [Matrix] 1 x 14
0 1 1 0 1 0 0 0 1 0 0 1 0 0
leaves: 14
linkage: ward
n_clusters: 2
n_features: 5
n_samples: 14
]
Comments
Output 'parameters' should be passed as input to agglomerativepredict function.