Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Clustermap | Matrix Plots
Deep Dive into the seaborn Visualization

book
Clustermap

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

carousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-img
Tehtävä

Swipe to start coding

  1. Create the clustermap using the seaborn library:
  • Add the data for the clustermap. Input only the name of the DataFrame;
  • Set the 'vlag' cmap;
  • Set the standard_scale parameter equals 1;
  • Set the 'single' method parameter;
  • Set the 'correlation' metric parameter;
  • Add the annot;
  • Set the vmin parameter equals 0 and vmax parameter equals 10;
  • Display the plot.

Ratkaisu

# 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ää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 2
# 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ä

expand
ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt