Clustermap
A clustermap
is a matrix plot with a heatmap and two clustering dendrograms (learn more: Machine Learning).







Tehtävä
Swipe to start coding
- Create the
clustermap
using theseaborn
library:
- Add the data for the
clustermap
. Input only the name of the DataFrame; - Set the
'vlag'
cmap
; - Set the
standard_scale
parameter equals1
; - Set the
'single'
method
parameter; - Set the
'correlation'
metric
parameter; - Add the
annot
; - Set the
vmin
parameter equals0
andvmax
parameter equals10
; - Display the plot.
Ratkaisu
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/flights.csv')
upd_df = df.pivot_table(index='month', columns='year', values='passengers')
# Create a clustermap
sns.clustermap(# Add the data for the cluster
upd_df,
# Set the cmap
cmap = 'vlag',
# Set the standard_scale
standard_scale = 1,
# Set the method
method = 'single',
# Set the metric
metric = 'correlation',
# Set the annot
annot = True,
# Set the vmin
vmin = 0,
# Set the vmax
vmax = 10)
# Display the plot
plt.show()
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 4. Luku 2
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/flights.csv')
upd_df = df.pivot_table(index='month', columns='year', values='passengers')
# Create a clustermap
___(# Add the data for the clustermap
___,
# Set the cmap
___,
# Set the standard_scale
___ = 1,
# Set the method
___ = 'single',
# Set the metric
metric = '___',
# Set the annot
___,
# Set the vmin
___,
# Set the vmax
vmax = ___)
# Display the plot
___
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme