Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K-means on images / 3D data #55

Open
kmader opened this issue Jul 27, 2019 · 1 comment
Open

K-means on images / 3D data #55

kmader opened this issue Jul 27, 2019 · 1 comment

Comments

@kmader
Copy link
Owner

kmader commented Jul 27, 2019

I'd like to cluster my vector maps with k-means in time. My number of samples are thus my number of timesteps and the featurevector are the u and v vectors for all pixels. Like this, I cannot use the information that u and v are a couple at each point in space, I just stack them behind each other. sklearn.Kmeans doesn't allow for a third dimension.

@kmader
Copy link
Owner Author

kmader commented Jul 27, 2019

you have to reshape or flatten the array to use it with K-means. It (and most scikit-learn functions) take only 2D input. The first dimension is the number of observations and the second is the feature.
In this example: https://www.kaggle.com/kmader/k-means-clustering-on-neurons

We reshape the 2D+time (WHT) image into (W*H, T) meaning each pixel is an observation and the feature is the time series.

In some of the examples in the lecture (advanced segmentation), we added the x and y position of the pixel as a feature so it could group regions together (ultimately leading to super pixels) You probably want to use U and V as the feature and possibly add x and y if it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant