Page 301 - Touhpad Ai
P. 301

Output:



























                 6.     Write a Python program to create a pair plot using Seaborn to visualize pairwise relationships between variables in
                     a dataset.
                     Download the dataset using the given link or scan the QR code:
                     https://www.kaggle.com/code/desalegngeb/heart-disease-predictions/input

                     import seaborn as sns
                     import matplotlib.pyplot as plt
                     import pandas as pd
                     df = pd.read_csv('D:\\Data\\Heart.csv')
                     df_selected = df[['age', 'trestbps', 'chol', 'thalach', 'target']]
                     fig = plt.figure(figsize=(10, 8))
                     sns.pairplot(df_selected, hue='target')
                     fig.suptitle('Pair Plot of Heart Disease Dataset', y=1.02)
                     plt.tight_layout()
                     plt.show()
                     Output:
































                                                                                                     Practical File  299
   296   297   298   299   300   301   302   303   304   305   306