# hue="species" colors the dots so we can spot clusters
# corner=True removes the duplicate charts to keep it clean
sns.pairplot(df_clean, hue="species", corner=True, height=1.5)
plt.show()
Now that we have a sense of the numbers, let’s visualise the relationships.
A Pairplot allows us to see the relationship between every variable at once. This helps us spot clusters and potential correlations.
# hue="species" colors the dots so we can spot clusters
# corner=True removes the duplicate charts to keep it clean
sns.pairplot(df_clean, hue="species", corner=True, height=1.5)
plt.show()
Finally, let’s quantify how strongly these variables are related.
1.0 = Perfect positive correlation (move together)
-1.0 = Perfect negative correlation (move opposite)
0 = No relationship
This matrix is crucial for deciding which variables to include in a regression model.
# Calculate the correlation matrix
corr_matrix = df_clean.corr(numeric_only=True)
# Plot the heatmap
plt.figure(figsize=(6, 5))
sns.heatmap(corr_matrix, annot=True, cmap="coolwarm", vmin=-1, vmax=1, fmt=".2f")
plt.title("Correlation Matrix")
plt.show()