plotClasses#
Purpose#
Plots classes after classification.
Format#
- plotClasses(data, label[, myplot])#
- Parameters:
data (Nx2 matrix) – First column is x-axis, the second is y-axis.
label (Nx1 vector) – The corresponding label for each row.
myplot (Structure) – An instance of the
plotControl
structure used for formatting the plot.
Examples#
new;
library gml;
rndseed 234234;
/*
** Load data and prepare data
*/
fname = getGAUSSHome("pkgs/gml/examples/iris.csv");
X = loadd(fname, ". - species");
// Split data into X_train and X_test
{ X_train, X_test } = splitData(X, 0.70);
/*
** Train model
*/
// Number of clusters
n_clusters = 3;
// Declare kmeansModel struct to
// hold the results from 'kmeansFit'
struct kmeansModel mdl;
// Fit kmeans model to training set
mdl = kmeansFit(X_train , n_clusters);
/*
** Test model
*/
test_clusters = kmeansPredict(mdl, X_test);
/*
** Plot Classes
*/
plotClasses(X_test[., 1:2], test_clusters);
See also
Functions plotScatter()