đa chiều (MDS) nhằm mục đích dự án ma trận khoảng cách của dữ liệu của bạn vào một chiều hướng thấp hơn k, nơi mong muốn k = 2 trong trường hợp của bạn, trong khi cố gắng để duy trì khoảng cách giữa các điểm dữ liệu:
# Multidimensional scaling
library(MASS)
set.seed(1)
labels <- as.factor(sample(LETTERS[1:5], 100, replace=TRUE))
dat <- mvrnorm(n=100, mu = c(1:4), Sigma=matrix(1:16, ncol=4)) + as.numeric(labels)^2
#> dim(dat)
#[1] 100 4
# Euclidean distance matrix (100x100)
d <- dist(dat)
# Classical MDS for distance matrix d
# http://en.wikipedia.org/wiki/Multidimensional_scaling
mds <- cmdscale(d, k = 2)
x <- mds[,1]
y <- mds[,2]
plot(x,y, col=rainbow(5)[as.numeric(labels)], pch=16, main="MDS for object 'dat'")
legend("topright", legend=unique(labels), col=rainbow(5)[unique(as.numeric(labels))], pch=16)
đọc thêm: https://stats.stackexchange.com/questions/14002/whats-the-difference-between-principal-components-analysis-and-multidimensional
Nguồn
2013-06-24 11:07:15
không có một giải pháp duy nhất cho vấn đề này kể từ khi bạn có thể xoay tập dữ liệu của bạn mà không ảnh hưởng đến ma trận khoảng cách. – Backlin