-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
28 lines (28 loc) · 1017 Bytes
/
streamlit_app.py
File metadata and controls
28 lines (28 loc) · 1017 Bytes
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
import streamlit as st
import joblib
import pandas as pd
st.title("Gender prediction")
# Load the model
@st.cache_resource
def load_model():
return joblib.load("naive_bayes_gender_model_US.pkl")
model = load_model()
# Input from user
st.subheader("Enter mesuarements to predict")
col1, col2 = st.columns(2)
with col1:
feet = st.number_input("Height (feet)", min_value=1 , max_value=8 , value=5, step=1)
with col2:
inches = st.number_input("Height (inches)", min_value=0 , max_value=11 , value=6, step=1)
height = feet + (12 /inches)
normalized_shoe_size = st.number_input("Shoe size US shoe", min_value=1.0, max_value=24.0, value=10.0, step=0.5)
if st.button("Predict"):
input_data = pd.DataFrame({
"height": [height],
"shoe_size": [normalized_shoe_size]
})
prediction = model.predict(input_data)[0]
probability = model.predict_proba(input_data)[0]
st.subheader("Prediction result:")
st.write(f'Prediction: {prediction}')
st.write(f'Probability: {probability}')