Skip to content
Advertisement

Tag: k-means

How to print KMeans intiatial parameters?

I am using PyCharm to run Kmeans using Iris data. When I run this, simply prints KMeans() But I would like it to print the following: How can this be accomplished? Answer Simply run kmeans.get_params(). This will print out the parameters (default or custom) used while instantiating the function in a dictionary format. Please refer this link for more information.

Kmean clustering top terms in cluster

I am using python Kmean clustering algorithm for cluster document. I have created a term-document matrix Then I applied Kmean clustering using following code My next task is to see the top terms in every cluster, searching on googole suggested that many of the people has used the km.cluster_centers_.argsort()[:, ::-1] for finding the top term in the clusters using the

How to use Scikit kmeans when I have a dataframe

I have converted my dataset to dataframe. I was wondering how to use it in scikit kmeans or if any other kmeans package available. Answer sklearn is fully compatible with pandas DataFrames. Therefore, it’s as simple as: That 0.6 means you use 60% of your data for training, 40% for testing. More info here: http://scikit-learn.org/stable/modules/generated/sklearn.cross_validation.train_test_split.html http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html

Advertisement