Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Comparing the Dynamics | 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

Comparing the Dynamics

That's an interesting result! The yearly average temperatures across clusters significantly differ for 3 of them (47.3, 60.9, and 79.24). It seems like a good split.

Now let's visualize the monthly dynamics of average temperatures across clusters, and compare the result with the 5 clusters by the K-Means algorithm. The respective line plot is below.

Tarea

Visualize the monthly temperature dynamics across clusters. Follow the next steps:

  1. Import KMedoids function from sklearn_extra.cluster.
  2. Create a KMedoids object named model with 4 clusters.
  3. Fit the 3-15 columns (these are not indices, but positions) of data to model.
  4. Add the 'prediction' column to data with predicted by model labels.
  5. Calculate the monthly averages using data and save the result within the d DataFrame:
  • Group the observations by the 'prediction' column.
  • Calculate the mean values.
  • Stack the columns into indices (already done).
  • Reset the indices.
  1. Assign ['Group', 'Month', 'Temp'] as columns names of d.
  2. Build lineplot with 'Month' on the x-axis, 'Temp' on the y-axis for each 'Group' of d DataFrame (i.e. separate line and color for each 'Group').

Tarea

Visualize the monthly temperature dynamics across clusters. Follow the next steps:

  1. Import KMedoids function from sklearn_extra.cluster.
  2. Create a KMedoids object named model with 4 clusters.
  3. Fit the 3-15 columns (these are not indices, but positions) of data to model.
  4. Add the 'prediction' column to data with predicted by model labels.
  5. Calculate the monthly averages using data and save the result within the d DataFrame:
  • Group the observations by the 'prediction' column.
  • Calculate the mean values.
  • Stack the columns into indices (already done).
  • Reset the indices.
  1. Assign ['Group', 'Month', 'Temp'] as columns names of d.
  2. Build lineplot with 'Month' on the x-axis, 'Temp' on the y-axis for each 'Group' of d DataFrame (i.e. separate line and color for each 'Group').

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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

Comparing the Dynamics

That's an interesting result! The yearly average temperatures across clusters significantly differ for 3 of them (47.3, 60.9, and 79.24). It seems like a good split.

Now let's visualize the monthly dynamics of average temperatures across clusters, and compare the result with the 5 clusters by the K-Means algorithm. The respective line plot is below.

Tarea

Visualize the monthly temperature dynamics across clusters. Follow the next steps:

  1. Import KMedoids function from sklearn_extra.cluster.
  2. Create a KMedoids object named model with 4 clusters.
  3. Fit the 3-15 columns (these are not indices, but positions) of data to model.
  4. Add the 'prediction' column to data with predicted by model labels.
  5. Calculate the monthly averages using data and save the result within the d DataFrame:
  • Group the observations by the 'prediction' column.
  • Calculate the mean values.
  • Stack the columns into indices (already done).
  • Reset the indices.
  1. Assign ['Group', 'Month', 'Temp'] as columns names of d.
  2. Build lineplot with 'Month' on the x-axis, 'Temp' on the y-axis for each 'Group' of d DataFrame (i.e. separate line and color for each 'Group').

Tarea

Visualize the monthly temperature dynamics across clusters. Follow the next steps:

  1. Import KMedoids function from sklearn_extra.cluster.
  2. Create a KMedoids object named model with 4 clusters.
  3. Fit the 3-15 columns (these are not indices, but positions) of data to model.
  4. Add the 'prediction' column to data with predicted by model labels.
  5. Calculate the monthly averages using data and save the result within the d DataFrame:
  • Group the observations by the 'prediction' column.
  • Calculate the mean values.
  • Stack the columns into indices (already done).
  • Reset the indices.
  1. Assign ['Group', 'Month', 'Temp'] as columns names of d.
  2. Build lineplot with 'Month' on the x-axis, 'Temp' on the y-axis for each 'Group' of d DataFrame (i.e. separate line and color for each 'Group').

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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

Comparing the Dynamics

That's an interesting result! The yearly average temperatures across clusters significantly differ for 3 of them (47.3, 60.9, and 79.24). It seems like a good split.

Now let's visualize the monthly dynamics of average temperatures across clusters, and compare the result with the 5 clusters by the K-Means algorithm. The respective line plot is below.

Tarea

Visualize the monthly temperature dynamics across clusters. Follow the next steps:

  1. Import KMedoids function from sklearn_extra.cluster.
  2. Create a KMedoids object named model with 4 clusters.
  3. Fit the 3-15 columns (these are not indices, but positions) of data to model.
  4. Add the 'prediction' column to data with predicted by model labels.
  5. Calculate the monthly averages using data and save the result within the d DataFrame:
  • Group the observations by the 'prediction' column.
  • Calculate the mean values.
  • Stack the columns into indices (already done).
  • Reset the indices.
  1. Assign ['Group', 'Month', 'Temp'] as columns names of d.
  2. Build lineplot with 'Month' on the x-axis, 'Temp' on the y-axis for each 'Group' of d DataFrame (i.e. separate line and color for each 'Group').

Tarea

Visualize the monthly temperature dynamics across clusters. Follow the next steps:

  1. Import KMedoids function from sklearn_extra.cluster.
  2. Create a KMedoids object named model with 4 clusters.
  3. Fit the 3-15 columns (these are not indices, but positions) of data to model.
  4. Add the 'prediction' column to data with predicted by model labels.
  5. Calculate the monthly averages using data and save the result within the d DataFrame:
  • Group the observations by the 'prediction' column.
  • Calculate the mean values.
  • Stack the columns into indices (already done).
  • Reset the indices.
  1. Assign ['Group', 'Month', 'Temp'] as columns names of d.
  2. Build lineplot with 'Month' on the x-axis, 'Temp' on the y-axis for each 'Group' of d DataFrame (i.e. separate line and color for each 'Group').

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

That's an interesting result! The yearly average temperatures across clusters significantly differ for 3 of them (47.3, 60.9, and 79.24). It seems like a good split.

Now let's visualize the monthly dynamics of average temperatures across clusters, and compare the result with the 5 clusters by the K-Means algorithm. The respective line plot is below.

Tarea

Visualize the monthly temperature dynamics across clusters. Follow the next steps:

  1. Import KMedoids function from sklearn_extra.cluster.
  2. Create a KMedoids object named model with 4 clusters.
  3. Fit the 3-15 columns (these are not indices, but positions) of data to model.
  4. Add the 'prediction' column to data with predicted by model labels.
  5. Calculate the monthly averages using data and save the result within the d DataFrame:
  • Group the observations by the 'prediction' column.
  • Calculate the mean values.
  • Stack the columns into indices (already done).
  • Reset the indices.
  1. Assign ['Group', 'Month', 'Temp'] as columns names of d.
  2. Build lineplot with 'Month' on the x-axis, 'Temp' on the y-axis for each 'Group' of d DataFrame (i.e. separate line and color for each 'Group').

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 6
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt