image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

data = pd.read_csv('../input/heart-attack-analysis-prediction-dataset/heart.csv')

data.describe().T

data.isnull().sum()

duplicate = data[data.duplicated()]

data.drop_duplicates(inplace=True)

data = data.reset_index(drop=True)

plt.figure(figsize=(12,6))
sns.set(style='darkgrid')
ax = sns.countplot(y = 'output', data=data, palette='viridis')
ax.set_yticklabels(['Less Chance','Higher Chance'])
plt.ylabel('Chance to Have Heart Attack')
plt.xlabel('Number of Person')
plt.title('Output distribution', fontsize=20, loc = 'center')
plt.show()

fig, ax = plt.subplots(1, 2, figsize=(15, 8))
sns.histplot(x='age', data=data, kde=True, hue='output', ax=ax[0], palette='viridis')
ax[0].set_title('Age distribution on Output')
ax[0].set_ylabel('Number of Person')
ax[0].set_xlabel('age')
ax[0].legend(title='Heart Attack Chances', labels=['Higher Chance', 'Less Chance'], loc='upper right')
sns.boxplot(x='output', data=data, y='age', ax=ax[1], palette='viridis')
ax[1].set_title('Age distribution on Output')
ax[1].set_xticklabels(['Less Chance', 'Higher Chance'])
ax[1].set_xlabel('Chance to Have Heart Attack')
plt.tight_layout()
plt.show()