susi icon indicating copy to clipboard operation
susi copied to clipboard

ValueError: Found array with dim 3. None expected <=2.

Open Russjas opened this issue 3 years ago • 3 comments

Been bashing my head against this one. I have a hyperspectral cube from drill core scanning:

box.shape
(3590, 30, 249)

som = Susi.SOMClustering()
test = som.fit(box)

ValueError: Found array with dim 3. None expected <= 2.

Russjas avatar Oct 18 '22 07:10 Russjas

The SOM is designed to take M input vectors with N dimensions, so the data should have a shape of (M, N). Yours is image data with a shape of (M, N, K). This does not yet work with this package. One idea could be to flatten your data:

import numpy as np
data = np.reshape(box, newshape=(3590, -1))
som = Susi.SOMClustering()
som.fit(data)

Does that work for you?

felixriese avatar Oct 18 '22 19:10 felixriese

Hi, thanks for the reply.

Yes, I have tried the .fit method with flattened data, and it runs with no errors. The trouble I am having is then translating the som outputs back to the image to visualise the distribution of clusters. I will keep playing with it.

It is good to have confirmation that M x N data is required and I wasnt just calling susi incorrectly

Thanks

Russjas avatar Oct 21 '22 08:10 Russjas

Glad to hear that it works!

For the interpretation of the results: what exactly do you want to achieve with the SOM? What do you want to visualize?

See examples/SOMClustering.ipynb for plot examples.

felixriese avatar Oct 22 '22 16:10 felixriese

Closing this for now - can be reopened for more questions

felixriese avatar Nov 19 '22 18:11 felixriese