source: orange/docs/reference/rst/code/mds-euclid-torgerson-3d.py @ 9372:aef193695ea9

Revision 9372:aef193695ea9, 699 bytes checked in by mitar, 2 years ago (diff)

Moved documentation to the separate directory.

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
10table = Orange.data.Table("iris.tab")
11
12# Construct a distance matrix using Euclidean distance
13dist = Orange.distance.instances.EuclideanConstructor(table)
14matrix = Orange.core.SymMatrix(len(table))
15matrix.setattr('items', table)
16for i in range(len(table)):
17    for j in range(i+1):
18        matrix[i, j] = dist(table[i], table[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.