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?
Нужно восстановить порядок, в котором элементы располагаются на прямой- 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