kmodes_fit
Returns a structure with all required k-modes fitted model parameters. These parameters are used for prediction.
Attention: Available only with Twin Activate commercial edition.
Syntax
model = kmodes_fit(data)
model = kmodes_fit(data,options)
Inputs
- data
- The dataset on which to perform k-modes clustering.
- options
- Type: struct
- init
- The method to use when choosing the initial centroids.
- n_clusters (default: 3)
- Type: integer
- dissim
- The dissimilarity function to be used when calculating and selecting the centroids.
- maxiter (default: 100)
- Type: integer
- remove_header (default: true or 1)
- Type: Boolean
Outputs
- model
- Type: struct
Example
Usage of kmodes_fit without options:
data = [1 0 1 2; 1 1 1 2; 1 1 2 0; 0 0 0 0; 0 0 1 2];
model = kmodes_fit(data)
model = struct [
assignments: [Matrix] 5 x 1
1
1
2
3
1
centroids: [Matrix] 3 x 4
1 1 2 0
1 0 1 2
0 0 0 0
dissim: simple
]
Usage of kmodes_fit with options:
data = [1 2; 1 1; 2 2];
options = struct;
options.init = 'huang';
options.n_clusters = 2;
options.dissim = 'ng';
options.remove_header = 1;
model = kmodes_fit(data,options)
>model = struct [
assignments: [Matrix] 2 x 1
1
2
centroids: [Matrix] 2 x 2
1 1
2 2
dissim: ng
]