File size: 1,093 Bytes
6655025
 
 
414ceaa
6655025
 
 
 
 
414ceaa
 
6655025
 
 
 
 
 
 
 
 
 
 
 
414ceaa
6655025
 
 
 
 
 
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
import streamlit as st
import tensorflow as tf
import numpy as np
import joblib
from sklearn.preprocessing import MinMaxScaler

# Load the trained model
model = tf.keras.models.load_model('vitals_model.keras')

# Load the pre-fitted scaler
scaler = joblib.load('scaler.save')  # Make sure this file is accessible in your app environment

# Streamlit input fields
st.title('Vitals Prediction with LSTM')

systolic_bp = st.number_input('Systolic BP', 100, 180)
diastolic_bp = st.number_input('Diastolic BP', 60, 120)
glucose_level = st.number_input('Glucose Level', 70, 200)
heart_rate = st.number_input('Heart Rate', 50, 150)
steps = st.number_input('Steps', 0, 20000)

# Preprocess input
input_data = np.array([[systolic_bp, diastolic_bp, glucose_level, heart_rate, steps]])
scaled_data = scaler.transform(input_data)  # Now, this will work as the scaler is pre-fitted

# Predict
if st.button('Predict'):
    prediction = model.predict(np.expand_dims(scaled_data, axis=0))
    unscaled_prediction = scaler.inverse_transform(prediction)
    st.write(f'Predicted vitals: {unscaled_prediction}')