Skip to main content
26 votes
Accepted

Confused about how to apply KMeans on my a dataset with features extracted

For clustering, your data must be indeed integers. Moreover, since k-means is using euclidean distance, having categorical column is not a good idea. Therefore you should also encode the column ...
HonzaB's user avatar
  • 1,669
20 votes
Accepted

How to measure the similarity between two images?

Check this handout! Well, there a few so... lets go: Given two images $J[x,y]$ and $I[x,y]$ with $(x,y) \in N^{N \times M}$... A - Used in template matching: Template Matching is linear and is not ...
Pedro Henrique Monforte's user avatar
14 votes
Accepted

How to get the probability of belonging to clusters for k-means?

Let us briefly talk about a probabilistic generalisation of k-means: the Gaussian Mixture Model (GMM). In k-means, you carry out the following procedure: - specify k centroids, initialising their ...
R Hill's user avatar
  • 1,105
13 votes
Accepted

Clustering high dimensional data

I don't think any of the clustering techniques "just" work at such scale. The most scalable supposedly is k-means (just do not use Spark/Mahout, they are really bad) and DBSCAN (there are some good ...
Has QUIT--Anony-Mousse's user avatar
12 votes
Accepted

Clustering for multiple variable

K-means Your data has $7$ dimensions so k-means is worth to try. See the PCA of your data and check if any cluster is visible there as K-means will have a tough time if clusters are not Gaussian. the ...
Kasra Manshaei's user avatar
11 votes

Clustering for mixed numeric and nominal discrete data

Taking a stab: I am trying to identify a clustering technique with a similarity measure that would work for categorical and numeric binary data. Gower Distance is a useful distance metric when the ...
gregorymatchado's user avatar
10 votes

Clustering geo location coordinates (lat,long pairs)

