File size: 909 Bytes
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
import streamlit as st
import pandas as pd
import re
import tensorflow as tf
import tensorflow_hub as hub
import joblib

def load_model():
    # Correct the path to your model
    return tf.keras.models.load_model('path_to_my_model', custom_objects={'KerasLayer': hub.KerasLayer})

model = load_model()

# Correct the path to your label encoder
label_encoder = joblib.load('label_encoder.joblib')

st.title('Transaction Category Predictor')

user_input = st.text_input("Enter a transaction description:")

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}")