-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exploring heart dataset.py
45 lines (30 loc) · 1.21 KB
/
Exploring heart dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
import seaborn as sns
#Kaggle dataset
df = pd.read_csv("../input/heart-failure-clinical-data/heart_failure_clinical_records_dataset.csv")
(df.columns) # printing features
# Exploring data
import seaborn as sns
sns.pairplot(df)
df["DEATH_EVENT"].value_counts() # counting total deaths and alive from deathcount column
# Bar graph
df["DEATH_EVENT"].value_counts().plot(kind="bar", color=["salmon", "lightblue"]);
plt.xlabel("DEATH COUNT")
plt.ylabel("COUNT")
df.isna().sum() # checking for null values
# HEART FAILURE FREQUENCY ON THE BASICS OF GENDER
df.rename(columns = {"sex": "gender"} , inplace= True)
df["gender"].value_counts()
#crosstab values
pd.crosstab(df.DEATH_EVENT , df.gender)
# HEART FAILURE FREQUENCY ON THE BASICS OF AGE
df["age"].value_counts().head()
#crosstab values
pd.crosstab(df.DEATH_EVENT , df.age)
#scatterplot to determine deaths on basics of Age
plt.scatter(df.gender[df.DEATH_EVENT==1] , df.age[df.DEATH_EVENT==1] ,c="salmon" )
plt.title("Increasing Deaths due to Heart failure")
plt.xlabel("0=MALE | 1=FEMALE")
plt.ylabel(" AGE ")