The orngMDS module provides the functionality to perform multi dimensional scaling
Attributes
LSMT
changes these)points
stress
run()
methodMethods
dim
indicating the dimension of the projected space and an initial configuration of points
points
and updates the projectedDistances
matrixprojectedDistances
and distances
matrix using stressFunc
and updates the stress
matrix and avgStress
accordinglypoints
numIter
iteration of SMACOFstep function, or the stress improvement ratio is smaller then eps
(oldStress-newStress smaller then oldStress*eps)In our first example, we will take iris data set, compute the distance between the examples and then run MDS on a distance matrix. This is done by the following code:
part of mds2.py (uses iris.tab)
Notice that we are running MDS through 100 iterations. We will now use matplotlib to plot the data points using the coordinates computed with MDS (you need to install matplotlib, it does not come with Orange). Each data point in iris is classified in one of the three classes, so we will use colors to denote instance's class.
part of mds2.py (uses iris.tab)
Executing the above script pops-up a pylab window with the following scatterplot:
Iris is a relatively simple data set with respect to classification, and to no surprise we see that MDS found such instance placement in 2-D where instances of different class are well separated. Notice also that MDS does this with no knowledge on the instance class.
We are going to write a script that is similar to the functionality of the orngMDS.run method, but performs 10 steps of Smacof optimization before computing the stress. This is suitable if you have a large dataset and want to save some time. First we load the data and compute the distance matrix (just like in our previous example).
Then we construct the MDS instance and perform the initial torgerson approximation, after which we update the stress matrix using the orngMDS.KruskalStress function.
And finally the main optimization loop, after which we print the projected points along with the data
StressFunction
computes the stress between two points
Methods
distances
and projectedDistances
elements)The orngMDS module provides 4 stress functions