Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
import tensorflow as tf | |
import joblib | |
# Load trained model | |
model = tf.keras.models.load_model("banking_model.keras") | |
# Load encoders and scaler | |
label_encoders = joblib.load("label_encoders.pkl") | |
scaler = joblib.load("scaler.pkl") | |
# Define the input features | |
feature_names = [ | |
# Add all the feature column names used in training | |
] | |
st.title("Classification Prediction App") | |
# Create input fields for user input | |
user_input = {} | |
for feature in feature_names: | |
if feature in label_encoders: # If it's a categorical feature | |
options = list(label_encoders[feature].classes_) | |
user_input[feature] = st.selectbox(f"Select {feature}", options) | |
else: # If it's a numerical feature | |
user_input[feature] = st.number_input(f"Enter {feature}", value=0.0) | |
# Convert input to DataFrame | |
input_df = pd.DataFrame([user_input]) | |
# Apply encoding & scaling | |
for col, encoder in label_encoders.items(): | |
input_df[col] = encoder.transform(input_df[col]) | |
input_df[feature_names] = scaler.transform(input_df[feature_names]) | |
# Predict when user clicks button | |
if st.button("Predict"): | |
prediction = model.predict(input_df) | |
predicted_stage = np.argmax(prediction) | |
st.success(f"Predicted Stage: {predicted_stage}") | |
if __name__ == "__main__": | |
main() |