1. Learn
  2. /
  3. Courses
  4. /
  5. Cluster Analysis in Python

Exercise

Basic checks on clusters

In the FIFA 18 dataset, we have concentrated on defenders in previous exercises. Let us try to focus on attacking attributes of a player. Pace (pac), Dribbling (dri) and Shooting (sho) are features that are present in attack minded players. In this exercise, k-means clustering has already been applied on the data using the scaled values of these three attributes. Try some basic checks on the clusters so formed.

The data is stored in a pandas DataFrame, fifa. The scaled column names are present in a list scaled_features. The cluster labels are stored in the cluster_labels column. Recall the .count() and .mean() methods in pandas help you find the number of observations and mean of observations in a DataFrame.

Instructions

100 XP
  • Print the size of the clusters by grouping the column cluster_labels.
  • Print the mean values of the wages of the players in each cluster. eur_wage is the column name that stores the wages of a player in Euros.