ShadowTEM commited on
Commit
d67ed2a
·
verified ·
1 Parent(s): 13508c4

Upload 3 files

Browse files
deployment/controller/GetPredictions.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+
3
+ def GetPredictions(model, inputs):
4
+
5
+ df = pd.DataFrame([inputs])
6
+
7
+ df['Gender'] = df['Gender'].map({'Male': 1, 'Female': 0})
8
+ df['Region'] = df['Region'].map({'Urban': 0, 'Rural': 1, 'Suburban': 0.5})
9
+ df['Exercise_Level'] = df['Exercise_Level'].map({'Low': 0, 'High': 1, 'Moderate': 0.5})
10
+ df['Diet'] = df['Diet'].map({'Unhealthy': 0, 'Healthy': 1, 'Mixed': 0.5})
11
+ df['Occupation'] = df['Occupation'].map({'Unemployed': 0, 'Employed': 2, 'Student': 1, 'Retired': 3})
12
+ df['Income_Level'] = df['Income_Level'].map({'Low': 0, 'High': 1, 'Middle': 0.5})
13
+ df['Physical_Activity'] = df['Physical_Activity'].map({'Low': 0, 'High': 1, 'Moderate': 0.5})
14
+ df['Education_Level'] = df['Education_Level'].map({'Primary': 0, 'Higher': 2, 'Secondary': 1})
15
+ df['Marital_Status'] = df['Marital_Status'].map({'Single': 0, 'Married': 1, 'Divorced': 2, 'Widowed': 3})
16
+ df['Smoking'] = df['Smoking'].map({'True': 1, 'False': 0})
17
+ df['Diabetes'] = df['Diabetes'].map({'True': 1, 'False': 0})
18
+ df['Family_History'] = df['Family_History'].map({'True': 1, 'False': 0})
19
+ df['Angina'] = df['Angina'].map({'True': 1, 'False': 0})
20
+ df['Heart_Disease_History'] = df['Heart_Disease_History'].map({'True': 1, 'False': 0})
21
+ df['Medication'] = df['Medication'].map({'True': 1, 'False': 0})
22
+ df['Obesity'] = df['Obesity'].map({'True': 1, 'False': 0})
23
+
24
+
25
+ prediction = model.predict([df.to_numpy()[0]])[0]
26
+
27
+ return prediction
deployment/controller/LoadModel.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+
3
+ def LoadModel(file_path: str):
4
+
5
+ with open(file_path, 'rb') as file:
6
+ loaded_model = pickle.load(file)
7
+
8
+ return loaded_model
deployment/controller/__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from .GetPredictions import GetPredictions
2
+ from .LoadModel import LoadModel