Questions tagged [k-means]

k-means is a clustering algorithm, implemented in popular data science tools. Use this tag for questions related to the k-means clustering algorithm itself, or to its use with the tools that implement it (alongside other tags specific to those tools).

k-means
Filter by
Sorted by
Tagged with
0 votes
0 answers
78 views

Running a K-means (.fit) gives error:Params must be either a param map or a list/tuple of param maps but got %s." % type(params)

I am running a k-means algorithm. My feature are DoubleType and have no nulls, but I get : raise TypeError("Params must be either a param map or a list/tuple of param maps but got %s." % ...
mblume's user avatar
  • 253
0 votes
1 answer
339 views

How do I evaluate a clustering performance if number of the clusters are not equal to ground truth labels?

I have been trying to learn unsupervised machine learning models. I wanted to know if the number of predicted clusters are more or less than the number of ground truth labels, then how do we ...
Md Farhad Mokter's user avatar
0 votes
0 answers
36 views

k-means clustering in jsfiddle using json data

I want to make cluster data using K-means using JSON data The variable to be clustered are "InterestinProgramming", "AbilityinPython", "AbilityinJS", "AbilityinJAVA&...
Erma Dearni Wati's user avatar
1 vote
1 answer
66 views

Dtaidistance SSE and Silhouette score

I'm searching for a way to easily print SSE value and Silhouette score of a Dtaidistance (https://dtaidistance.readthedocs.io/en/latest/index.html) kmeans model after its training on data. While ...
hrdmean's user avatar
  • 21
0 votes
1 answer
33 views

How to segment with labelled data?

I have a historical dataset of target customers, of whom I know who has purchased the product. E.g. 100k target customers, of whom 10k purchased. I also have metadata Inc demographic information, and ...
Westy347's user avatar
0 votes
0 answers
44 views

Perform K-means Clustering in RapidMiner - Dealing with Categorical Variables

I have a table customer_segmentation where each entry corresponds to a unique customer, and the structure of the table is as follows: customer_id: (integer) Unique key to identify each customer gender:...
Tiago's user avatar
  • 41
-1 votes
1 answer
265 views

array.array() takes no keyword arguments [closed]

Trying to do a k means clustering on FARS dataset, getting the array.array() takes no keyword arguments error and don't understand why or how to correct it. Initially was getting errors for int32 ...
Louisa Wareing's user avatar
0 votes
1 answer
131 views

When using scikit-learn K-Means Clustering, how can you extract the centroids in original data domain?

I am using the sklearn KMeans k-means clustering algorithm. Before clustering, I normalize my data from [0,1] using scaler = MinMaxScaler() scaled_features = scaler.fit_transform(data) Now, I can run ...
Colton Campbell's user avatar
0 votes
0 answers
518 views

KMeans is showing error 'NoneType' object has no attribute 'split' on nonEmpty Array

I ran the code below. from sklearn.cluster import KMeans kmeans = KMeans(n_clusters=4) kmeans.fit(data[0]) But got an error : AttributeError: 'NoneType' object has no attribute 'split' PS - ...
Deb Jyoti's user avatar
0 votes
1 answer
56 views

Why are the kmeans centroids far from the data? Python

I'm making a kmeans model with the data from Twitter, but when I apply the polarity and subjectivity analysis on the scatterplot, the centroids (red x) appear far from the data: from sklearn....
Nana's user avatar
  • 13
1 vote
1 answer
43 views

Python - Image Colors Extrapolation - KMeans error

i have found this tutorial on how to write a python script that uses OpenCV and Kmeans for extrapolating the top colors from an image and plot them in a pie chart using Matplot. The code is the ...
Mattew's user avatar
  • 13
-1 votes
1 answer
212 views

How to get the optimal number of clusters using elbow method and return it?

I need to find a way to return the number of optimal clusters from the elbow method implementation in python. How can I implement the elbow method in order to show the elbow method graph and then ...
Mikelenjilo's user avatar
0 votes
0 answers
38 views

Clustering matrix columns

I'm trying to build clusters into a matrix. The matrix represent the presence of products in an image. I have a first row with products references and a first column with videos references. My matrix ...
HMWorks's user avatar
  • 19
0 votes
1 answer
25 views

Is it possible to keep the best of both worlds of the k-mean and k-medoid methods?

I need to form teams (clusters) of individuals in such a way as to minimize the distance between the locations of the individuals on the same team. I could therefore use the k-mean method. Where it ...
B Legrand's user avatar
  • 101
1 vote
1 answer
147 views

K-means clustering algorithm

I want to get this image: But I got this image: how can i change the color? Below is my code. import numpy as np import cv2 as cv def kmeans_clustering(image, K): pixels = image.reshape((-1, 3))...
    ERICA 's user avatar
0 votes
0 answers
129 views

K-means clustering query in PostgreSQL using Embeddings column

I have a table named “keywords” with fields: text, embeddings. The embeddings field is an array type with the embeddings retried from OpenAI embeddings (1536 floats - Ada-002 model). Row example Text:...
sparkle's user avatar
  • 7,264
1 vote
1 answer
75 views

ValueError: invalid literal for int() with base 10: '2020-12-22 00:00:00' date time to time stamp conversion

I am doing clustering on date and value data. while performing k-means clustering date data not not fitted in model showing this error k_means = KMeans(n_clusters=2) k_means.fit(df) Error: ...
igneous spark's user avatar
1 vote
0 answers
27 views

How to summarize GPS tracks into a single line of equidistant points?

I am looking forward to advice on GPS data. Recorded are several tracks which branch out. I would like to summarize this data so that only one line of points summarizes the traveled route. The points ...
Julian Zirbel's user avatar
0 votes
1 answer
74 views

Spark KMeans produces deterministic results and not random

I am running Spark KMeans and I would like to have random seeds in every run for different results every time, however this is not the case. This is the code that I am using: KMeans kmeans = new ...
ktzan's user avatar
  • 512
0 votes
0 answers
127 views

Trying to develop a code for k-means clustering but can't get it right. What am I doing wrong?

I'm a very beginner in Python and trying to resolve a question for my Uni assessment where I need to perform a K-Means clustering. The first column of the dataset is all the countries in the world, ...
Gerd Muller's user avatar
0 votes
0 answers
135 views

Bag-of-Words (BoW) with k-means clustering

I created this matlab code that perform a BoW model and then add k-means clustering. % Load text data and preprocess it filename = "sonnetsPreprocessed.txt"; str = extractFileText(filename); ...
David Expósito's user avatar
0 votes
0 answers
139 views

Do I need to scale categorical variables which have numeric values for K-means clustering?

4 203 8 103 6 84 3 4 5 3 Name: cyl, dtype: int64 This is column named 'cyl' for cylinder, showing the number of cylinders ranging from 3-8 cylinders in a car engine. So do I need ...
Pree07's user avatar
  • 17
1 vote
1 answer
458 views

Passing a Distance Matrix to sklearn's K-Means Clustering

I am currently doing research using the ASJP Database and I have a distance matrix of the similarities between 30 languages in the shape of (30 x 30). I would like to perform K-Means Clustering on ...
gliwidilt's user avatar
1 vote
1 answer
319 views

Python kmeans : Sort cluster labels based on the value of their centroid

I have this simple kmeans algorithm that I apply on a list of float lists : def clustering(k,lists_to_cluster): max_vals = [max(sublist) for sublist in lists_to_cluster] kmeans_ampl = KMeans(k,...
Movilla's user avatar
  • 178
0 votes
0 answers
272 views

About CCC stats in K-means Clustering in SAS EM

I'm doing a K-means Clustering in SAS Enterprise Miner (SAS EM), and while I want to check how much k (clusters) is the best, the Reference Help of Cluster node there stated: " CCC — The cubic ...
Ya Choon's user avatar
0 votes
0 answers
101 views

ValueError: could not broadcast input array from shape (8,) into shape (9,)

So I am practicing ML on diet recommendations for diabetes patients with the help of BMI and age and I used a total of 2 datasets and they are input.csv and inputfin.csv. Then, after separating the ...
sss's user avatar
  • 1
0 votes
1 answer
360 views

How to get the feature names from OneHotEncoder and have them in Pandas data frame

Here is my Python code: encode = OneHotEncoder() encoded_cols = encode.fit_transform(data[['Sex', 'Housing', 'Saving accounts', 'Checking account', 'Purpose']]) cols = ...
BADREDDINE BALAJ's user avatar
0 votes
0 answers
114 views

merging or removing duplicated lines on the border of an edge map

I'm trying to draw exactly one line on all the edges of an image. I was able to draw the lines but some of the lines are repeated and I'm stuck on it for days, any help would be appreciated. I tried ...
Rastaw's user avatar
  • 1
0 votes
0 answers
109 views

Time series of cluster analysis spatiotemporal python

I want to cluster patterns based on three meteorological fields. Each field has the shape 31, 137, 181 (31 timesteps, 137 latitudes, 181 longitudes) and I want a spatial maps of clusters for each ...
scriptgirl_3000's user avatar
0 votes
1 answer
134 views

AttributeError with Scikit-Learn 'list' object has no attribute 'shape' even though I've verified the input is a numpy array

When running this function def evaluate_performance(self, data): data = np.array(data) print(data.shape[0]) if self.cluster_method == 'kmeans': predicted_labels = ...
AbhishekRaoC's user avatar
0 votes
0 answers
87 views

K-means clustering in R studio with 30+ microbiome samples

I have 33 samples containing microbiome community data. I have used the full_join command to combine all 33 samples into one dataframe. The dataframe looks like this: Samp1 Samp2 Samp3 Samp4 ...
Alex Gomez's user avatar
0 votes
0 answers
93 views

how does wav2vec2 quantize continuous speech deterministically

I am trying to understand the wav2vec2 paper better. I understand that the raw signal is passed through a feature encoder which outputs latent speech representation which is continuous. Then it is ...
afsara_ben's user avatar
0 votes
0 answers
38 views

Influence of points and coordinates on the KMeans calculation

I'm defining spatial domains with KMeans. But when I use table columns that contain coordinates or the number of each point, it generates different results than when I simply use the values of each ...
Ferretto's user avatar
-1 votes
1 answer
158 views

AzureML - How to create a web service from a clustering model

I've created an Inference Pipeline that clusters a set of data using K-means. When run from the designer it works fine and returns cluster assignments for the input data. Once deployed as a web ...
Simon's user avatar
  • 9
1 vote
0 answers
82 views

Need help fixing my K-means clustering on MRI-data Python script

I'm using KMeans clustering from the scikitlearn module, and nibabel to load and save nifti files. I want to: Load a nifti file Perform KMeans clustering on the data of this nifti file (acquired by ...
Björn's user avatar
  • 11
0 votes
0 answers
101 views

clustering using k-means/ k-means++, for data with geolocation

I need to define spatial domains over various types of data collected in my field of study. Each collection is performed at a georeferenced point. So I need to define the spatial domains through ...
Ferretto's user avatar
0 votes
1 answer
50 views

How to access Object values in Python

For this function: def kmeans(examples, k, verbose = False): #Get k randomly chosen initial centroids, create cluster for each initialCentroids = random.sample(examples, k) clusters = [] ...
Jesse Garcia's user avatar
1 vote
1 answer
265 views

Get number of pixels in clusters with same color in an image

I have a black and white image where I want to count the pixels in each white spot (cluster). I am lost and I think it's missing just something I cant't think of. The Image looks like this: enter ...
Dave Whatever's user avatar
0 votes
1 answer
108 views

Python code for this algorithm to identify outliers in k-means clustering

The have an input_df which has stirng index and not integers. The index could be anything like '1234a', 'abcd', and so on. I have performed k-means on an input df with k = 100 and have received ...
Ash's user avatar
  • 385
0 votes
0 answers
30 views

R k-means cluster with pearson (ClusterR)

I'm trying to replicate a feature in Systat, which is k-means clustering with Pearson correlation.I've attempted to use the package called ClusterR as it allows me to modify some parameters. I have a ...
Stef's user avatar
  • 1
0 votes
0 answers
93 views

K-Means Clustering with R MARKDOWN

I work for big a fashion retailer and I am creating clusters of customers depending on their purchase patterns. I perform this clustering using K-Means in a RMarkdown file, to be able to run an "...
KarlGitihub's user avatar
1 vote
0 answers
120 views

Clustering base on weights and distance

I created this algorithm to make a route for each agent every day so that each agent can 22 close retailers he shall visit today. The code: def clustering(df): route_size = 22 df_with_cluster =...
Esmael Maher's user avatar
0 votes
0 answers
172 views

Why is this scatter plot not scatter? Instead it is in a perfect line

When I try to plot a clustering algorithm following this tutorial the following scatter plot is plotted. I've used my own dataset rather than trying on the provided data. What could be the possible ...
Rocky Armany's user avatar
1 vote
0 answers
323 views

K-means clustering with constraints

The context is as follows: I am tasked to re-cluster a vending machine company's vending machine routes (they're more so areas that each serviceman is responsible for). I have geocoded the lon/lat ...
mdbr2407's user avatar
0 votes
1 answer
160 views

How to make KMeans Clustering more Meaningful for Titanic Data?

I'm running this code. import pandas as pd titanic = pd.read_csv('titanic.csv') titanic.head() #Import required module from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.cluster ...
ASH's user avatar
  • 19.8k
0 votes
1 answer
167 views

Library to cluster circular data

I have an array of data that describes the number of people at a restaurant which is also a nightclub. The data distribution is as follows: I assume customer distributions to be approximately ...
masteryoda436's user avatar
1 vote
0 answers
104 views

K-means clustering with Pearson_Correlation

I'm trying to replicate a feature in Systat, which is k-means clustering with Pearson correlation. I saw that a package called ClusterR allows you to do this by specifying a bunch of parameters. I ...
StephenRappaport's user avatar
2 votes
2 answers
4k views

Python:: Sklearn OpenBLAS Error for KMeans

I get the following error when I try to use Kmeans: kmeans = KMeans(init='k-means++', n_clusters=numClusters, max_iter=100, n_init='auto') --------------------------------------------------------------...
P Ved's user avatar
  • 119
0 votes
0 answers
93 views

k-means clustering by blocks for large images

I'm trying to find a way to run a k-means clustering over a large image size (16GB) without loading the whole array into python. I already have a code that is able to read the image by blocks to make ...
David Montoya's user avatar
0 votes
1 answer
125 views

Error with ConsensusClusterPlus function and subsampling by pFeature parameter

The following function returns an error which I am unable to resolve. pl.eset <- matrix(runif(50*30), nrow=50, ncol=30) ConsensusClusterPlus::ConsensusClusterPlus(pl.eset, pFeature = 0.50, reps = ...
Mark's user avatar
  • 15

1 2
3
4 5
70