# Questions tagged [k-means]

k-means is a method to partition data into clusters by finding a specified number of means, k, s.t. when data are assigned to clusters w/ the nearest mean, the w/i cluster sum of squares is minimized

286 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
261 views

### Convergence of k-means or EM on Mixture of Gaussians

There are many algorithms for learning mixture of Gaussians but typically k-means/EM is used in practice. My question is related to the performance of k-means/EM for MoG. Recently, I came across this ...
• 213
2k views

### Pearson's Correlation Coefficient as a clustering criterion: why should it be close to -1?

Let's say we have a dataset $x = (x_1, x_2, ..., x_n)$ where each data point is assigned to one of $m$ clusters. Let $D = \{d_{ij}\}$ be the $n\times n$ distance matrix where $d_{ij} = d(x_1, x_j)$. ...
971 views

### Why does Kernel K-means work better than spectral clustering in this case?

I want to cluster a dataset using spectral clustering. Assuming $X$ is $d \times n$ data matrix as $n$ is the number of data samples. I construct a directed Adjacency matrix $W, n \times n$ in which ...
• 429
10k views

### K-Means Clustering with Dummy Variables

I want to use k-means to cluster my data. I have broken one column into 4 dummy variables and I have normalized all of the data to mean=0 and sd=1. Will k-means work with these dummy variables? I ...
• 517
2k views

### Checking the assumptions of K-means clustering

I want to do a k-means clustering on a dataset containing 22 numerical variables between 0 and 100 and 75 observations using R. I read this post How to understand the drawbacks of K-means on k-means ...
• 217
27k views

### k-means clustering why sum of squared errors (why k-medoids not)?

