IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Cluster Analysis in Python

Visualizza il corso

Istruzioni dell'esercizio

  • 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.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Print the size of the clusters
print(fifa.____(____)['ID'].count())

# Print the mean value of wages in each cluster
print(fifa.____(____)['eur_wage'].____())
Modifica ed esegui il codice