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.
Swipe to start coding

Compute the rand index to compare the results of using complete and ward linkages. Follow the next steps:
- Import functions needed:
rand_score
fromsklearn.metrics
.AgglomerativeClustering
fromsklearn.cluster
.
- Create two models
model_complete
andmodel_ward
performing a hierarchical clustering with 4 clusters both and'complete'
and'ward'
linkages respectively. - Fit the 3-14 columns of
data
to models and predict the labels. Save the labels formodel_complete
withinlabels_complete
and formodel_ward
withinlabels_ward
. - Compute the rand index using
labels_complete
andlabels_ward
.
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Zusammenfassen Sie dieses Kapitel
Code in file erklären
Erklären, warum file die Aufgabe nicht löst
Awesome!
Completion rate improved to 3.57
How Similar are the Results?
Swipe um das Menü anzuzeigen
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.
Swipe to start coding

Compute the rand index to compare the results of using complete and ward linkages. Follow the next steps:
- Import functions needed:
rand_score
fromsklearn.metrics
.AgglomerativeClustering
fromsklearn.cluster
.
- Create two models
model_complete
andmodel_ward
performing a hierarchical clustering with 4 clusters both and'complete'
and'ward'
linkages respectively. - Fit the 3-14 columns of
data
to models and predict the labels. Save the labels formodel_complete
withinlabels_complete
and formodel_ward
withinlabels_ward
. - Compute the rand index using
labels_complete
andlabels_ward
.
Lösung
Danke für Ihr Feedback!
Awesome!
Completion rate improved to 3.57single