Skip to main content

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

272 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
2 answers
2k 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 ...
syd's user avatar
  • 159
5 votes
0 answers
293 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 ...
anup's user avatar
  • 223
5 votes
0 answers
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 ...
Yang Li's user avatar
  • 1,013
4 votes
0 answers
704 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....
msamogh's user avatar
  • 61
4 votes
0 answers
739 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 ...
phamilton's user avatar
4 votes
2 answers
8k 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 ...
ERB3's user avatar
  • 41
4 votes
1 answer
4k 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 ...
curiosus's user avatar
  • 333
4 votes
0 answers
4k 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 ...
Adel's user avatar
  • 295
4 votes
0 answers
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)$. ...
Krithika Raghavendran's user avatar
4 votes
0 answers
1k 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 ...
Bob's user avatar
  • 439
4 votes
0 answers
12k 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 ...
Adam12344's user avatar
  • 527
4 votes
0 answers
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 ...
Hamideh's user avatar
  • 217
4 votes
0 answers
30k 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 ...
dominic's user avatar
  • 41
3 votes
0 answers
548 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,...
Lasnik23's user avatar
3 votes
0 answers
56 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 ...
Flitschi's user avatar
3 votes
0 answers
410 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?
user9855045's user avatar
3 votes
0 answers
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 ...
user21398's user avatar
  • 183
3 votes
0 answers
956 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 ...
Arpit Sisodia's user avatar
3 votes
2 answers
7k views

Difference between Ward hierarchical clustering and K-Means for classification

I have a dataset where of socio-demographic features of a population (expressed as percentages over the total population of the municipality: e.g. 12% of freelancers, 5% of unemployed etc.), each ...
sato's user avatar
  • 177
3 votes
0 answers
903 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 ...
Sameer Khanna's user avatar
3 votes
0 answers
755 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, ...
Liudas Daumantas's user avatar
3 votes
0 answers
101 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 ...
gmrukwa's user avatar
  • 31
3 votes
0 answers
342 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 ...
pdanese's user avatar
  • 191
3 votes
0 answers
2k 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 ...
Ashok K Harnal's user avatar
3 votes
0 answers
127 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: ...
Pierre L's user avatar
  • 1,008
3 votes
0 answers
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 ...
Filipe Francisco's user avatar
2 votes
0 answers
16 views

How to cluster based on x and y coordinates

I am trying to identify rows in groups of points using clustering algorithms. The bigger picture problem I'm trying to solve is to identify shelves given x and y coordinates of products. I can cluster ...
Tommy Wolfheart's user avatar
2 votes
1 answer
370 views

Choosing the best clustering algorithm and evaluating the results

I'm trying to separate my data into clusters using the k-means algorithm and the hierarchical algorithm, choose which algorithm fits my data the best, and evaluate the results. However, all of my ...
Jim's user avatar
  • 61
2 votes
0 answers
51 views

How can I ensure both levels of a binary variable are represented in every cluster?

Let's say I have some continuous variables and a binary treatment indicator. I want to cluster my observations based on the variables while ensuring that each cluster contains at least one member of ...
Noah's user avatar
  • 36.8k
2 votes
0 answers
371 views

How does this prove that the objective function in K-means clustering never increases?

I am reading the ISLR textbook (pg. 518-519, 12.4) and having trouble understanding why K-means clustering never increases. I can understand it conceptually but I don't understand the mathematical ...
idkmath28's user avatar
2 votes
0 answers
159 views

Normalization/standardization impact on T-SNE and K-means

I have a dataset of 20K samples on 27 features that I am trying to cluster with k-means. The dataset is in its majority rather sparse, i.e. 98% of samples have a single nonzero value in one of its ...
Seifbb's user avatar
  • 21
2 votes
1 answer
84 views

PCA : how to cluster data to differenciate my data the most while considering their groups

I have to do a PCA in R for a project, but I have 300 data in 15 differents groups, and I want to find the reduced space which gives me the most variability between the groups and cluster my data in ...
Marguerite's user avatar
2 votes
0 answers
290 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 ...
Ling Guo's user avatar
  • 121
2 votes
0 answers
280 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 ...
Michael Pulis's user avatar
2 votes
0 answers
158 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"...
Jens Stach's user avatar
2 votes
0 answers
57 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 ...
KRL's user avatar
  • 286
2 votes
0 answers
201 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?
Haitao Du's user avatar
  • 37.3k
2 votes
1 answer
1k 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 ...
Maths12's user avatar
  • 579
2 votes
2 answers
486 views

How to include percentage variables in PCA + K-means when some values are undefined because the denominator is 0?

I'm trying to do customer segmentation by using PCA to reduce dimensionality and then feeding the resulting principal components into a K-means algo to get at the final segments. Some of my variables ...
Amazonian's user avatar
  • 1,554
2 votes
1 answer
777 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 ...
user avatar
2 votes
0 answers
260 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 ...
Andrey's user avatar
  • 61
2 votes
0 answers
894 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 ...
Andrew's user avatar
  • 21
2 votes
0 answers
114 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 ...
Christian's user avatar
2 votes
0 answers
2k views

Selecting K with elbow method for K-modes (binary or nominal data)

I have run the k-modes algorithm on my nominal data set, which I converted to a dummy matrix (binary). As for K-Means, one can perform the elbow method by looking at the elbow method using, according ...
dmeu's user avatar
  • 300
2 votes
0 answers
77 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 ...
mmuntag's user avatar
  • 21
2 votes
0 answers
2k 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 ...
Steven's user avatar
  • 499
2 votes
0 answers
125 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 ...
Christian Rodriguez's user avatar
2 votes
0 answers
420 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. ...
Fanny ZMN's user avatar
2 votes
0 answers
2k 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 ...
R.S's user avatar
  • 21
2 votes
0 answers
727 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). ...
Bzisch's user avatar
  • 21

1
2 3 4 5 6