Spaces:
Runtime error
Runtime error
Create App.py
Browse files
App.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
import gradio as gr
|
3 |
+
with open("diabetes_classifier.pkl", "rb") as file:
|
4 |
+
loaded_model = pickle.load(file)
|
5 |
+
diabetes_classifier = loaded_model['model']
|
6 |
+
columns = loaded_model['columns']
|
7 |
+
|
8 |
+
def predict_diabetes_func(Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age):
|
9 |
+
input_data = [Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age]
|
10 |
+
input_df = pd.DataFrame([input_data], columns=columns)
|
11 |
+
prediction = diabetes_classifier.predict(input_df)
|
12 |
+
return "Positive" if prediction[0] == 1 else "Negative"
|
13 |
+
|
14 |
+
iface = gr.Interface( title = "Mashdemy AI Demo _Diabetes Prediction App"
|
15 |
+
description = "Enter the various parameters and click submit to know if the result is Positive or Negative"
|
16 |
+
fn=predict_diabetes_func, # Updated function name
|
17 |
+
inputs=[
|
18 |
+
gr.Number(label="Pregnancies"),
|
19 |
+
gr.Number(label="Glucose"),
|
20 |
+
gr.Number(label="BloodPressure"),
|
21 |
+
gr.Number(label="SkinThickness"),
|
22 |
+
gr.Number(label="Insulin"),
|
23 |
+
gr.Number(label="BMI"),
|
24 |
+
gr.Number(label="DiabetesPedigreeFunction"),
|
25 |
+
gr.Number(label="Age"),
|
26 |
+
],
|
27 |
+
outputs="text",
|
28 |
+
live=False,
|
29 |
+
)
|
30 |
+
|
31 |
+
iface.launch(share= True)
|