ArpitChb commited on
Commit
d2cafe4
·
verified ·
1 Parent(s): 5f2d9ad

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import pickle
4
+ import numpy as np
5
+
6
+ # Load your ML model (replace 'model.pkl' with your model file)
7
+ with open("model.pkl", "rb") as model_file:
8
+ model = pickle.load(model_file)
9
+
10
+ # Define your prediction function
11
+ def predict_health_risk(age, activity_level, diet_score, health_history):
12
+ """
13
+ Predict health risk based on user input.
14
+ """
15
+ input_data = np.array([[age, activity_level, diet_score, health_history]])
16
+ prediction = model.predict(input_data)
17
+ return f"Predicted Risk: {prediction[0]}"
18
+
19
+ # Set up Gradio interface
20
+ with gr.Blocks() as demo:
21
+ gr.Markdown("## Personalized Health Tracker")
22
+ gr.Markdown("Enter your details to predict health risks.")
23
+
24
+ with gr.Row():
25
+ age = gr.Number(label="Age", value=30)
26
+ activity_level = gr.Number(label="Activity Level (1-10)", value=5)
27
+ diet_score = gr.Number(label="Diet Score (1-10)", value=5)
28
+ health_history = gr.Number(label="Health History (e.g., 1 for Yes, 0 for No)", value=0)
29
+
30
+ predict_btn = gr.Button("Predict Risk")
31
+ output = gr.Textbox(label="Risk Score")
32
+
33
+ predict_btn.click(predict_health_risk, inputs=[age, activity_level, diet_score, health_history], outputs=output)
34
+
35
+ # Launch the app
36
+ if __name__ == "__main__":
37
+ demo.launch()