Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre How Similar are the Results? | Hierarchical Clustering
Cluster Analysis in Python
course content

Contenu du cours

Cluster Analysis in Python

Cluster Analysis in Python

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

book
How Similar are the Results?

Well done! Let's look at the last line charts you built in the previous chapter.

As you can see, only the ward linkage could catch the 'downward up to July' trend. Both results are different. But let's find out how different they are using the rand index.

Tâche

Swipe to start coding

Table

Compute the rand index to compare the results of using complete and ward linkages. Follow the next steps:

  1. Import functions needed:
  • rand_score from sklearn.metrics.
  • AgglomerativeClustering from sklearn.cluster.
  1. Create two models model_complete and model_ward performing a hierarchical clustering with 4 clusters both and 'complete' and 'ward' linkages respectively.
  2. Fit the 3-14 columns of data to models and predict the labels. Save the labels for model_complete within labels_complete and for model_ward within labels_ward.
  3. Compute the rand index using labels_complete and labels_ward.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 8
toggle bottom row

book
How Similar are the Results?

Well done! Let's look at the last line charts you built in the previous chapter.

As you can see, only the ward linkage could catch the 'downward up to July' trend. Both results are different. But let's find out how different they are using the rand index.

Tâche

Swipe to start coding

Table

Compute the rand index to compare the results of using complete and ward linkages. Follow the next steps:

  1. Import functions needed:
  • rand_score from sklearn.metrics.
  • AgglomerativeClustering from sklearn.cluster.
  1. Create two models model_complete and model_ward performing a hierarchical clustering with 4 clusters both and 'complete' and 'ward' linkages respectively.
  2. Fit the 3-14 columns of data to models and predict the labels. Save the labels for model_complete within labels_complete and for model_ward within labels_ward.
  3. Compute the rand index using labels_complete and labels_ward.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 8
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt