luispedro / milk

MILK: Machine Learning Toolkit
http://www.luispedro.org/software/milk
MIT License
605 stars 146 forks source link

RuntimeError when running SOM #22

Open vickyliau opened 9 years ago

vickyliau commented 9 years ago

Hi,

Thanks for the great work!

I found an issue when running SOM. My python shell is under Win7 64bit using Anaconda. Here is my code.

    from sklearn import datasets
    import milk
    n_points = 1000
    X, color = datasets.samples_generator.make_s_curve(n_points, random_state=0)
    g=(1000,)
    grid = milk.unsupervised.som(data=X, shape=g, iterations=1000, L=.2, radius=4, R=None)

Here is the error message.

    RuntimeError                              Traceback (most recent call last)
    <ipython-input-7-dbad0be19950> in <module>()
    ----> 1 grid = milk.unsupervised.som(data=X, shape=g, iterations=1000, L=.2, radius=4, R=None)

    C:\Anaconda\lib\site-packages\milk\unsupervised\som.pyc in som(data, shape, iterations, L, radius, R)
    109         data = data.astype(np.float32)
    110     grid = np.array(R.sample(list(data), np.product(shape))).reshape(shape + (d,))
    --> 111     putpoints(grid, data, L=L, radius=radius, iterations=iterations, shuffle=True, R=R)
    112     return grid

    C:\Anaconda\lib\site-packages\milk\unsupervised\som.pyc in putpoints(grid, points, L, radius, iterations, shuffle, R)
     49         if shuffle:
     50             random.shuffle(points)
    ---> 51         _som.putpoints(grid, points, L, radius)
     52
     53 def closest(grid, f):

    RuntimeError: Arguments to putpoints don't conform to expectation. Are you calling this directly? This is an internal function!

Did I make a mistake? I have checked the _som.pyd file is in the same folder with SOM.py file, so it seems no issue in SOM.py. However, since I don't know how to open _som.pyd file, I am not sure whether I make a mistake in using codes.

Thanks!