Latest Update

BCSL606 Program 2

PROGRAM:

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_california_housing

# Step 1: Load the California Housing Dataset
california_data = fetch_california_housing(as_frame=True)
data = california_data.frame

# Step 2: Compute the correlation matrix
correlation_matrix = data.corr()

# Step 3: Visualize the correlation matrix using a heatmap
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt='.2f', linewidths=0.5)
plt.title('Correlation Matrix of California Housing Features')
plt.show()

# Step 4: Create a pair plot to visualize pairwise relationships
sns.pairplot(data, diag_kind='kde', plot_kws={'alpha': 0.5})
plt.suptitle('Pair Plot of California Housing Features', y=1.02)
plt.show()

OUTPUT:

BCSL606-program-2-output-1
BCSL606-program-2-output-2
guest
5 Comments
Inline Feedbacks
View all comments
sheeba
sheeba
25-01-2025 9:15 PM

can you send all programs in Machine learning to my mail id
couldnt able to download
thankyou

sheeba
sheeba
25-01-2025 9:16 PM

can you send all programs in Machine learning to my mail id
couldnt able to download
thankyou

ajay
ajay
13-02-2025 11:46 AM

while executing we are not getting the dataset from the table what you have shown
our table is empty

Dhanashree kulkarni
Dhanashree kulkarni
24-02-2025 12:56 PM

thanks for help

5
0
Would love your thoughts, please comment.x
()
x