Get startedGet started for free

Results of kmeans()

The kmeans() function produces several outputs. In the video, we discussed one output of modeling, the cluster membership.

In this exercise, you will access the cluster component directly. This is useful anytime you need the cluster membership for each observation of the data used to build the clustering model. A future exercise will show an example of how this cluster membership might be used to help communicate the results of k-means modeling.

k-means models also have a print method to give a human friendly output of basic modeling results. This is available by using print() or simply typing the name of the model.

This exercise is part of the course

Unsupervised Learning in R

View Course

Exercise instructions

The k-means model you built in the last exercise, km.out, is still available in your workspace.

  • Print a list of the cluster membership to the console.
  • Use a print method to print out the km.out model.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Print the cluster membership component of the model


# Print the km.out object
Edit and Run Code