Bourgi82 commited on
Commit
dd24b10
·
1 Parent(s): 9f9632d
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import joblib
4
+
5
+ # Load scaler, encoder, and model
6
+ scaler = joblib.load(r'toolkit\scaler.joblib')
7
+ model = joblib.load(r'toolkit\model_final.joblib')
8
+ encoder = joblib.load(r'toolkit\encoder.joblib')
9
+
10
+ # Prediction function
11
+ def predict(Gender, Urea, Cr, HbA1c, Chol, TG, HDL, LDL, VLDL, BMI):
12
+ # Create a DataFrame
13
+ input_df = pd.DataFrame({
14
+ 'Gender': [Gender],
15
+ 'Urea': [float(Urea)],
16
+ 'Cr': [float(Cr)],
17
+ 'HbA1c': [float(HbA1c)],
18
+ 'Chol': [float(Chol)],
19
+ 'TG': [float(TG)],
20
+ 'HDL': [float(HDL)],
21
+ 'LDL': [float(LDL)],
22
+ 'VLDL': [float(VLDL)],
23
+ 'BMI': [float(BMI)],
24
+ })
25
+
26
+ # Transform gender using the encoder
27
+ input_df['Gender'] = encoder.transform(input_df['Gender'])
28
+ # Apply scaler if necessary (uncomment if scaling is required)
29
+ # input_df = scaler.transform(input_df)
30
+
31
+ # Make prediction
32
+ prediction = model.predict(input_df)
33
+
34
+ # Prediction label mapping
35
+ prediction_label = {0: "No Diabetes", 1: "Prediabetic", 2: "Diabetic"}
36
+ return prediction_label[int(prediction[0])]
37
+
38
+ # Gradio app
39
+ with gr.Blocks(theme=gr.themes.Monochrome()) as app:
40
+ gr.Image("diabete1.jpg", label="Diabetes Prediction App")
41
+ gr.Markdown("# Diabetes Prediction App")
42
+ gr.Markdown(
43
+ "This app predicts a patient's diabetes status based on their health parameters. "
44
+ "Please provide the following inputs:"
45
+ )
46
+
47
+ with gr.Row():
48
+ with gr.Column():
49
+ Gender = gr.Radio(['M', 'F'], label="Gender")
50
+ Urea = gr.Slider(0, 100, step=1, label="Urea (mg/dL)")
51
+ Cr = gr.Number(label="Creatinine (mg/dL)")
52
+ HbA1c = gr.Number(label="HbA1c (%)")
53
+ Chol = gr.Number(label="Cholesterol (mg/dL)")
54
+ with gr.Column():
55
+ TG = gr.Number(label="Triglycerides (mg/dL)")
56
+ HDL = gr.Slider(0, 100, step=1, label="HDL Cholesterol (mg/dL)")
57
+ LDL = gr.Number(label="LDL Cholesterol (mg/dL)")
58
+ VLDL = gr.Number(label="VLDL (mg/dL)")
59
+ BMI = gr.Number(label="Body Mass Index (BMI)")
60
+
61
+ predict_btn = gr.Button("Predict")
62
+ output = gr.Label(label="Prediction Result")
63
+
64
+ predict_btn.click(
65
+ fn=predict,
66
+ inputs=[Gender, Urea, Cr, HbA1c, Chol, TG, HDL, LDL, VLDL, BMI],
67
+ outputs=output
68
+ )
69
+
70
+ app.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ seaborn
4
+ joblib
5
+ gradio
6
+ scikit-learn
toolkit/encoder.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a773365438957038e0df5904e618d7a28b7278b726f912ec705927efa28f2ba3
3
+ size 534
toolkit/model_final.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a458b1320736be446b50fdb02ac9c530da95407970b402f09c4ad19b41d157cc
3
+ size 776385
toolkit/scaler.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd31b5cd4ef3a901412794f8db4de41983e8847af2dce4902eaf373223d6da10
3
+ size 1463