Spaces:
Sleeping
Sleeping
File size: 2,318 Bytes
562f6d4 7c8bc68 562f6d4 794472c 562f6d4 2677dc1 562f6d4 2677dc1 562f6d4 66d520c 562f6d4 c514415 562f6d4 c514415 c19b001 562f6d4 d4351ec 562f6d4 2677dc1 562f6d4 2677dc1 c514415 562f6d4 c514415 |
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import streamlit as st
import pandas as pd
import numpy as np
import pickle
import sklearn
@st.cache_resource()
def load_rfr():
model = pickle.load(open('rfr.sav', 'rb'))
return model
def load_xgb():
model = pickle.load(open('xbg.sav', 'rb'))
return model
def load_lr():
model = pickle.load(open('lr.sav', 'rb'))
return model
st.title("Burnt Calories Prediction")
st.write("""
# Select a machine learning model
"""
)
#define the duration for the model
age = st.number_input('Input your age!', max_value=80, min_value=18, step=1)
duration = st.number_input('Input the amount of exercise time in minutes!', max_value=30.0, min_value=1.0, step=1.0)
height = st.number_input('Input your height!', max_value=230.0, min_value=120.0, step=1.0)
weight = st.number_input('Input your weight!', max_value=140.0, min_value=35.0, step=1.0)
heart_rate = st.number_input('Input your heart rate!', max_value=130.0, min_value=60.0, step=20.0)
body_temp = st.number_input('Input your body temperature!', max_value=45.0, min_value=35.0, step=1.0)
def model_prediction(age, height, weight, duration, heart_rate, body_temp, gender, model_input):
with st.spinner('Model is being loaded..'):
if model_input == "Random Forest Regressor":
model = load_rfr()
elif model_input == "Linear Regressor":
model = load_lr()
else:
model = load_xgb()
inputs = pd.DataFrame([{'Gender': gender, 'Age': age, 'Height': height, 'Weight': weight, 'Duration': duration, 'Heart_Rate': heart_rate, 'Body_Temp': body_temp}])
predictions = model.predict(inputs)
st.write("""# Prediction : """ , predictions)
with st.sidebar:
st.markdown("<h2 style='text-align: center; color: red;'>Settings Tab</h2>", unsafe_allow_html=True)
st.write("Input Settings:")
#define the gender for the model
gender_input = st.radio("Gender", ["Male", "Female"], index=None)
if gender_input == "Male":
gender = 0
else:
gender = 1
model_input = st.radio("Model", ["Random Forest Regressor", "Linear Regressor", "XG Boost"], index=None)
with st.container():
if st.button("Calculate"):
model_prediction(age, height, weight, duration, heart_rate, body_temp, gender, model_input) |