Course Content
Cluster Analysis in Python
Cluster Analysis in Python
Mean Yearly Temperatures Across Clusters
The last chart we got was even harder to interpret than two chapters ago. But if we are talking about 'peeks', the number 4 best fits it.
Let's compare the yearly average temperatures across 4 predicted clusters.
Task
Calculate the yearly average temperatures across each cluster. The structure of data
is shown below.
[object Object]
Follow the next steps:
- Create a
KMedoids
model with 4 clusters namedmodel
. - Fit the 3-15 (these are positions, not indices) columns of
data
tomodel
. - Add the
'prediction'
column todata
with predicted bymodel
labels. - Group the
data
DataFrame by theprediction
column, then apply the.mean()
function twice: the first call will calculate the monthly means, the second one (withaxis = 1
) will calculate the yearly averages.
Thanks for your feedback!
Mean Yearly Temperatures Across Clusters
The last chart we got was even harder to interpret than two chapters ago. But if we are talking about 'peeks', the number 4 best fits it.
Let's compare the yearly average temperatures across 4 predicted clusters.
Task
Calculate the yearly average temperatures across each cluster. The structure of data
is shown below.
[object Object]
Follow the next steps:
- Create a
KMedoids
model with 4 clusters namedmodel
. - Fit the 3-15 (these are positions, not indices) columns of
data
tomodel
. - Add the
'prediction'
column todata
with predicted bymodel
labels. - Group the
data
DataFrame by theprediction
column, then apply the.mean()
function twice: the first call will calculate the monthly means, the second one (withaxis = 1
) will calculate the yearly averages.
Thanks for your feedback!
Mean Yearly Temperatures Across Clusters
The last chart we got was even harder to interpret than two chapters ago. But if we are talking about 'peeks', the number 4 best fits it.
Let's compare the yearly average temperatures across 4 predicted clusters.
Task
Calculate the yearly average temperatures across each cluster. The structure of data
is shown below.
[object Object]
Follow the next steps:
- Create a
KMedoids
model with 4 clusters namedmodel
. - Fit the 3-15 (these are positions, not indices) columns of
data
tomodel
. - Add the
'prediction'
column todata
with predicted bymodel
labels. - Group the
data
DataFrame by theprediction
column, then apply the.mean()
function twice: the first call will calculate the monthly means, the second one (withaxis = 1
) will calculate the yearly averages.
Thanks for your feedback!
The last chart we got was even harder to interpret than two chapters ago. But if we are talking about 'peeks', the number 4 best fits it.
Let's compare the yearly average temperatures across 4 predicted clusters.
Task
Calculate the yearly average temperatures across each cluster. The structure of data
is shown below.
[object Object]
Follow the next steps:
- Create a
KMedoids
model with 4 clusters namedmodel
. - Fit the 3-15 (these are positions, not indices) columns of
data
tomodel
. - Add the
'prediction'
column todata
with predicted bymodel
labels. - Group the
data
DataFrame by theprediction
column, then apply the.mean()
function twice: the first call will calculate the monthly means, the second one (withaxis = 1
) will calculate the yearly averages.