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.
Deze oefening maakt deel uit van de cursus
Cluster Analysis in Python
Oefeninstructies
- 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.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Print the size of the clusters
print(fifa.____(____)['ID'].count())
# Print the mean value of wages in each cluster
print(fifa.____(____)['eur_wage'].____())