[1caa3f]: / MOA / AgeHypo.py

Download this file

77 lines (47 with data), 1.5 kB

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import numpy as np
import pandas as panda
import matplotlib.pyplot as plt
from scipy.stats import norm
import statistics
db = panda.read_csv('cardio_train.csv')
Age = db.loc[db.cardio == 1].age
Age /= 356
Age = np.floor(Age)
ageMean = Age.mean()
ageMedian = Age.median()
ageMode = Age.mode()
ageSD = Age.std()
ageQ25,ageQ75 = np.percentile(Age,[25,75])
plt.boxplot(Age)
plt.title("BoxPlot Of The Age")
plt.ylabel("Age")
plt.show()
# Data Is Clean Already
unique,count = np.unique(Age, return_counts=True)
r = statistics.correlation(unique,count)
print("Correlation Between Age And Heart Disease = " + str(r))
x,y = np.polyfit(unique,count,1)
plt.scatter(unique,count)
plt.plot(unique,x*unique + y)
plt.title("Best Linear Fit Of The Data")
plt.ylabel("Frequency")
plt.xlabel("Age")
plt.show()
plt.hist(Age,10)
plt.title("Histogram Of The Age Column Of Patient")
plt.ylabel("Frequency")
plt.xlabel("Age")
plt.show()
AgeRightSide = Age.loc[Age >= ageMean]
AgeLeftSide = Age.loc[Age <= ageMean]
rightSideMean = AgeRightSide.mean()
leftSideMean = AgeLeftSide.mean()
print("Data Mean = " + str(ageMean))
print("Right Side Mean = " + str(rightSideMean))
print("Left Side Mean = " + str(leftSideMean))
rightSideCount = AgeRightSide.count()
leftSideCount = AgeLeftSide.count()
PhighAge = (rightSideCount) * 100 / (Age.count())
PLowAge = (leftSideCount) * 100 / (Age.count())
print("Propability Of High Age And Heart Disease = " + str(PhighAge))
print("Propability Of Low Age And Heart Disease = " + str(PLowAge))