source: orange/orange/doc/modules/mds1.py @ 6538:a5f65d7f0b2c

Revision 6538:a5f65d7f0b2c, 812 bytes checked in by Mitar <Mitar@…>, 4 years ago (diff)

Made XPM version of the icon 32x32.

Line 
1# Description: Example of advanced use of MDS
2# Category:    association
3# Classes:     orngMDS.MDS
4# Referenced:  orngMDS.htm
5# Uses:        iris.tab
6
7import orange, orngMDS, math
8
9data=orange.ExampleTable("../datasets/iris.tab")
10dist = orange.ExamplesDistanceConstructor_Euclidean(data)
11matrix = orange.SymMatrix(len(data))
12for i in range(len(data)-1):
13   for j in range(i+1, len(data)):
14       matrix[i, j] = dist(data[i], data[j])
15
16mds=orngMDS.MDS(matrix)
17#mds.Torgerson()
18mds.getStress(orngMDS.KruskalStress)
19
20i=0
21while 100>i:
22    i+=1
23    oldStress=mds.avgStress
24    for j in range(10): mds.SMACOFstep()
25    mds.getStress(orngMDS.KruskalStress)
26    if oldStress*1e-3 > math.fabs(oldStress-mds.avgStress):
27        break;
28for (p, e) in zip(mds.points, data):
29    print "<%4.2f, %4.2f> %s" % (p[0], p[1], e)
Note: See TracBrowser for help on using the repository browser.