-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasic Goeey.py
66 lines (43 loc) · 2.07 KB
/
Basic Goeey.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'''
A simple Gooey example. One required field, one optional.
'''
from argparse import ArgumentParser
from gooey import Gooey
from colored import stylize, attr, fg
import joblib
import pandas as pd
import warnings
warnings.filterwarnings("ignore")
model = joblib.load("diabeteseModel.pkl")
def predict(Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin,BMI, DiabetesPedigreeFunction, Age):
#print(payload)
values = [Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin,BMI, DiabetesPedigreeFunction, Age]
headers = ['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness', 'Insulin','BMI', 'DiabetesPedigreeFunction', 'Age']
input_variables = pd.DataFrame([values],
columns=headers,
dtype=float,
index=['input'])
# Get the model's prediction
prediction = model.predict(input_variables)
#print("Prediction: ", prediction)
prediction_proba = model.predict_proba(input_variables)[0][1]
#print("Probabilities: ", prediction_proba)
ret = {"prediction":float(prediction),"prediction_proba":float(prediction_proba)}
return ret
@Gooey(program_name="Diabetes Prediction Application",richtext_controls=True,terminal_font_size=16)
def main():
parser = ArgumentParser()
headers = ['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness', 'Insulin','BMI', 'DiabetesPedigreeFunction', 'Age']
for i in headers:
parser.add_argument(i,
action='store',
help="Description Goes Here")
args = parser.parse_args()
prediction_output=predict(args.Pregnancies, args.Glucose, args.BloodPressure, args.SkinThickness, args.Insulin,args.BMI, args.DiabetesPedigreeFunction, args.Age)
prediction_value=prediction_output.get('prediction_proba')
prediction_proba=str(round(float(prediction_output.get('prediction_proba')),1)*100)+'%'
prediction_desc='Positive' if float(prediction_value) >0.4 else 'Negative'
print("The Person is Diagnosed as Diabetes: "+stylize(prediction_desc, attr("bold")))
print(stylize("The Prediction Confidence is: "+prediction_proba, fg("blue") + attr("bold")))
if __name__ == '__main__':
main()