Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende K-Medoids and the Weather Data | K-Medoids Algorithm
Cluster Analysis in Python
course content

Contenido del Curso

Cluster Analysis in Python

Cluster Analysis in Python

1. K-Means Algorithm
2. K-Medoids Algorithm
3. Hierarchical Clustering
4. Spectral Clustering

book
K-Medoids and the Weather Data

As you can see, there was no such clear peek as in the example. That means that both 3 and 4 clusters may be a good choice!

Let's see what will be the result of using the K-Medoids algorithm for the weather data we used in the previous section. Let's start with defining the optimal number of clusters.

Tarea

Swipe to start coding

Given cities' average temperatures dataset data. The numerical columns are 3 - 14. Table

Your tasks are:

  1. Using for loop iterate over n_cl. Within the loop:
  • Create KMedoids model with j clusters named model.
  • Fit the 2-15 columns of data to the model. Watch out that indices in Python start from 0.
  • Add silhouette score value to the silhouettes list. Remember to pass two parameters: the data used for fitting (the same 3-15 columns) and predicted by model labels.
  1. Visualize the results using lineplot of sns. Pass n_cl as x parameter and silhouettes as y. Do not forget to apply the .show() method to display the plot.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 4
toggle bottom row

book
K-Medoids and the Weather Data

As you can see, there was no such clear peek as in the example. That means that both 3 and 4 clusters may be a good choice!

Let's see what will be the result of using the K-Medoids algorithm for the weather data we used in the previous section. Let's start with defining the optimal number of clusters.

Tarea

Swipe to start coding

Given cities' average temperatures dataset data. The numerical columns are 3 - 14. Table

Your tasks are:

  1. Using for loop iterate over n_cl. Within the loop:
  • Create KMedoids model with j clusters named model.
  • Fit the 2-15 columns of data to the model. Watch out that indices in Python start from 0.
  • Add silhouette score value to the silhouettes list. Remember to pass two parameters: the data used for fitting (the same 3-15 columns) and predicted by model labels.
  1. Visualize the results using lineplot of sns. Pass n_cl as x parameter and silhouettes as y. Do not forget to apply the .show() method to display the plot.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 4
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Lamentamos que algo salió mal. ¿Qué pasó?
some-alt