Spaces:
Sleeping
Sleeping
File size: 1,891 Bytes
4c340f7 fbdcf36 4c340f7 fbdcf36 4c340f7 fbdcf36 4c340f7 fbdcf36 ce9644d 166273f fbdcf36 4c340f7 fbdcf36 4c340f7 fbdcf36 ce9644d 4c340f7 166273f 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 |
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_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.slider("Bmi", min_value=10, max_value=100)
HbA1c_level = st.slider("HbA1c_level", min_value=1, max_value=100)
blood_glucose_level = st.slider("Blood_glucose_level", min_value=1, max_value=100)
gender = st.selectbox("Gender", unique_gender)
smoking_history = st.selectbox("Smoking_history", unique_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 = 'have diabetes' if result[0] == 1 else 'does not have diabetes'
st.success('The predicted is {}'.format(result))
if __name__=='__main__':
main()
|