-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app.py
55 lines (45 loc) · 1.66 KB
/
streamlit_app.py
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
import numpy as np
from sklearn.preprocessing import StandardScaler
import pickle
import warnings
import streamlit as st
# ignore warnings
warnings.filterwarnings('ignore')
# Loading Data files divided into test and train
X_test = pickle.load(open('data/X_test', 'rb'))
X_train = pickle.load(open('data/X_train', 'rb'))
# standardizing the data for faster and accurate result
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
# Loading the Trained model
model = pickle.load(open('TrainedModel.sav', 'rb'))
def calories_prediction(input_data):
data_array = np.asarray(input_data)
data_reshaped = data_array.reshape(1, -1)
data_transformed = scaler.transform(data_reshaped)
prediction = model.predict(data_transformed)
return prediction
st.title('Calories Burnt Prediction using AI')
st.sidebar.image('usrImage/hmrlogo.png')
st.sidebar.write('# Summer Training Project')
st.sidebar.write('# Shivam Singh\n # 07313302720\n # CSE-5A\n')
gender = st.radio(
"What is your gender",
('Male', 'Female')
)
if gender == 'Male':
gender = 0
else:
gender = 1
age = st.text_input('Write your age')
height = st.text_input('Write your height in cm')
weight = st.text_input('Write your weight in Kg')
duration = st.text_input('Duration of exercise')
heart_rate = st.text_input('Average heart rate')
body_temp = st.text_input('Average body temp in celsius')
calculated_calories = ''
# creating the result button
if st.button('Calculate the calories burnt during exercise'):
calculated_calories = calories_prediction([gender, age, height, weight, duration, heart_rate, body_temp])
st.success(calculated_calories)