source: orange/docs/reference/rst/code/mds-euclid-torgerson-3d.py @ 9891:66ee6522a40f

Revision 9891:66ee6522a40f, 673 bytes checked in by gregorr, 2 years ago (diff)

SymMatrix documentation (data -> misc).

Line 
1# Description: 3D MDS with Euclid distance and Torgerson initialization, without iteration
2# Category:    projection
3# Uses:        iris
4# Referenced:  Orange.projection.mds
5# Classes:     Orange.projection.mds.MDS
6
7import Orange
8
9# Load some data
10iris = Orange.data.Table("iris.tab")
11
12# Construct a distance matrix using Euclidean distance
13dist = Orange.distance.Euclidean(iris)
14matrix = Orange.misc.SymMatrix(len(iris))
15matrix.setattr('items', iris)
16for i in range(len(iris)):
17    for j in range(i + 1):
18        matrix[i, j] = dist(iris[i], iris[j])
19
20# Run the MDS
21mds = Orange.projection.mds.MDS(matrix, dim=3)
22mds.Torgerson()
23
24# Print a few points
25print mds.points[:3]
Note: See TracBrowser for help on using the repository browser.