Spaces:
Runtime error
Runtime error
import joblib | |
import pandas as pd | |
import streamlit as st | |
model = joblib.load('model.joblib') | |
unique_values = joblib.load('unique_values.joblib') | |
unique_sex = unique_values["sex"] | |
unique_smoker = unique_values["smoker"] | |
unique_region = unique_values["region"] | |
def main(): | |
st.title("medical expenses") | |
with st.form("questionaire"): | |
age = st.slider("Age", min_value =10,max_value=100) | |
sex = st.selectbox("Sex", options=unique_sex) | |
bmi = st.slider("Bmi",min_value=10,max_value=100) | |
children = st.slider("Children", min_value=10,max_value=100) | |
smoker = st.selectbox("Smoker", options=unique_smoker) | |
region = st.selectbox("Region",options=unique_region) | |
# clicked==True only when the button is clicked | |
clicked = st.form_submit_button("Predict medical expenses") | |
if clicked: | |
result=model.predict(pd.DataFrame({"age": [age], | |
"sex": [sex], | |
"bmi": [bmi], | |
"children": [children], | |
"smoker": [smoker], | |
"region": [region]})) | |
st.success(f"You predict medical expenses is {result[0]}") | |
if __name__ == "__main__": | |
main() | |
# Run main() | |