Orange Forum • View topic - MDS input matrix type error

MDS input matrix type error

A place to ask questions about methods in Orange and how they are used and other general support.

MDS input matrix type error

Postby fimz » Sun Nov 11, 2012 23:55

Hi,

I have a symmetric matrix created using numpy for my project and I would like to use the MDS package provided by orange to visualize the matrix. Unfortunately the MDS function provided does not accept numpy arrays and im getting this error:
Code: Select all
>>> mds=orngMDS.MDS(distance_matrix)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/Orange/utils/__init__.py", line 199, in wrap_call
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Orange/projection/mds.py", line 234, in __init__
    self.mds=orangemds.MDS(distances, dim, **kwargs)
TypeError: must be (unspecified), not numpy.ndarray


I then tried it as a list of list but that didnt work either:

Code: Select all
>>> mds=orngMDS.MDS(distance_matrix.tolist())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/Orange/utils/__init__.py", line 199, in wrap_call
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Orange/projection/mds.py", line 234, in __init__
    self.mds=orangemds.MDS(distances, dim, **kwargs)
TypeError: must be (unspecified), not list


Can you please help me understand the format orange uses as input for the MDS method. Also please suggest a way to convert a numpy array/matrix to a format that will speak with the MDS method.

p.s. I tried the example you provided below and it works fine:
http://orange.biolab.si/doc/modules/orngMDS.htm
Using this example the type of matrix is this:
Code: Select all
>>> type(matrix)
<type 'Orange.core.SymMatrix'>


Thanks,
-Fahim

Re: MDS input matrix type error

Postby Ales » Mon Nov 12, 2012 10:19

Try
Code: Select all
import Orange
symm = Orange.core.SymMatrix(distance_matrix)


Return to Questions & Support