source: orange/Orange/testing/regression/tests_20/modules_mds1.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 812 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

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.