Skip to content
Evgeny Mirkes edited this page Apr 24, 2019 · 39 revisions

Welcome to the Elastic Map wiki!

This wiki contains several pages: Technical and mathematical description of package is presented in
Elastic maps / Elastic maps.docx

Examples of package usage are presented in the three auxiliary pages / documents

Additional information for data imputation is presented in Data Imputation repository.

This document shows several examples of Elastic Maps colouring. Word vwrsion of this document can be found here

There are several files with elastic map demo. All these files are located in the “tests” folder of repository. This document contains several examples of Elastic maps usage.

Map creation and 3D visualisation

You can find code in the file ExternalMapColouringTest.m in tests folder.

The first fragment is common for three map colouring tests. This fragment simple creats and fits map.

Creation map for demo.

% Colours to draw are defined now
colours = ['b'; 'g'];

% Download database
load('breastCancer.mat');

if size(d1n, 1) > 286
    %We need to transpose matrix
    d1n = d1n';
end

% Create map wit 30 rows and 30 columns and initialise along Principal
% components
map = rect2DMap(30, 30);
init(map, d1n, 'pci');

% Map fitting for standard parameters
EM(map, d1n, 'stretch', 0, 'bend', 0.1);

The first map simply presents distribution of data points in the space of the first three principal components. It is not necessary to train map for this. Formed figure ca be rotated by standard Matlab tool (see, for example the right figure below).

Two pairs provide possibility to colour points of different classes by different colours: Pair 'classes', col defines classes of points; Pair 'markColour', colours defines colours to use. User also can select different shapes for markers by 'markShape' and size of marker for different classes by 'markSize'. Pair 'lineWidth', 0 suppress drawing of map.

% Draw the firs map to see distribution (map hidden by 'lineWidth', 0)
drawMap(map, d1n, 'classes', col, 'markColour', colours, 'lineWidth', 0);
saveFigures('figures/Distribution.png');

The next fragment visualises 3D maps with reduced (left) and non reduced (right) color map

% Draw the density by density function
drawMap(map, d1n, 'projType', 2, 'nodeMarker', 'none', 'lineWidth', 0.5,...
            'classes', col, 'markColour', colours, ...
            'coloring', 'density', 'ColorMap', parula(7));
saveFigures('figures/flatDensity3D.png');
drawMap(map, d1n, 'projType', 2, 'nodeMarker', 'none', 'lineWidth', 0.5,...
            'classes', col, 'markColour', colours, ...
            'coloring', 'density', 'ColorMap', parula);
saveFigures('figures/flatDensity3DC.png');

These two calles used following optional arguments

  • 'coloring', 'density' means colouring map according with data density

  • 'projType', 2 means projection of data points onto nearest face. It is necessary to calculate density of points projections.

  • 'nodeMarker', 'none' means absebce of map nodes.

  • 'lineWidth', 0.5 means drawing of thin map edges.

  • 'classes', col defines belonging of data points to classes.

  • 'markColour', colours defines colours to depict points of each class.

  • 'ColorMap', parula means usage of color map parula.

  • 'ColorMap', parula(7) means usage of color map parula with 7 colours only.

As a result we have following map visualisations:

Maps with small number of colours

You can find code in the file InternalMapColouring7Test.m in tests folder. Text of example is presented below as fragments with corresponding maps.

Let us draw density map. Two function calls to do this are presented below. The first call draw flat map (left figure below) and the second draw 3D density (right figure below). These calls remove drawing of map nodes by 'nodeMarker', 'none', specified thin lines to draw map by 'lineWidth', 0.5, specified classes and colours to depict classes by 'classes', col, 'markColour', colours. Both these commands request drawing of density 'coloring', 'density' and usage of reduced colour map wit 7 colours 'ColorMap', parula(7). The difference is defined by 'flatColoring', true in the first call to draw flat map (left figure below) and with 'flatColoring', false in the second call to draw 3D map (right figure below).

% Draw the density by density function
drawMapInt(map, d1n, 2, 'nodeMarker', 'none', 'lineWidth', 0.5,...
            'classes', col, 'markColour', colours, ...
            'coloring', 'density', 'flatColoring', true,...
            'ColorMap', parula(7));
drawMapInt(map, d1n, 2, 'nodeMarker', 'none', 'lineWidth', 0.5,...
            'classes', col, 'markColour', colours, ...
            'coloring', 'density', 'flatColoring', false,...
            'ColorMap', parula(7));

We can draw arbitrary function defined in data points. Just for simplicity we used constant value 1 which is equivalent to density. First of all we form vector of ones

% Draw density by vector of ones
col1 = col;
col1(col1 > 0) = 1;

Then we use almost the same commands as before to depict map. The only difference is in argument 'coloring', col1 instead of 'coloring','density' used before. Graphs are absolutely the same as above.

drawMapInt(map, d1n, 2, 'nodeMarker', 'none', 'lineWidth', 0.5,...
            'classes', col, 'markColour', colours, ...
            'coloring', col1, 'flatColoring', true, 'ColorMap', parula(7));
drawMapInt(map, d1n, 2, 'nodeMarker', 'none', 'lineWidth', 0.5,...
            'classes', col, 'markColour', colours, ...
            'coloring', col1, 'flatColoring', false,...
            'ColorMap', parula(7));

The next example presents pseudo risk map. Let us put value 1 for one class points and -1 for the second class points.

% Draw pseudo risk map
col1 = col;
col1(col1 == 2) = -1;
col1 = -col1;

Then we use completely the same commands to depict map (with pair 'coloring', col1). For simplicity we depict risk maps in the top row and repeat density map in the bottom row. As we can see there is one difference: in the first row dark blue means high concentration of blue points but in the bottom row it means the most empty areas.

Maps with “continuous” colours

In the previous examples we used "reduced" colour map: 'ColorMap', parula(7). To use standard colour map we can simply omit fragment (7): use pair 'ColorMap', parula instead of pair 'ColorMap', parula(7). You can find code in the file InternalMapColouringTest.m in tests folder.

We consider pseudo risk maps (top row) and density maps (bottom row):

Clone this wiki locally