0% found this document useful (0 votes)
2 views1 page

Iris Dataset Correlation Analysis

The document provides a Python script that utilizes the Seaborn and Matplotlib libraries to analyze the Iris dataset. It generates a scatter plot to visualize the relationship between sepal length and petal length, computes the Pearson correlation, and displays both the covariance and correlation matrices. Additionally, it creates a heatmap to illustrate the correlation coefficients among the dataset's numerical features.

Uploaded by

iamnotnoob8888
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Iris Dataset Correlation Analysis

The document provides a Python script that utilizes the Seaborn and Matplotlib libraries to analyze the Iris dataset. It generates a scatter plot to visualize the relationship between sepal length and petal length, computes the Pearson correlation, and displays both the covariance and correlation matrices. Additionally, it creates a heatmap to illustrate the correlation coefficients among the dataset's numerical features.

Uploaded by

iamnotnoob8888
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import pandas as pd

import seaborn as sns


import [Link] as plt

# Load built-in Iris dataset


df = sns.load_dataset('iris')

# Display first few rows


print([Link]())

# Select two numerical columns


x, y = 'sepal_length', 'petal_length'

# Scatter plot & Pearson correlation


[Link](data=df, x=x, y=y)
[Link](f'Scatter Plot: {x} vs {y}')
[Link]()
print(f"Pearson Correlation between {x} and {y}: {df[x].corr(df[y]):.2f}")

# Covariance & Correlation Matrix


cov_matrix = [Link](numeric_only=True)
corr_matrix = [Link](numeric_only=True)
print("\nCovariance Matrix:\n", cov_matrix)
print("\nCorrelation Matrix:\n", corr_matrix)

# Correlation Heatmap
[Link](figsize=(6, 4))
[Link](corr_matrix, annot=True, cmap='coolwarm', fmt=".2f")
[Link]("Correlation Heatmap")
plt.tight_layout()
[Link]()

You might also like