In pattern recognition, we take into account the problem of distance distance, which is the distance between a sample and another sample in space. The classification is judged by the size of the distance. So, there is the same kind of problem: we only know the distance of the point (sample) in space, then how to reconstruct the relative position of these points?
Obviously the European distance is the most intuitive distance, then we would like to use Euclidean distance for computational reconstruction, we also want to be able to refactor in different dimensions, such as 2-D or 3-dimensional.
What do you do?
There is a solution called MDS called Multidimensional Scaling.
The following step by step describes how MDS solves this problem.
Step 1: Restatement of the problem
We have such a distance matrix that we calculate the relative position matrix X of the point by this matrix, so that the distance matrix by X in turn is the least difference from the original distance matrix D. So this is an optimization problem.
You can look at the problem description on Wikipedia, which is just right here:
Step 2: Solving by matrix method
We also see that the wiki finally says that solution with eigendecompositions is the eigenvalue decomposition.
Here is a detailed explanation of how it is done.
Turn 4 mds ppt (from your own class teacher's ppt):
Explaining it is actually very simple:
1) constructs a matrix T, and then finds that the T matrix can be calculated entirely from D.
2) t this matrix can be decomposed ah, then the inside eigenvalue if greater than or equal to 0, you can open the square root.
Look at this formula:
U is a eigenvectors, the middle one is a matrix of eigenvalues.
In this way, X can be reconstructed from several selected eigenvalues and eigenvectors (which is also a way of reducing dimensions).
Step 3: Specific MATLAB implementation
The example of a direct turn to class is to know the relative distances of several cities in Britain and reconstruct their relative positions.
Matlab code:
Clc;clear all;close all;%distance Matrix For:london, Cardiff, Birmingham, Manchester, York, and%glasgow.d=[ 0,411,213,219,296,397, ..... 411,0,204,203,120,152, ..... 213,204,0,73,136,245, ..... 219,203,73,0,90,191, ..... 296,120,136,90,0,109, ..... 397,152,245,191,109,0];n=size (d,1); T=zeros (n,n); for i=1:n for j=1:n T (i,j) =-0.5* (d (i,j) ^2-1/n*d (i,:) *d (i ,:) ' -1/n*d (:, J) ' *d (:, j) +1/n^2*sum (sum (d.^2))); Endend[v,d] = Eig (t) x=v (:, 1:2) *d (1:2,1:2). ^ (); Scatter (-X (:, 2), X (:, 1)); axis ([ -300,300,-300,300]);
The results from Matlab:
Ok,mds That's it!
The analysis of MDS multidimensional scaling multidimensional scale method and MATLAB realization in pattern recognition