Puree's picture
Update app.py
6575ef2
raw
history blame
2.75 kB
# -*- coding: utf-8 -*-
"""app.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1oAFb0lQ60MTeHdmQvqQwgEtMQzg7f0t4
"""
import joblib
import pandas as pd
import streamlit as st
model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')
unique_gender = unique_values["gender"]
unique_hypertension = unique_values["hypertension"]
unique_heart_disease = unique_values["heart_disease"]
unique_ever_married = unique_values["ever_married"]
unique_residence_type = unique_values["Residence_type"]
unique_smoking_status = unique_values["smoking_status"]
unique_work_type = unique_values["work_type"]
def main():
st.title("Brain stroke predict")
with st.form("questionaire"):
age = st.slider("Age",min_value=10, max_value=100)
gender = st.selectbox("Gender",options = unique_gender)
hypertension = st.selectbox("Hypertension",options = unique_hypertension )
heart_disease = st.selectbox("Heart disease",options = unique_heart_disease)
ever_married = st.selectbox("Ever married?",options = unique_ever_married)
residence_type = st.selectbox("Residence",options = unique_residence_type)
smoking_status = st.selectbox("Smoke",options = unique_smoking_status)
work_type = st.selectbox("Work type",options = unique_work_type)
avg_glucose_level = st.slider("Average glucose level",min_value=40, max_value=300)
bmi = st.slider("BMI(Body mass index )",min_value=12, max_value=50)
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Predict income")
if clicked:
result=model.predict(pd.DataFrame({"age": [age],
"gender": [gender],
"hypertension": [hypertension],
"heart_disease": [heart_disease],
"ever_married": [ ever_married],
"residence_type": [residence_type],
"smoking_status": [smoking_status],
"work_type": [work_type],
"avg_glucose_level": [avg_glucose_level],
"bmi": [bmi]}))
# Show prediction
result = '1'
if result[0] == 1:
st.success("You have change of getting brain stroke")
else:
st.success("You haven't change of getting brain stroke")
if __name__ == '__main__':
main()
# Run main()