1

I am trying to use SUSI on hyperspectral data, but I am getting errors. I am sure that I am the problem and not SUSI.

import susi as su
import spectral as sp
import spectral.io.envi as envi
import numpy as np
import matplotlib.pyplot as plt
import matplotlib


box = envi.open('C:/path/ref_16-2_22/normalised.hdr')
data = np.array(box.load())
som = su.SOMClassifier(n_rows=data.shape[0], n_columns=data.shape[1])
som.fit(data)
ValueError: estimator requires y to be passed, but the target y is None
som = su.SOMClustering(n_rows=data.shape[0], n_columns=data.shape[1])
som.fit(data)
ValueError: Found array with dim 3. None expected <= 2.

I am definitely the problem! Has anyone used SUSI on 3D data?

russj
  • 25
  • 1
  • 6
  • Please post the issue in the `susi` repository so that other `susi` users can benefit: https://github.com/felixriese/susi/issues – felice Oct 11 '22 at 10:53

1 Answers1

1

In general: the dimensions of the SOM (rows and columns) don't have to relate to the dimensions of your data.

For susi: You are using a classifier on data without class labels. in som.fit, you need to pass also the labels y:

som.fit(data, y)

data can be an n-D array, y would be a 1D array in your case I guess.

Alternatively, you can use unsupervised clustering:

som = SOMClustering()
som.fit(data)

[Disclaimer: I am the developer of susi.]

felice
  • 1,185
  • 1
  • 13
  • 27
  • hah, then you are exactly the person to answer my question. Thanks for the response. I did try the SOMClustering() call, and got a different error (I also have that in my question above). Does the SOMClustering only accept 2d arrays? Currently my data is in shape M x N x B, and it is throwing a value error for dimensions. I asssume I need to reshape np.reshape(data (-1, B)) ? – russj Oct 11 '22 at 11:30
  • As I said: the perfect place for this discussion is here: github.com/felixriese/susi/issues . In general, the input data can be N-dimensional, so not pictures. You can reshape, but you need to check if that makes sense for your data (e.g., you lose spatial correlation). – felice Oct 12 '22 at 08:20
  • I added a comment about the SOM dimensions – felice Oct 12 '22 at 08:23