Good day. I have a matrix of distances between n elements on a straight line, the dimension of the matrix nxn, for example pair_distances:

pair_distances [[ 0. 3. 6. 1.] [ 3. 0. 5. 2.] [ 6. 5. 0. 5.] [ 1. 2. 5. 0.]] 

It is necessary to restore the order in which the elements are located on a straight line. For example, for a given matrix [e1, e4, e2, e3], the elements are numbered in order as in the matrix. The data is not 100% accurate, so many standard algorithms did not work. They suggested the idea to reduce the dimension of the array using PCA.

I tried to do it on the table below.

 import sklearn from sklearn import decomposition from sklearn.decomposition import PCA pca = PCA(n_components=1) PCAreduced = pca.fit_transform(pair_distances) print 'Sklearn reduced: \n', PCAreduced 

That's what I got:

 Sklearn reduced: [[-2.91964806] [-1.12020198] [ 6.57986373] [-2.54001369]] 

I do not quite understand how this can be correlated with the order, or for which element is its pairwise distances displayed here? Is it possible to work with this?

  • it is not entirely clear what you want to get ... You had points for which you calculated the distance matrix (it is not clear for what purpose). Нужно восстановить порядок, в котором элементы располагаются на прямой - can you re-prepopulate so that it is clearer? Maybe we should start from the beginning: we have an array of coordinates (example in question), we need to get this and that (example in question) ... - MaxU
  • 2
    @MaxU, the distance matrix is ​​needed precisely to restore the order of the elements on the line. let's say we have the x axis, the first is the element a, then f, k, j. The distances between them are respectively 2,1, 5. Let the distances be additive, it is possible to reconstruct the matrix of pairwise distances between all the elements. I have an inverse problem - by the matrix to understand which element is located on the axis. But the matrix in life is actually only an approximate one, therefore, the additivity of distances can also be calculated only approximately. Greedy algorithms do not work, so they offered to do it with the PCA. - lizaveta
  • hmmm, interesting problem ... and what result do you expect for the proposed matrix? Can you specify it in the question ? - MaxU
  • one
    PCAreduced order for example the correct shows. It remains only to make argsort. - jfs

0