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.
This exercise is part of the course
Cluster Analysis in Python
Exercise instructions
- 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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Print the size of the clusters
print(fifa.____(____)['ID'].count())
# Print the mean value of wages in each cluster
print(fifa.____(____)['eur_wage'].____())