GPS coordinates can be directly converted to a geohash. Geohash divides the Earth into "buckets" of different size based on the number of digits (short Geohash codes create big areas and longer codes ...
Brian Spiering's user avatar
10 votes
Accepted

K-Means vs hierarchical clustering

I would say hierarchical clustering is usually preferable, as it is both more flexible and has fewer hidden assumptions about the distribution of the underlying data. With k-Means clustering, you ...
tom's user avatar
  • 2,248
10 votes
Accepted

How to evaluate the K-Modes Clusters?

The are some techniques to choose the number of clusters K. The most common ones are The Elbow Method and The Silhouette Method. Elbow Method In this method, you ...
Bruno Lubascher's user avatar
9 votes

k-means in R, usage of nstart parameter?

nstart option attempts multiple initial configurations and reports on the best one. For example, adding nstart=25 will generate 25 initial random centroids and choose the best one for the algorithm. ...
FrlUn's user avatar
  • 121
9 votes

Clustering geo location coordinates (lat,long pairs)

I am probably very late with my answer, but if you are still dealing with geo clustering, you may find this study interesting. It deals with comparison of two fairly different approaches to ...
VividD's user avatar
  • 656
9 votes
Accepted

Sklearn: unsupervised knn vs k-means

Unsupervised k-NN Unlike k-means, the unsupervised k-nn does not associate a label to instances. All it can do is tell you what instances in your training data is k-nearest to the point you are ...
JahKnows's user avatar
  • 8,946
9 votes

Accuracy for Kmeans clustering

Accuracy is a measure of comparing the true label to the predicted label. K-Means is an unsupervised clustering algorithm where a predicted label does not exist. So, accuracy can not be directly ...
E. Kenney's user avatar
  • 304
8 votes

K-Means clustering for mixed numeric and categorical data

You should not use k-means clustering on a dataset containing mixed datatypes. Rather, there are a number of clustering algorithms that can appropriately handle mixed datatypes. Some possibilities ...
Sam  - Founder of AceAINow.com's user avatar
7 votes

K-Means clustering for mixed numeric and categorical data

It depends on your categorical variable being used. For ordinal variables, say like bad,average and good, it makes sense just to use one variable and have values 0,1,2 and distances make sense here(...
Ram's user avatar
  • 349
7 votes

K-means incoherent behaviour choosing K with Elbow method, BIC, variance explained and silhouette

Finding the elbow can be made more easier by computing the angles between the consecutive segments. Replace your: kIdx = 10-1 with: ...
Sahloul's user avatar
  • 71
7 votes

K-means incoherent behaviour choosing K with Elbow method, BIC, variance explained and silhouette

Just posting a summary of above comments and some more thoughts so that this question is removed from "unanswered questions". Image_doctor's comment is right that these graphs are typical for k-means....
Joachim Wagner's user avatar
7 votes

PCA before K-mean clustering

PCA reduces dimensionality. It does not change the number of observations you have. Nor does it change the order of the data. The n-th observation in your original dataset will still be the n-th ...
Lauren Yu's user avatar
7 votes
Accepted

How to use k-means outputs (extracted features) as SVM inputs?

'Prediction' of k-means algorithm for each observation is just the corresponding centroid. So you can take vector of predicted centroids and use it as a categorical feature (maybe one-hot encoded). ...
David Dale's user avatar
  • 1,551
7 votes

KMeans vs. DBSCAN

In short, KMeans is a distance based clustering technique where depending on the distance between the data points your initialization(usually kmeans++) and clustering works. In kmeans, you initialize ...
karthikeyan mg's user avatar
6 votes

Clustering geo location coordinates (lat,long pairs)

You can use HDBSCAN for this. The python package has support for haversine distance which will properly compute distances between lat/lon points. As the docs mention, you will need to convert your ...
Matt's user avatar
  • 181
6 votes

Clustering users based on buying behaviour

Big Picture: First of all, the feature set in your data is pretty sparse and uninteresting, so you should not expect to gain much traction from this problem. Use your human mind to think about the ...
AN6U5's user avatar
  • 6,828
6 votes
Accepted

How to test accuracy of an unsupervised clustering model output?

Since you have the actual labels, you can compare them with the obtained labels and evaluate performance. Typically purity and nmi (normalized mutual information) are used. Read this (Evaluation of ...
arduinolover's user avatar
6 votes
Accepted

calculate distance between each data point of a cluster to their respective cluster centroids

...
Roshni Amber's user avatar
6 votes
Accepted

K-Means clustering - What to do if a cluster has 0 elements?

This is mostly an issue with really bad initialization (random vector generation as well as random labeling are stupid, don't use it - choose k points wth sampling, or k-means++) and with data where k-...
Has QUIT--Anony-Mousse's user avatar
6 votes

How to do clustering assuring more than one class per cluster?

This is a very strange design: The goal is to train an ensemble classification model. In general there is no strong reason to use only subsets of the data to train the individual learners, let alone ...
Erwan's user avatar
  • 25.5k
5 votes
Accepted

How to evaluate distance in k-means clusters?

There are several important points to keep in mind in considering your questions: You should always normalize or standardize your data before applying k-means clustering. This is true of most other ...
AN6U5's user avatar
  • 6,828
5 votes

Categorical data in Kmeans

Converting the categorical data into numerical data isn't really meaningful. Different mappings will give you different solutions. There is an extension of K-means algorithm for categorical data ...
arduinolover's user avatar
5 votes
Accepted

What is the meaning of spherical dataset?

In this case, a picture is a worth a thousand words. They literally mean data whose distribution on X,Y is roughly a sphere. Different clustering algorithms work better on different distributions. For ...
CalZ's user avatar
  • 1,663
5 votes

calculate distance between each data point of a cluster to their respective cluster centroids

I think this is a more elegant solution. First of all, km.fit_transform() (or km.transform()) gives you back all distances to all clusters. Then you can summarize only the minimum values - which are ...
Desiré De Waele's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible