# source:orange/orange/doc/modules/mds2.py@6538:a5f65d7f0b2c

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

Made XPM version of the icon 32x32.

Line
1# Description: Uses MDS on iris data set and plots the scatterplot to illustrate the effect and observe the degree of separation between groups of different classes
2# Category:    association
3# Classes:     orngMDS.MDS
4# Uses:        iris.tab
5# Referenced:  orngMDS.htm
6
7import orange
8import orngMDS
9
10data=orange.ExampleTable("../datasets/iris.tab")
11euclidean = orange.ExamplesDistanceConstructor_Euclidean(data)
12distance = orange.SymMatrix(len(data))
13for i in range(len(data)-1):
14   for j in range(i+1, len(data)):
15       distance[i, j] = euclidean(data[i], data[j])
16
17mds=orngMDS.MDS(distance)
18mds.run(100)
19
20try:
21   from pylab import *
22   colors = ["red", "yellow", "blue"]
23
24   points = []
25   for (i,d) in enumerate(data):
26      points.append((mds.points[i][0], mds.points[i][1], d.getclass()))
27   for c in range(len(data.domain.classVar.values)):
28       sel = filter(lambda x: x[-1]==c, points)
29       x = [s[0] for s in sel]
30       y = [s[1] for s in sel]
31       scatter(x, y, c=colors[c])
32   savefig('mds-iris.png', dpi=72)
33   show()
34except ImportError:
35    print "Can't import pylab (matplotlib)"
Note: See TracBrowser for help on using the repository browser.