I want to classify a hyperspectral image (Indian Pines data set).
The input is of shape (145, 145, 200) = a HSI of 145x145 px with 200 bands.
Each one of the 145x145 pixels should be classified to one of the 15 classes, so 'y' is of shape 145x145 containing the labels for each one of the pixels.
After flattening X (shape is now 145 * 145, 200) and y (shape is now 145 * 145) I used:
X_train_flat, X_test_flat, y_train_flat, y_test_flat = train_test_split(X_flat, y_flat, range(X_flat.shape), test_size = 0.8, random_state = 12) knn = KNeighborsClassifier(n_neighbors=16) knn.fit(X_train_flat, y_train_flat) y_pred_flat = knn.predict(X_test_flat)
This seems to work, but it is not clear to me if KNeighborsClassifier really knows that a 'pixel' is actually an array of values corresponding to the 200 bands and that KNeighborsClassifier should map all of the 200 bands to a single value from y.
For example, the first pixel of X has 200 values (i.e. X, X,.., X). Can KNeighborsClassifier determine that each value of input X belongs to y?
I hope I made my question clear enough.