Spaces:
Sleeping
Sleeping
File size: 977 Bytes
6201e93 bb4f720 6201e93 bb4f720 6201e93 889a3da bb4f720 6201e93 bb4f720 6201e93 |
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 |
import streamlit as st
import pandas as pd
import re
import tensorflow as tf
import tensorflow_hub as hub
import joblib
# Load model and label encoder
def load_model():
return tf.keras.models.load_model('path_to_my_model', custom_objects={'KerasLayer': hub.KerasLayer})
model = load_model()
label_encoder = joblib.load('label_encoder.joblib')
# Streamlit application title
st.title('Transaction Category Predictor')
# User input for transaction description
user_input = st.text_input("Enter a transaction description:")
# Process user input and display prediction
if user_input:
processed_input = re.sub(r'\d+', '', user_input)
input_df = pd.DataFrame([processed_input], columns=['transaction_desc'])
prediction = model.predict(input_df['transaction_desc'])
predicted_category_index = prediction.argmax()
predicted_category = label_encoder.inverse_transform([predicted_category_index])[0]
st.write(f"Predicted Category: {predicted_category}")
|