source: orange/docs/reference/rst/code/mds-euclid-torgerson-3d.py @ 9823:7f9c3f3c6474

Revision 9823:7f9c3f3c6474, 692 bytes checked in by lanumek, 2 years ago (diff)

Changed names of data sets (table replaced with data or name of the data set).

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.instances.EuclideanConstructor(iris)
14matrix = Orange.core.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.