mashdemy's picture
Update app.py
40a8579 verified
raw
history blame
1.57 kB
import pickle
import gradio as gr
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
# import sklearn.preprocessing
# with open("diabetes_classifier.pkl", "rb") as file:
# loaded_model = pickle.load(file)
loaded_model = pickle.load(open("diabetes_classifier.pkl", "rb"), encoding="bytes")
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 Pregnancies
# 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, debug = True)