Conteúdo do Curso
Cluster Analysis in Python
Cluster Analysis in Python
Visualizing the Dynamics Across Clusters
The selective pair of months on the scatter plot looked good, didn't it? Maybe there were no key differences between 'areas' on the plot, but at least there were no outliers outside the respective groups, and in general, all groups were disjoint.
Finally, let's find out the yearly dynamics for each cluster, i.e. let's build the line plot representing the monthly averages for each group of points.
Tarefa
- Extract the necessary columns (month's names and temperatures) within the
col
variable:
- Firstly, extract the 2-13 column names as
list
type, and save them within thecol
variable. - Then add the
'prediction'
string to the listcol
.
- Calculate the monthly average temperatures for each cluster, and save the result within
monthly_data
variable:
- Firstly group the observations of
col
column ofdata
by'prediction'
. - Then calculate
.mean()
of grouped table. - Then apply
.stack()
to stack the table (already done). - Finally reset the indices using
.reset_index()
method.
- Assign list
['Group', 'Month', 'Temp']
as column names for transformed data withinmonthly_data
variable. - Build the line plot
'Month'
vs'Temp'
for eachGroup
usingmonthly_data
DataFrame.
Obrigado pelo seu feedback!
Visualizing the Dynamics Across Clusters
The selective pair of months on the scatter plot looked good, didn't it? Maybe there were no key differences between 'areas' on the plot, but at least there were no outliers outside the respective groups, and in general, all groups were disjoint.
Finally, let's find out the yearly dynamics for each cluster, i.e. let's build the line plot representing the monthly averages for each group of points.
Tarefa
- Extract the necessary columns (month's names and temperatures) within the
col
variable:
- Firstly, extract the 2-13 column names as
list
type, and save them within thecol
variable. - Then add the
'prediction'
string to the listcol
.
- Calculate the monthly average temperatures for each cluster, and save the result within
monthly_data
variable:
- Firstly group the observations of
col
column ofdata
by'prediction'
. - Then calculate
.mean()
of grouped table. - Then apply
.stack()
to stack the table (already done). - Finally reset the indices using
.reset_index()
method.
- Assign list
['Group', 'Month', 'Temp']
as column names for transformed data withinmonthly_data
variable. - Build the line plot
'Month'
vs'Temp'
for eachGroup
usingmonthly_data
DataFrame.
Obrigado pelo seu feedback!
Visualizing the Dynamics Across Clusters
The selective pair of months on the scatter plot looked good, didn't it? Maybe there were no key differences between 'areas' on the plot, but at least there were no outliers outside the respective groups, and in general, all groups were disjoint.
Finally, let's find out the yearly dynamics for each cluster, i.e. let's build the line plot representing the monthly averages for each group of points.
Tarefa
- Extract the necessary columns (month's names and temperatures) within the
col
variable:
- Firstly, extract the 2-13 column names as
list
type, and save them within thecol
variable. - Then add the
'prediction'
string to the listcol
.
- Calculate the monthly average temperatures for each cluster, and save the result within
monthly_data
variable:
- Firstly group the observations of
col
column ofdata
by'prediction'
. - Then calculate
.mean()
of grouped table. - Then apply
.stack()
to stack the table (already done). - Finally reset the indices using
.reset_index()
method.
- Assign list
['Group', 'Month', 'Temp']
as column names for transformed data withinmonthly_data
variable. - Build the line plot
'Month'
vs'Temp'
for eachGroup
usingmonthly_data
DataFrame.
Obrigado pelo seu feedback!
The selective pair of months on the scatter plot looked good, didn't it? Maybe there were no key differences between 'areas' on the plot, but at least there were no outliers outside the respective groups, and in general, all groups were disjoint.
Finally, let's find out the yearly dynamics for each cluster, i.e. let's build the line plot representing the monthly averages for each group of points.
Tarefa
- Extract the necessary columns (month's names and temperatures) within the
col
variable:
- Firstly, extract the 2-13 column names as
list
type, and save them within thecol
variable. - Then add the
'prediction'
string to the listcol
.
- Calculate the monthly average temperatures for each cluster, and save the result within
monthly_data
variable:
- Firstly group the observations of
col
column ofdata
by'prediction'
. - Then calculate
.mean()
of grouped table. - Then apply
.stack()
to stack the table (already done). - Finally reset the indices using
.reset_index()
method.
- Assign list
['Group', 'Month', 'Temp']
as column names for transformed data withinmonthly_data
variable. - Build the line plot
'Month'
vs'Temp'
for eachGroup
usingmonthly_data
DataFrame.