K-means clustering uses the sum of squared errors (SSE) $E = \sum\limits_{i=1}^k \sum\limits_{p \in C_i} (p-m_i)^2$ (with k clusters, C the set of objects in a cluster, m the center point of a ...
• 41
35 views

### Cluster Algorithm for multidimensional data

My goal is to cluster data (20000 samples with a range from 0.0 to 1.0, and 14 dimensions/features). Since I don't know the number of clusters, I tried using MeanShift and DBSCAN. My problem with ...
• 31
245 views

### Clustering text embeddings: TF-IDF + BERT Sentence Embeddings

I am trying to cluster a few thousand forum posts that are similar in content to Stackoverfow. So far, I have tried two main approaches to represent the posts: TF-IDF Sentence embedding based on BERT....
• 41
173 views

### When to use K-Medoids instead of K-means

When it's better to use K-Medoids rather than K-Means? Can anybody give some examples of dataset for the same?
38 views

### Is my variable considered okay to use in k-means clustering with Euclidean distance?

I was wondering if I can use regular kmeans() in R with my variable "number of drug prescriptions" which equals a number between 1-25. From what I've read k-means ...
• 173
3k views

### How to determine the best batch-size value for Mini Batch K-means algorithm?

I am working on a project where I apply k-means on severals datasets. These datasets may include up to several billion points. I would like to use mini batch k-means to save time. However, the mini ...
• 153
1k views

### Compare clustering results with different attributes and number of clusters

I used K-means to cluster a large data set that has millions of samples. I tried to create the clusters with different sets of attributes, which, as a result, generated different optimal number of ...
• 139
720 views

### Difference between identifying outliers using LOF and K-means clustering

I am identifying outliers using K-means and LOF (Local Outlier Factor). Let's say if we are identifying possible outliers using both the techniques, I believe LOF will pick global outliers also as ...
• 1,059
3k views

### Distance metric for categorical and numerical data

I have asked a related question in mathematics section, but I think here is a better place to ask. for both KNN algorithm (classification) and k-means algorithm (clustering), there is a need for a ...
• 275
795 views

### Clustering a set of curves

I am working with a MRI dataset where we inject dye into a person's wrist and measure intensity per time on a voxel-by-voxel basis. I am trying to determine if it is possible to identify certain ...
697 views

### If I want to do PCA before k - means, is it mandatory to do it for all variables?

I have 10 variables and some of them are highly correlated. So before I do k - means, I want to get lower number of variables that are not correlated, but retain as much information as possible. Thus, ...
83 views

### How to check whether there are any clusters in data?

In short: I am using k-means clustering with correlation distance. How to check, how many clusters should be used, if any? There are many indices and answers on how to establish a number of clusters ...
• 31
225 views

### When should I use classical k-means clustering and when should I use trimmed k-means clustering?

I suspect that if there are many unimportant outliers, trimmed k-mean clustering should be employed. Am I on the right track?
• 539
314 views

### How to deal with variability in clustering. Multiple/Meta clustering?

I'm not sure what information is relevant here, so here is some background: I'm using Python 3 / sklearn, but I could probably use R if needed. I have a small sparse data-set (~1500 samples, ~1600 ...
• 181
1k views

### Should dummy variables be normalized along with numeric variables when doing kmeans clustering

I am trying to cluster the data set 'How Americans spend their time' using kmeans clustering. The data set contains education, gender and age-range (55-60, 60-65 etc) as categorical variables and ...
98 views

### Adding weights to functions not accepting weights

If I had a vector of weights for each observation data(iris) wghts <- abs(rnorm(nrow(iris))) And I had a function that did not accept weights as an argument: ...
• 928
2k views

### Is K-Medoids really better at dealing with outliers than K-Means? (with example showing the contrary)

K-Medoids and K-Means are two popular methods of partitional clustering. The consensus is that K-Medoids is better at clustering data when there are outliers (source). This is because it chooses data ...
• 753
8k views

### R: silhouette with k-means

I'm currently checking some clustering evaluation indexes in R, and now I'm using Silhouette and its respective function in R, "silhouette" (in "cluster" package). To test the method, I used the ...
139 views

### PCA explained variance and model inertia

I'm trying to perform a PCA to reduce the dimensionality of my data and subsequently perform a K-Means algorithm. I initially chose 4 Principal Components because they explain 70% of my variance. This,...
• 21
155 views

### Update centroids in minibatch K-Means

I wish to know about the operation of minibatch KMeans through a very simple algorithm. The aim of this post is to know how should one update centers in minibatch KMeans. I intend to integrate ...
• 121
178 views

### Perform clustering from a similarity matrix

I have a list of songs for each of which I have extracted a feature vector. I calculated a similarity score between each vector and stored this in a similarity matrix. I would like to cluster the ...
55 views

### How to perform cluster analysis on categorial data in R

I have survey data with 1000 respondents, each one has awnsered 20 questions related to different product features of a car. Each question could be awnsered as "good", "indifferent"...
• 159
34 views

### How can I cluster sequential data?

Suppose that I have a sequence of vectors $y_n \in \mathbb{R}^m$ for $n \in \{1, \dots, N\}$. My goal is to divide $y_n$ in $K$ clusters and want my clusters to satisfy the following conditions: Each ...
• 186
132 views

### Can DBSCAN overcome the drawbacks of K-means?

We have a great post to discuss the drawbacks of K-means. Can DBSCAN overcome these drawbacks? and what are the drawbacks of DBSCAN?
• 33.7k
254 views

### For which clustering algorithms is the Gap statistic useful?

How can i know for which clustering algorithms (with a parameter that represents number of clusters) it makes sense to use the Gap statistic? I've read in the paper by Tibshirani, Walter & Hastie ...
• 399
423 views

### Can clustering with Gaussian mixture models be done based on cosine similarity?

Apologies if this has already been answered; I found some similar posts (here and here) but don't feel they answered the specific question I have. Please feel free to correct any misunderstandings in ...
4k views

### Missing data in k-means cluster model

I'm working on clustering email addresses using K-means based on their value to and engagement with the company (metrics such as % of emails opened, # of web browsing sessions, etc). I would like to ...
• 21
865 views

### k-means/k-nearest neighbours on multi-dimensional scaled data

I used the Python manifold library for multi-dimensional scaling on my distance matrix. Can I use k-means or k-nearest neighbours on ...
• 401
558 views

### Clustering spatial data based on location and values

I'm looking for a way, preferably in R, to create a cluster of point data (specifically, the centroids of UK postcodes), where each cluster comes as close as possible to containing a certain number of ...
232 views

### How to cluster customers by their purchases

I have matrix with about 40 columns which are sales of specific products and about 15 000 rows. Each row is purchases of specific customer. The data consists of information about sales for 2 years ...
• 61
886 views

### K means clustering for time series data

Suppose, we have three metrics (M1,M2,M3) for one database D1 which have time series data and similarly same metric (M1,M2,M3) for other database D2 and so on.How do we cluster using K- means ...
• 21
110 views

### Clustering data sitting close to corners of an N-dimensional parallelepiped

I am looking for a method of clustering data that are close to the corners of an $N$-dimensional parallelepiped (but I don't know the vectors spanning it). Is there a good method for finding ...
73 views

### Distribution of the initializing set at K-means++

There is a well-known modification of the initializing step of K-means, named K-means++. It chooses cluster centers with probability proportional to its squared distance from the point's closest ...
• 21
1k views

### Why Elbow algorithm plot shows a straight line instead of curve line?

I want to apply kmeans clustering algorithm on dataset of 12008 samples. This dataset is actually an eigenvector matrix of size (12008 * 12008) generated from given laplacian matrix. In order to ...
• 449
124 views

### Regression analysis for a big set of data

Well, it's my first post but I have been struggling hard with this problem so I had to look after help. The problem: I have a high set of data like this one (black dot are the data): I have to find ...
384 views

### A problem with implementing PCA-guided k-means

I am new to machine learning. I am reading the papers K-means Clustering via Principal Component Analysis and PCA-guided search for K-means. But there are too many mathematical proofs in these papers. ...
1k views

### K-Means Clustering using modified correlation (1 - pearson correlation coefficient)

I am trying to implement k-means clustering on a 6x6 data set that looks like this: 2 3 6 0 1 7 4 9 9 6 2 2 0 1 7 9 5 0 2 3 2 7 8 3 8 2 9 2 3 1 8 0 0 1 7 9 Using ...
• 21
687 views

### kMeans unsupervised feature learning on multiple layers

I'm trying to develop an unsupervised feature learning pipeline. I have a train set with 512x512 images. I've extracted 16x16 patches, performed preprocessing steps (normalization and whitening). ...
• 21
151 views

### Anomaly Analysis (K-Means) - finding suspicious activities/operators

I am relativly new to the field of data mining and want to make a anomaly detection on transactional retail data. I want to use a simple anomaly detection (kmeans at the moment) for finding suspicious ...
229 views

### Vector Quantization of heavy tailed distribution

I'm generating with Monte Carlo simulation some stock price $X$. Once I have the stock price sample, I want to cluster it with 100 points $\hat{X}$. My problem is that the error associate with my k-...
96 views

### What's the methodology behind the most-difference-between-groups-tag-cloud?

What is the likely stats methodology used in this old OKCupid post?: http://www.economist.com/blogs/johnson/2010/10/sexuality_and_language And this: http://blog.okcupid.com/index.php/the-real-stuff-...
• 523
442 views

### Standardizing non-normal data for use in distance-based classifier

I have a dataset containing non-normally distributed variables that I want to feed into a distance-based classifier (e.g. K-means). Is it ok to just subtract the mean and divide by the standard ...
• 155
1k views

### Using linear discriminant analysis to validate the cluster groups resulting from kmeans

I'm currently working on a cluster analysis project and ran kmeans on the data for k=2. I was reading similar articles on similar experiments, and the investigators used discriminant analysis to ...
• 853
Usually online clustering methods (based on kmeans or not) define a distance threshold value. If a new data-point $x$ is far enough from the nearest center $c$ (i.e. the distance from $x$ to $c$ is ...