File size: 1,341 Bytes
b0f3a2d
 
17c19e6
b0f3a2d
72f6a07
17c19e6
72f6a07
17c19e6
 
72f6a07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17c19e6
 
 
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
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()