# Questions tagged [k-means]

k-means is a family of cluster analysis methods in which you specify the number of clusters you expect. This is as opposed to hierarchical cluster analysis methods.

301 questions
Filter by
Sorted by
Tagged with
191k views

### K-Means clustering for mixed numeric and categorical data

My data set contains a number of numeric attributes and one categorical. Say, NumericAttr1, NumericAttr2, ..., NumericAttrN, CategoricalAttr, where ...
68k views

### Clustering geo location coordinates (lat,long pairs)

What is the right approach and clustering algorithm for geolocation clustering? I'm using the following code to cluster geolocation coordinates: ...
17k views

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

I'm trying to cluster some vectors with 90 features with K-means. Since this algorithm asks me the number of clusters, I want to validate my choice with some nice math. I expect to have from 8 to 10 ...
19k views

### K-means: What are some good ways to choose an efficient set of initial centroids?

When a random initialization of centroids is used, different runs of K-means produce different total SSEs. And it is crucial in the performance of the algorithm. What are some effective approaches ...
7k views

### K-means vs. online K-means

K-means is a well known algorithm for clustering, but there is also an online variation of such algorithm (online K-means). What are the pros and cons of these approaches, and when should each be ...
2k views

### Fast k-means like algorithm for 10^10 points?

I am looking to do k-means clustering on a set of 10-dimensional points. The catch: there are 10^10 points. I am looking for just the center and size of the largest clusters (let's say 10 to 100 ...
20k views

### Clustering for mixed numeric and nominal discrete data

My data includes survey responses that are binary (numeric) and nominal / categorical. All responses are discrete and at individuals level. Data is of shape (n=7219, p=105). Couple things: I am ...
3k views

### Convergence in Hartigan-Wong k-means method and other algorithms

I have been trying to understand the different k-means clustering algorithms mainly that are implemented in the stats package of the ...
54k views

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

I am trying to apply a basic use of the scikitlearn KMeans Clustering package, to create different clusters that I could use to identify a certain activity. For example, in my dataset below, I have ...
10k views

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

I need to get the probability for each point in my data set. The idea is to compute distance matrix (first column contsins distances to first cluster, second column conteins distances to second ...
9k views

### Clustering high dimensional data

TL;DR: Given a big image dataset (around 36 GiB of raw pixels) of unlabeled data, how can I cluster the images (based on the pixel values) without knowing the number of clusters ...
2k views

### Efficient dynamic clustering

I have a set of datapoints from the unit interval (i.e. 1-dimensional dataset with numerical values). I receive some additional datapoints online, and moreover the value of some datapoints might ...
2k views

### Bag of Visual Words

What I am trying to do: I am trying to classify some images using local and global features. What I have done so far: I have extracted sift descriptors for each image and I am using this as my ...
5k views

### For which real world data sets does DBSCAN surpass K-means.?

For clustering, DBSCAN surpass k-means in terms of handling arbitrary shape data sets. In the most published papers about density based clustering, the experiments are performed with synthetic data ...
4k views

### Image clustering by similarity measurement (CW-SSIM)

I'm trying to use scikit-learn and pyssim for clustering a set of images - less than 100. The end goal is to place the images into several buckets (clusters) according to the calculated similarity ...
1k views

### Binning long-tailed / pareto data before clustering

I want to cluster a set of long-tailed / pareto-like data into several bins (actually the bin number is not determined yet). Which algorithm or model would anyone recommend?
115 views

### How to compare different similarity measurements in text clustering?

I have a dataset which contains vectors generated from subtitles (each column represents a genre, each row is a movie name), my purpose is to find the most similar movie titles, I want to use ...
2k views

### Improve k-means accuracy

Our weapons: I am experimenting with k-means and Hadoop, where I am chained to these options for various reasons (e.g. Help me win this war!). The battlefield: I have articles, which belong to c ...
3k views

### Distributed k-means in Spark

I want to implement K-means algorithm in Spark. I am looking for a starting point and I found Berkeley's naive implementation. However, is that distributed? I mean I see no mapreduce operations. Or ...
15k views

### K-Means vs hierarchical clustering [closed]

What use cases does it make more sense to use hierarchical clustering as opposed to K-Means and vice versa?
17k views

### k-means in R, usage of nstart parameter?

I try to use k-means clusters (using SQLserver + R), and it seems that my model is not stable : each time I run the k-means algorithm, it finds different clusters. But if I set nstart (in R k-means ...
2k views

### What is the meaning of spherical dataset?

In the following article, one of the statement is as follows: The K-means algorithm is effective only for spherical datasets What does spherical dataset mean?
4k views

### Predictive analysis of rare events

I'm trying to predict rare events, meaning less than 1% of positive cases. I basically try to predict if a subject will have 0, 1, 2 ... , 6, > 6 failures (there are cases in all those categories). I'...
3k views

### Determinate K in K-Means Clustering

I have salary data of several user (Python list). Now I am using KMeans to cluster them. Given this data, Is there a way to figure out the best value for 'K' automatically through program? I tried ...
530 views

### Couple PCA plot and clusters to labels

I am trying my first 'project' concerning machine learning and I am a bit stuck. However, I am not sure if it's even possible but here goes my question. What I want to achieve is clustering user ...
2k views

### How to make k-means distributed?

After setting up a 2-noded Hadoop cluster, understanding Hadoop and Python and based on this naive implementation, I ended up with this code: ...
63 views

### How do I interpret my result of clustering?

I am working on a clustering problem. I have 11 features. My complete data frame has 70-80% zeros. The data had outliers that I capped at 0.5 and 0.95 percentile. However, I tried k-means (python) on ...
332 views

### Clustering efficiency in a discrete time-series

Is it possible to identify the point in time where the cluster separation is at its most in a discrete time series clustering? Say I have 4 clusters of discrete time series and I want to pick a ...
407 views

### Categorical Clustering of Users Reading Habits

I have a data set with a set of users and a history of documents they have read, all the documents have metadata attributes (think topic, country, author) associated with them. I want to cluster the ...
42 views

### What are practical differences between kernel k-means and spectral clustering?

I've been lately wondering about kernel k-means and spectral clustering algorithms and their differences. I know that spectral clustering is a more broad term and different settings can affect the ...
15k views

### Clustering for multiple variable

There are total 50 students(john, Roy..) and used some action to do a job. My dataSet something like this ...
2k views

### Boundary conditions for clustering

I have some data that I would like to cluster with k-means. One of the features is the hour of the day. The problem is that the hour '23' is considered far from the hour '0'. How can I map the ...
6k views

### How to measure the similarity between two images?

I have two group images for cat and dog. And each group contain 2000 images for cat and dog respectively. My goal is try to cluster the images by using k-means. Assume image1 is ...
5k views

### Sklearn: unsupervised knn vs k-means

Sklearn has an unsupervised version of knn and also it provides an implementation of k-means. If I am right, kmeans is done exactly by identifying "neighbors" (at ...
4k views

### Plots with shaded standard deviation

What tools can I use to make a visualization similar to this one? I want to have the mean be bolded and the standard deviation be shaded.
121 views

### Does the choice of normalization change dramatically the result of a KMeans

I'm using a KMeans to get the profile of several users according to several columns (I'm working with RStudio). To analyze my clusters, I decided to realize a radar chart, so I decided to use feature ...
25k views

### How to test accuracy of an unsupervised clustering model output?

I am trying to test how well my unsupervised K-Means clustering properly clusters my data. I have an unsupervised K-Means clustering model output (as shown in the first photo below) and then I ...
8k views

### How to calculate the silhouette coefficient?

Calculate the silhouette coefficient of point Pi from the above image. To apply the given formula, how to know which is a(i) and b(i)?
3k views

### k-means clustering data with large number of meaningless values

I am looking to perform k-means on my dataset which contains a large number of 0 values. Edit: the last value you see is different to the others, that is simply the sum of transactions, not related ...
2k views

### How to explain the outcome of k-means clustering?

I am currently conducting some analysis using NTSB aviation accident database. There are cause statements for most of the aviation incidents in this dataset that describe the factors lead to such ...
4k views

### Scikit Learn: KMeans Clustering 3D data over a time period (dimentionality reduction?)

I have a dataset of xyz coordinates with a date component in a pandas dataframe ex: date1: $[x_1,y_1,z_1]$, date2: $[x_2,y_2,z_2]$, date3: $[x_3,y_3,z_3]$, .. I would like to classify a sample of ...
603 views

### What's the difference between finding the average Euclidean distance and using inertia_ in KMeans in sklearn?

I've found two different approaches online when using the Elbow Method to determine the optimal number of clusters for K-Means. One approach is to use the following code: ...
508 views

### k-means|| in PySpark

I'm trying to apply k-means$\|$ clustering in PySpark. According to this paper, there is an oversampling factor, $l$, that would affect the model's cost. I couldn't find any parameter regarding ...
5k views

### K-means clustering on the data frame having only one column

unsup_df is a DataFrame which has only one column: review. I want to form 2 clusters of the reviews. One positive and one ...
531 views

### Details of the k-means++ algorithm that is used to seed k-means

Regard to K-Means++ algorithm, which is an algorithm for choosing the initial values (or "seeds") for the k-means clustering algorithm. K-Means++ algorithm in Wikipedia The exact algorithm is as ...
2k views

### Constrained k-means algorithms in R (must-link constraints)

I currently face an unsupervised learning task that is to be approaches using clustering. More specifically, it is a segementation task and hence there is some prior knowledge about a) the number of ...
66 views

### k-means classifies one data point as a group

I have 1000 sets of one dimensional data (360 each in length), and I want k means to classify what is a small/medium/large value (n_clusters=3) for each set of data, but I'm getting a lot of instances ...
15k views

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

I have a dataset of some keywords in some text files. Using the append feature I have access each text file and I append all of the keywords to token_dict like this ...