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.
Cet exercice fait partie du cours
Cluster Analysis in Python
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_wageis the column name that stores the wages of a player in Euros.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Print the size of the clusters
print(fifa.____(____)['ID'].count())
# Print the mean value of wages in each cluster
print(fifa.____(____)['eur_wage'].____())