Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Weather Data: Complete and Ward Linkages | Hierarchical Clustering
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

Weather Data: Complete and Ward Linkages

The last chart was good, but if you remember the K-Means and K-Medoids algorithms results, you may remember that there was at least one more line that unlike all the others goes downwards close to July. The average linkage in hierarchical clustering didn't catch that dynamic.

We saw that for complete and ward linkages there is sense to consider 4 clusters. Let's find out will they catch that?

Tarea

Table
  1. Import numpy with np alias.
  2. Iterate over the linkages list. At each step:
  • Create a hierarchical clustering model with 4 clusters and method j named model.
  • Fit the numerical data of temp and predict the labels. Add predicted labels as the 'prediction' column to temp.
  • Create a temp_res DataFrame with monthly averages for each group. To do it group the values of temp by the 'prediction' column, calculate the mean, and then apply the .stack() method.
  • Add column 'method' to temp_res DataFrame with value j being repeated the number of rows in temp_res times.
  • Merge res and temp_res dataframes using .concat function of pd.
  1. Reassign the column names of res to ['Group', 'Month', 'Temp', "Method"].
  2. Within the FacetGrid function set the col parameter to 'Method'. This will build a separate chart for each value of the 'Method' column.
  3. Within the .map function set the seaborn line plot function as the first parameter.

Tarea

Table
  1. Import numpy with np alias.
  2. Iterate over the linkages list. At each step:
  • Create a hierarchical clustering model with 4 clusters and method j named model.
  • Fit the numerical data of temp and predict the labels. Add predicted labels as the 'prediction' column to temp.
  • Create a temp_res DataFrame with monthly averages for each group. To do it group the values of temp by the 'prediction' column, calculate the mean, and then apply the .stack() method.
  • Add column 'method' to temp_res DataFrame with value j being repeated the number of rows in temp_res times.
  • Merge res and temp_res dataframes using .concat function of pd.
  1. Reassign the column names of res to ['Group', 'Month', 'Temp', "Method"].
  2. Within the FacetGrid function set the col parameter to 'Method'. This will build a separate chart for each value of the 'Method' column.
  3. Within the .map function set the seaborn line plot function as the first parameter.

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 3. Capítulo 7
toggle bottom row

Weather Data: Complete and Ward Linkages

The last chart was good, but if you remember the K-Means and K-Medoids algorithms results, you may remember that there was at least one more line that unlike all the others goes downwards close to July. The average linkage in hierarchical clustering didn't catch that dynamic.

We saw that for complete and ward linkages there is sense to consider 4 clusters. Let's find out will they catch that?

Tarea

Table
  1. Import numpy with np alias.
  2. Iterate over the linkages list. At each step:
  • Create a hierarchical clustering model with 4 clusters and method j named model.
  • Fit the numerical data of temp and predict the labels. Add predicted labels as the 'prediction' column to temp.
  • Create a temp_res DataFrame with monthly averages for each group. To do it group the values of temp by the 'prediction' column, calculate the mean, and then apply the .stack() method.
  • Add column 'method' to temp_res DataFrame with value j being repeated the number of rows in temp_res times.
  • Merge res and temp_res dataframes using .concat function of pd.
  1. Reassign the column names of res to ['Group', 'Month', 'Temp', "Method"].
  2. Within the FacetGrid function set the col parameter to 'Method'. This will build a separate chart for each value of the 'Method' column.
  3. Within the .map function set the seaborn line plot function as the first parameter.

Tarea

Table
  1. Import numpy with np alias.
  2. Iterate over the linkages list. At each step:
  • Create a hierarchical clustering model with 4 clusters and method j named model.
  • Fit the numerical data of temp and predict the labels. Add predicted labels as the 'prediction' column to temp.
  • Create a temp_res DataFrame with monthly averages for each group. To do it group the values of temp by the 'prediction' column, calculate the mean, and then apply the .stack() method.
  • Add column 'method' to temp_res DataFrame with value j being repeated the number of rows in temp_res times.
  • Merge res and temp_res dataframes using .concat function of pd.
  1. Reassign the column names of res to ['Group', 'Month', 'Temp', "Method"].
  2. Within the FacetGrid function set the col parameter to 'Method'. This will build a separate chart for each value of the 'Method' column.
  3. Within the .map function set the seaborn line plot function as the first parameter.

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 3. Capítulo 7
toggle bottom row

Weather Data: Complete and Ward Linkages

The last chart was good, but if you remember the K-Means and K-Medoids algorithms results, you may remember that there was at least one more line that unlike all the others goes downwards close to July. The average linkage in hierarchical clustering didn't catch that dynamic.

We saw that for complete and ward linkages there is sense to consider 4 clusters. Let's find out will they catch that?

Tarea

Table
  1. Import numpy with np alias.
  2. Iterate over the linkages list. At each step:
  • Create a hierarchical clustering model with 4 clusters and method j named model.
  • Fit the numerical data of temp and predict the labels. Add predicted labels as the 'prediction' column to temp.
  • Create a temp_res DataFrame with monthly averages for each group. To do it group the values of temp by the 'prediction' column, calculate the mean, and then apply the .stack() method.
  • Add column 'method' to temp_res DataFrame with value j being repeated the number of rows in temp_res times.
  • Merge res and temp_res dataframes using .concat function of pd.
  1. Reassign the column names of res to ['Group', 'Month', 'Temp', "Method"].
  2. Within the FacetGrid function set the col parameter to 'Method'. This will build a separate chart for each value of the 'Method' column.
  3. Within the .map function set the seaborn line plot function as the first parameter.

Tarea

Table
  1. Import numpy with np alias.
  2. Iterate over the linkages list. At each step:
  • Create a hierarchical clustering model with 4 clusters and method j named model.
  • Fit the numerical data of temp and predict the labels. Add predicted labels as the 'prediction' column to temp.
  • Create a temp_res DataFrame with monthly averages for each group. To do it group the values of temp by the 'prediction' column, calculate the mean, and then apply the .stack() method.
  • Add column 'method' to temp_res DataFrame with value j being repeated the number of rows in temp_res times.
  • Merge res and temp_res dataframes using .concat function of pd.
  1. Reassign the column names of res to ['Group', 'Month', 'Temp', "Method"].
  2. Within the FacetGrid function set the col parameter to 'Method'. This will build a separate chart for each value of the 'Method' column.
  3. Within the .map function set the seaborn line plot function as the first parameter.

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

¿Todo estuvo claro?

The last chart was good, but if you remember the K-Means and K-Medoids algorithms results, you may remember that there was at least one more line that unlike all the others goes downwards close to July. The average linkage in hierarchical clustering didn't catch that dynamic.

We saw that for complete and ward linkages there is sense to consider 4 clusters. Let's find out will they catch that?

Tarea

Table
  1. Import numpy with np alias.
  2. Iterate over the linkages list. At each step:
  • Create a hierarchical clustering model with 4 clusters and method j named model.
  • Fit the numerical data of temp and predict the labels. Add predicted labels as the 'prediction' column to temp.
  • Create a temp_res DataFrame with monthly averages for each group. To do it group the values of temp by the 'prediction' column, calculate the mean, and then apply the .stack() method.
  • Add column 'method' to temp_res DataFrame with value j being repeated the number of rows in temp_res times.
  • Merge res and temp_res dataframes using .concat function of pd.
  1. Reassign the column names of res to ['Group', 'Month', 'Temp', "Method"].
  2. Within the FacetGrid function set the col parameter to 'Method'. This will build a separate chart for each value of the 'Method' column.
  3. Within the .map function set the seaborn line plot function as the first parameter.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 3. Capítulo 7
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