Skip to content

newresu/fit-mds

Repository files navigation

mds

NPM version build status Test coverage npm download

Classic Multidimensional Scaling aka Principal Coordinate Analysis (PCoA).

Get the Senate vote-patterns down to a nice 2D plot.

Installation

$ npm i fit-mds

Usage

import { MultidimensionalScaling as MDS } from 'fit-mds';

const result = new MDS(data, dimension, options);

// some methods and properties
const d = result.dimension; // dimension of the output space
const error = result.strain(); // stress of the solution
const up = result.scaleUp(n); // `n` either number or array !
const down = result.scaleDown(n); // same

Basic API Description

  • data is an array of arrays. There are two cases:

    • Pass the distances between pair of points. In this case we are passing a dissimilarity/distance matrix. Which is the default.
    • Pass the raw data. It needs the option calculateDissimilarity:true.
  • dimension is the dimension of the output space. It may be less depending on the EigenValues, you can inspect it using result.dimensions.

  • options is an object currently only with the option calculateDissimilarity which is false by default, as described previously.

Idea of Multidimensional Scaling

Given a distance matrix with the distances between each pair of objects in a set, and a chosen number of dimensions, N, an MDS algorithm places each object into N-dimensional space (a lower-dimensional representation) such that the between-object distances are preserved as well as possible. For N = 1, 2, and 3, the resulting points can be visualized on a scatter plot.

Source: Wikipedia - MDS

Source: Towards Data Science - MDS

License

MIT

About

Multidimensional Scaling

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published