kmodes_predict

Returns a list of all predicted clusters for the dataset and model parameters provided.

Syntax

pred = kmodes_predict(data,model)

Inputs

data
The dataset on which to perform k-modes prediction.
Type: double
Dimension: matrix
model
Type: struct
Model parameters in the following format:
centroids
The list of centroids.
assignments (default: 3)
The list of all cluster assignments for each data points in the dataset.
dissim (default: 'simple')
The dissimilarity function used.

Outputs

pred
The predicted cluster number of each data point.
Type: integer
Dimension: matrix

Example

Usage of kmodes_predict:


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);
pred = kmodes_predict(data, model)
pred = [Matrix] 5 x 1
2
2
1
3
2

Comments

The data set should not contain string categorical variables. If it does, you should convert or enumerate them before passing them into the function.