Spaces:
Sleeping
Sleeping
File size: 1,978 Bytes
4c340f7 fbdcf36 4c340f7 fbdcf36 4c340f7 fbdcf36 4c340f7 fbdcf36 4c340f7 fbdcf36 4c340f7 fbdcf36 4c340f7 |
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 36 37 38 39 40 41 42 43 44 45 46 47 |
import joblib
import pandas as pd
import streamlit as st
model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')
unique_hypertension = unique_values["hypertension"]
unique_heart_disease = unique_values["heart_disease"]
unique_bmi = unique_values["bmi"]
unique_HbA1c_level = unique_values["HbA1c_level"]
unique_blood_glucose_level = unique_values["blood_glucose_level"]
unique_gender = unique_values["gender"]
unique_smoking_history = unique_values["smoking_history"]
def main():
st.title("diabetes prediction")
with st.form("questionaire"):
age = st.slider("Age", min_value=10, max_value=100)
hypertension = st.selectbox("Hypertemsion", unique_hypertension)
heart_disease = st.selectbox("Heart_desease", unique_heart_disease)
bmi = st.selectbox("Bmi", unique_bmi)
HbA1c_level = st.selectbox("HbA1c_level", unique_HbA1c_level)
blood_glucose_level = st.selectbox("Blood_glucose_level", blood_glucose_level)
gender = st.selectbox("Gender", gender)
smoking_history = st.selectbox("Smoking_history", smoking_history)
clicked = st.form_submit_button("Predict diabetes")
if clicked:
result=model.predict(pd.DataFrame({"age": [age],
"hypertension": [hypertension],
"heart_disease": [heart_disease],
"bmi": [bmi],
"HbA1c_level": [HbA1c_level],
"blood_glucose_level": [blood_glucose_level],
"gender": [gender],
"smoking_history": [smoking_history]}))
result = '0' if result[0] == 1 else '1'
st.success('The predicted income is {}'.format(result))
if __name__=='__main__':
main()
|