Spaces:
Runtime error
Runtime error
File size: 1,339 Bytes
ab7824d 38332b6 b5bf838 38332b6 ab7824d 908d75e 963c815 908d75e 38332b6 908d75e 7a7f5e1 f2cb4c0 adbe6da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from sklearn.linear_model import LogisticRegression
import pickle
model = pickle.load(open('model.pkl','rb'))
def classify(num):
if num<1:
return 'negative'
else:
return 'positive'
import gradio as gr
import numpy as np
def predict_diabetes(preg,glu,bp,st,ins,bmi,dpf,age):
input_array=np.array([[preg,glu,bp,st,ins,bmi,dpf,age]])
pred=model.predict(input_array)
output=classify(pred[0])
if output=='negative':
return [(0,output)]
else:
return [(1,output)]
preg = gr.inputs.Slider(minimum=0, maximum=17, default=2, label="Pregnancy")
glu = gr.inputs.Slider(minimum=0, maximum=199, default=2, label="glucose")
bp = gr.inputs.Slider(minimum=0, maximum=122, default=2, label="blood prussure")
st = gr.inputs.Slider(minimum=0, maximum=99, default=2, label="skin thickness")
ins = gr.inputs.Slider(minimum=0, maximum=846, default=2, label="insulin")
bmi = gr.inputs.Slider(minimum=0, maximum=67.1, default=2, label="bmi")
dpf = gr.inputs.Slider(minimum=0, maximum=2.5, default=2, label="diabetes pedigree function")
age = gr.inputs.Slider(minimum=20, maximum=100, default=2, label="age")
op=gr.outputs.HighlightedText(color_map={ "negative": "green",
"positive": "red",})
gr.Interface(predict_diabetes, inputs=[preg,glu,bp,st,ins,bmi,dpf,age], outputs=op,live=True).launch() |