/
MDS_softdes.m
27 lines (16 loc) · 1.52 KB
/
MDS_softdes.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
%Matrix taken from python program that downloads books, counts words,
%determines frequencies and then calcualtes the cosine similaries between
%4 different books:
clear all
clf
%'Plato.txt','Dar_voy.txt','PP_Aust.txt','hard_times.txt
books = {'Plato: The Republic','Darwin: The Voyage of the Beagle','Austen: Pride and Prejudice','Dickens: Hard Times','Grimm Fairy Tales','Dickens: Oliver Twist'}
%compare_matrix = [[1, 0.9490761416486647, 0.8644015286201565, 0.8831618161235175]; [0.9490761416486647, 1, 0.8338717250165556, 0.8664739869593135]; [0.8644015286201565, 0.8338717250165556, 1, 0.9626270210277179]; [0.8831618161235175, 0.8664739869593135, 0.9626270210277179, 1]]
compare_matrix = [[1.0, 0.9490761416486647, 0.8644015286201565, 0.8831618161235175, 0.87044905598553, 0.9172230624970704]; [0.9490761416486647, 1.0, 0.8338717250165556, 0.8664739869593135, 0.845935624140629, 0.9231703157558973]; [0.8644015286201565, 0.8338717250165556, 1.0, 0.9626270210277179, 0.870049401005955, 0.9059837944444138]; [0.8831618161235175, 0.8664739869593135, 0.9626270210277179, 1.0, 0.9128470650595878, 0.9522226944497051]; [0.87044905598553, 0.845935624140629, 0.870049401005955, 0.9128470650595878, 1.0, 0.9471539229040072]; [0.9172230624970704, 0.9231703157558973, 0.9059837944444138, 0.9522226944497051, 0.9471539229040072, 1.0]]
%finding disimilarities by subtracting similarities from 1
D = 1-compare_matrix
[Y,eigvals] = cmdscale(D);
plot(Y(:,1),Y(:,2),'.')
for i = 1:6
text(Y(i,1)+.01,Y(i,2),books(i))
end