mashdemy's picture
Create App.py
27524d2 verified
raw
history blame
1.27 kB
import pickle
import gradio as gr
with open("diabetes_classifier.pkl", "rb") as file:
loaded_model = pickle.load(file)
diabetes_classifier = loaded_model['model']
columns = loaded_model['columns']
def predict_diabetes_func(Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age):
input_data = [Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age]
input_df = pd.DataFrame([input_data], columns=columns)
prediction = diabetes_classifier.predict(input_df)
return "Positive" if prediction[0] == 1 else "Negative"
iface = gr.Interface( title = "Mashdemy AI Demo _Diabetes Prediction App"
description = "Enter the various parameters and click submit to know if the result is Positive or Negative"
fn=predict_diabetes_func, # Updated function name
inputs=[
gr.Number(label="Pregnancies"),
gr.Number(label="Glucose"),
gr.Number(label="BloodPressure"),
gr.Number(label="SkinThickness"),
gr.Number(label="Insulin"),
gr.Number(label="BMI"),
gr.Number(label="DiabetesPedigreeFunction"),
gr.Number(label="Age"),
],
outputs="text",
live=False,
)
iface.launch(share= True)