Diff of /MOA/AgeHypo.py [000000] .. [1caa3f]

Switch to unified view

a b/MOA/AgeHypo.py
1
import numpy as np
2
import pandas as panda
3
import matplotlib.pyplot as plt
4
from scipy.stats import norm
5
import statistics
6
7
8
9
db = panda.read_csv('cardio_train.csv')
10
11
Age = db.loc[db.cardio == 1].age
12
Age /= 356
13
Age = np.floor(Age)
14
15
16
17
ageMean = Age.mean()
18
ageMedian = Age.median()
19
ageMode = Age.mode()
20
ageSD = Age.std()
21
22
ageQ25,ageQ75 = np.percentile(Age,[25,75])
23
24
25
plt.boxplot(Age)
26
plt.title("BoxPlot Of The Age")
27
plt.ylabel("Age")
28
plt.show()
29
30
# Data Is Clean Already
31
32
unique,count = np.unique(Age, return_counts=True)
33
34
r = statistics.correlation(unique,count)
35
print("Correlation Between Age And Heart Disease = " +  str(r))
36
37
x,y = np.polyfit(unique,count,1)
38
plt.scatter(unique,count)
39
plt.plot(unique,x*unique + y)
40
41
plt.title("Best Linear Fit Of The Data")
42
plt.ylabel("Frequency")
43
plt.xlabel("Age")
44
plt.show()
45
46
47
plt.hist(Age,10)
48
plt.title("Histogram Of The Age Column Of Patient")
49
plt.ylabel("Frequency")
50
plt.xlabel("Age")
51
plt.show()
52
53
54
AgeRightSide = Age.loc[Age >= ageMean]
55
AgeLeftSide = Age.loc[Age <= ageMean]
56
57
58
rightSideMean = AgeRightSide.mean()
59
leftSideMean = AgeLeftSide.mean()
60
61
print("Data Mean = " + str(ageMean))
62
print("Right Side Mean = " + str(rightSideMean))
63
print("Left Side Mean = " + str(leftSideMean))
64
65
66
rightSideCount = AgeRightSide.count()
67
leftSideCount = AgeLeftSide.count()
68
69
PhighAge = (rightSideCount) * 100 / (Age.count())
70
PLowAge = (leftSideCount) * 100 / (Age.count())
71
72
print("Propability Of High Age And Heart Disease = " + str(PhighAge))
73
print("Propability Of Low Age And Heart Disease = " + str(PLowAge))
74
75
76