-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunmodel.py
More file actions
99 lines (77 loc) · 2.36 KB
/
Copy pathrunmodel.py
File metadata and controls
99 lines (77 loc) · 2.36 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from tensorflow import keras
import numpy as np
import pandas as pd
import os
feature_cols_index={'age':0, 'hypertension':1, 'heart_disease':2, 'ever_married':3,
'Residence_type':4, 'avg_glucose_level':5, 'bmi':6, 'gender_Female':7,
'gender_Male':8, 'gender_Other':9, 'work_type_Govt_job':10,
'work_type_Never_worked':11, 'work_type_Private':12,
'work_type_Self-employed':13, 'work_type_children':14,
'smoking_status_Unknown':15, 'smoking_status_formerly smoked':16,
'smoking_status_never smoked':17, 'smoking_status_smokes':18}
absolute_path = os.path.dirname(__file__)
relative_path = "Stroke_prediction.h5"
full_path = os.path.join(absolute_path, relative_path)
model=keras.models.load_model(full_path)
def strokepred():
features=np.zeros(19)
features=features.reshape(-1,19)
info=float(input("\nEnter Age : "))
features[0][0]=info
info=int(input("\nHypertension (Yes=1/No=0): "))
features[0][1]=info
info=int(input("\nHeart disease (Yes=1/No=0): "))
features[0][2]=info
info=int(input("\nEver married? (Yes=1/No=0): "))
features[0][3]=info
info=int(input("\nResidence Type : (Urban = 1 / Rural = 0 ) : "))
features[0][4]=info
info=float(input("\nEnter Avg Glucose level : "))
features[0][5]=info
info=float(input("\nEnter Bmi : "))
features[0][6]=info
info=int(input("\nGender : (Female = 1 / Male = 2 / Other = 3 ) : "))
if info==1:
features[0][7]=1
elif info==2:
features[0][8]=1
elif info==3:
features[0][9]=1
info=int(input('''\nWork type...
Govt. Job = 1
Never worked = 2
Private = 3
Self-Employed = 4
Children = 5
\n Enter your input : '''))
if info==1:
features[0][10]=1
elif info==2:
features[0][11]=1
elif info==3:
features[0][12]=1
elif info==4:
features[0][13]=1
elif info==5:
features[0][14]=1
info=int(input('''\nSmoking Status...
Unknown = 1
Formerly smoked = 2
Never smoked = 3
Smokes = 4
\n Enter your input :'''))
if info==1:
features[0][15]=1
elif info==2:
features[0][16]=1
elif info==3:
features[0][17]=1
elif info==4:
features[0][18]=1
print("\nData retrieved... generating output\n")
label=model.predict(features)
if label>0.5:
print("Stroke probable!")
else:
print("Stroke not probable.")
strokepred()