Skip to content

Iris example, visualizing several classes of data

Andrei Zinovyev edited this page Nov 4, 2017 · 11 revisions

In this example, we show how to visualize distribution of data point class labels on top of the metro map layout of the principal tree.

First, load the data from a tab-delimited table, convert numerical data to z-scores

iristable = importdata('test_data\iris\iris.txt'); 
iris = iristable.data;
irisz = zscore(iris);
pointlabels = (iristable.textdata(2:end,1))';

Construct an elastic principal tree with 20 nodes (it is slightly more that 17 which seems to be optimal from the Complexity/Accuracy plot).

[NodePositions,Edges] = computeElasticPrincipalGraph(irisz,20);

Now recompute the metro map layout and draw the graph together with pie-charts showing distribution of data point class labels. Note that the labeling should be a row-vector of strings.

NodesMM = computeMetroMapLayout(NodePositions,Edges);
close all; 
drawGraph2D(NodesMM,Edges,'ShowClusterNumbers',0); 
lcm = drawPieChartsMetroMap(NodePositions,Edges,irisz,pointlabels,NodesMM);

The coloring of classes in this plot is pre-defined. Let us assign some colors to the classes of points:

lcm('Iris-setosa') = [1 1 0]; % Setosa will be yellow
lcm('Iris-versicolor') = [0 1 1]; % Versicolor will be light blue
lcm('Iris-virginica') = [1 0 1]; % Virginica will be purple
close all; 
drawGraph2D(NodesMM,Edges,'ShowClusterNumbers',0); 
drawPieChartsMetroMap(NodePositions,Edges,irisz,pointlabels,NodesMM,'LabelColorMap',lcm);