HealthGuard-AI / app.py
waltertaya's picture
Added the scaler
414ceaa
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}')