# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Reduce a matrix of real values to low dimension using the principal coordinates analysis method

Contributed by:
Daniel Lichtblau

ResourceFunction["MultidimensionalScaling"][ uses principal coordinates analysis to find a "best projection" of | |

ResourceFunction["MultidimensionalScaling"][ projects |

Multidimensional Scaling (MDS) is a standard method for reducing dimension of a set of numerical vectors. It is related to the "LatentSemanticAnalysis" and "PrincipalComponentsAnalysis" methods of DimensionReduce.

ResourceFunction["MultidimensionalScaling"] gives an optimal reduction according to a certain Euclidean measure.

Given a set of *n* vectors, ResourceFunction["MultidimensionalScaling"] will create a list of all pairwise distances, that is, an *n*×*n* dense matrix of real values. It is thus not recommended to use this when *n* is large.

This function computes what is known as the classical multidimensional scaling for a given set of points. Other types of multidimensional scaling exist, including one that is supported as a Method setting for the built in function DimensionReduce.

Several variants of multidimensional scaling are described in this Wikipedia article. The one implemented here is also referred to as Principal Coordinates Analysis.

Reduce the dimension of some vectors:

In[1]:= |

Out[1]= |

Create and visualize random 3D vectors:

In[2]:= |

Out[3]= |

Visualize this dataset reduced to two dimensions:

In[4]:= |

Out[4]= |

MultidimensionalScaling will reduce to any dimension that is no larger than the input dimension. Here we create data in ten dimensional space, and visualize in three dimensions:

In[5]:= |

In[6]:= |

Out[6]= |

As is done in the reference page for DimensionReduce, load the Fisher iris dataset from ExampleData:

In[7]:= |

Reduce the dimension of the features:

In[8]:= |

Group the examples by their species:

In[9]:= |

Visualize the reduced dataset:

In[10]:= |

Out[10]= |

Now show some DimensionReduce methods for this same dataset. First we use the "PrincipalComponentsAnalysis" method:

In[11]:= |

Out[12]= |

Use the "TSNE" method:

In[13]:= |

Out[14]= |

Visualize with the "LatentSemanticAnalysis" method:

In[15]:= |

Out[16]= |

The "LatentSemanticAnalysis" method can be attained directly using SingularValueDecomposition:

In[17]:= |

In[18]:= |

Out[19]= |

Illustrate multidimensional scaling on textual data using several popular literature texts from ExampleData:

Break each text into chunks of equal string length:

Find the most common words across all texts:

Create common word frequency vectors for each chunk:

Weight the frequency vectors using the log-entropy method:

Show the result of multidimensional scaling in two dimensions, grouping text chunks by position of title in the list of text names:

In[20]:= |

Out[22]= |

- Mathematica Journal: Graphical Representation of Proximity Measures for Multidimensional Data
- MultidimensionalScaling

This work is licensed under a Creative Commons Attribution 4.0 International License