k-means

OpenCV - How to apply Kmeans on a grayscale image?

我怕爱的太早我们不能终老 提交于 2021-01-29 13:17:52
问题 I am trying to cluster a grayscale image using Kmeans. First, I have a question: Is Kmeans the best way to cluster a Mat or are there newer more efficient approaches? Second, when I try this: Mat degrees = imread("an image" , IMREAD_GRAYSCALE); const unsigned int singleLineSize = degrees.rows * degrees.cols; Mat data = degrees.reshape(1, singleLineSize); data.convertTo(data, CV_32F); std::vector<int> labels; cv::Mat1f colors; cv::kmeans(data, 3, labels, cv::TermCriteria(cv::TermCriteria::EPS

KMeans clustering unbalanced data

只谈情不闲聊 提交于 2021-01-28 18:57:55
问题 I have a set of data with 50 features (c1, c2, c3 ...), with over 80k rows. Each row contains normalised numerical values (ranging 0-1). It is actually a normalised dummy variable, whereby some rows have only few features, 3-4 (i.e. 0 is assigned if there is no value). Most rows have about 10-20 features. I used KMeans to cluster the data, always resulting in a cluster with a large number of members. Upon analysis, I noticed that rows with fewer than 4 features tends to get clustered together

How does sklearn.cluster.KMeans handle an init ndarray parameter with missing centroids (available centroids less than n_clusters)?

蹲街弑〆低调 提交于 2021-01-28 12:12:49
问题 In Python sklearn KMeans (see documentation), I was wondering what happens internally when passing an ndarray of shape (n, n_features) to the init parameter, When n<n_clusters Does it drop the given centroids and just starts a kmeans++ initialization which is the default choice for the init parameter ? (PDF paper kmeans++) (How does Kmeans++ work) Does it consider the given centroids and fill accordingly the remaining centroids using kmeans++ ? Does it consider the given centroids and fill

When using the K-Means Clustering Algorithm, is it possible to have a set of data which results in an Infinite Loop?

大城市里の小女人 提交于 2021-01-07 03:13:28
问题 This Question is more Theoretical, and not specifically trying to problem-solve. I recently was introduced to the K-Means Clustering algorithm, and unsupervised machine learning algorithm, and I was intrigued by the though that one some sets of data, even if completely random, the average centroids drawn could keep changing through each iteration. Example: What I am trying to show here, is, imagine if the program flipped between iteration 6, to iteration 9, and kept doing this forever. I have

Define k-1 cluster centroids — SKlearn KMeans

别说谁变了你拦得住时间么 提交于 2021-01-05 08:57:39
问题 I am performing a binary classification of a partially labeled dataset. I have a reliable estimate of its 1's, but not of its 0's. From sklearn KMeans documentation: init : {‘k-means++’, ‘random’ or an ndarray} Method for initialization, defaults to ‘k-means++’: If an ndarray is passed, it should be of shape (n_clusters, n_features) and gives the initial centers. I would like to pass an ndarray, but I only have 1 reliable centroid, not 2. Is there a way to maximize the entropy between the K

Define k-1 cluster centroids — SKlearn KMeans

烈酒焚心 提交于 2021-01-05 08:56:43
问题 I am performing a binary classification of a partially labeled dataset. I have a reliable estimate of its 1's, but not of its 0's. From sklearn KMeans documentation: init : {‘k-means++’, ‘random’ or an ndarray} Method for initialization, defaults to ‘k-means++’: If an ndarray is passed, it should be of shape (n_clusters, n_features) and gives the initial centers. I would like to pass an ndarray, but I only have 1 reliable centroid, not 2. Is there a way to maximize the entropy between the K

How to view cluster centroids for each iteration of n_init using skleans' KMeans

血红的双手。 提交于 2020-12-31 05:15:58
问题 I am currently trying to view the created centroids(cluster centers) for each iteration of KMeans that is determined from each iteration of n_init. As of now I am able to view the final results but I would like to see these at each iteration so I am able to report the differences of KMeans when using init='random' and preset cluster centers at each iteration. The following is a brief example of what I currently have \ #Creating model for Kmeans Model=[] Model=KMeans(n_clusters=5,max_iter=10,n

How to view cluster centroids for each iteration of n_init using skleans' KMeans

倾然丶 夕夏残阳落幕 提交于 2020-12-31 05:12:36
问题 I am currently trying to view the created centroids(cluster centers) for each iteration of KMeans that is determined from each iteration of n_init. As of now I am able to view the final results but I would like to see these at each iteration so I am able to report the differences of KMeans when using init='random' and preset cluster centers at each iteration. The following is a brief example of what I currently have \ #Creating model for Kmeans Model=[] Model=KMeans(n_clusters=5,max_iter=10,n

How to view cluster centroids for each iteration of n_init using skleans' KMeans

无人久伴 提交于 2020-12-31 05:12:02
问题 I am currently trying to view the created centroids(cluster centers) for each iteration of KMeans that is determined from each iteration of n_init. As of now I am able to view the final results but I would like to see these at each iteration so I am able to report the differences of KMeans when using init='random' and preset cluster centers at each iteration. The following is a brief example of what I currently have \ #Creating model for Kmeans Model=[] Model=KMeans(n_clusters=5,max_iter=10,n

How to view cluster centroids for each iteration of n_init using skleans' KMeans

自闭症网瘾萝莉.ら 提交于 2020-12-31 05:11:21
问题 I am currently trying to view the created centroids(cluster centers) for each iteration of KMeans that is determined from each iteration of n_init. As of now I am able to view the final results but I would like to see these at each iteration so I am able to report the differences of KMeans when using init='random' and preset cluster centers at each iteration. The following is a brief example of what I currently have \ #Creating model for Kmeans Model=[] Model=KMeans(n_clusters=5,max_iter=10,n