शुरू करेंमुफ़्त में शुरू करें

क्लस्टर्ड हीटमैप्स

Correlation matrix दिखाने के लिए heatmaps बहुत उपयोगी हैं, लेकिन clustermaps और बेहतर होते हैं. Clustermap एक hierarchical-clustered heatmap बनाकर correlation matrix में छिपा स्ट्रक्चर उजागर करने में मदद करता है:

df_corr = df.corr()

fig = sns.clustermap(df_corr)
plt.setp(fig.ax_heatmap.xaxis.get_majorticklabels(), rotation=90)
plt.setp(fig.ax_heatmap.yaxis.get_majorticklabels(), rotation=0)

Axis labels के ओवरलैप को रोकने के लिए, आप underlying fig ऑब्जेक्ट से Axes को reference कर सकते हैं और rotation सेट कर सकते हैं. clustermap() फंक्शन के आर्ग्युमेंट्स के बारे में आप यहाँ सीख सकते हैं.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Time Series Data का विज़ुअलाइज़ेशन

पाठ्यक्रम देखें

अभ्यास निर्देश

  • seaborn को sns नाम से import करें.
  • meat DataFrame में सभी कॉलम्स के बीच Pearson method से correlation निकालें और परिणाम एक नए वैरिएबल corr_meat में असाइन करें.
  • corr_meat का clustermap प्लॉट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Import seaborn library
____

# Get correlation matrix of the meat DataFrame
corr_meat = ____(____)

# Customize the heatmap of the corr_meat correlation matrix and rotate the x-axis labels
fig = ____(corr_meat,
                     row_cluster=True,
                     col_cluster=True,
                     figsize=(10, 10))

plt.setp(fig.ax_heatmap.xaxis.get_majorticklabels(), rotation=90)
plt.setp(fig.ax_heatmap.yaxis.get_majorticklabels(), rotation=0)
plt.show()
कोड संपादित करें और चलाएँ