Gargi16 commited on
Commit
e2aa6fe
·
verified ·
1 Parent(s): 7b037a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import gradio as gr
2
  import pickle
3
  import pandas as pd
4
 
@@ -35,3 +35,35 @@ iface = gr.Interface(
35
 
36
  # Launch the Gradio interface
37
  iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''import gradio as gr
2
  import pickle
3
  import pandas as pd
4
 
 
35
 
36
  # Launch the Gradio interface
37
  iface.launch()
38
+ '''
39
+ import gradio as gr
40
+ import pickle
41
+ import numpy as np
42
+
43
+ # Load the trained model
44
+ with open("model-svm.pkl", "rb") as f:
45
+ model = pickle.load(f)
46
+
47
+ def predict_pcos(age, weight, height, bmi, pulse_rate, cycle_length):
48
+ input_data = np.array([[age, weight, height, bmi, pulse_rate, cycle_length]])
49
+ prediction = model.predict(input_data)
50
+ return "Positive" if prediction[0] == 1 else "Negative"
51
+
52
+ # Define the Gradio interface
53
+ interface = gr.Interface(
54
+ fn=predict_pcos,
55
+ inputs=[
56
+ gr.Number(label="Age (yrs)"),
57
+ gr.Number(label="Weight (Kg)"),
58
+ gr.Number(label="Height (Cm)"),
59
+ gr.Number(label="BMI"),
60
+ gr.Number(label="Pulse rate(bpm)"),
61
+ gr.Number(label="Cycle length(days)")
62
+ ],
63
+ outputs=gr.Textbox(label="PCOS Prediction"),
64
+ title="PCOS Detection Model",
65
+ description="Predicts the likelihood of PCOS based on user input features."
66
+ )
67
+
68
+ # Launch the Gradio app
69
+ interface.launch()