Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import re
|
4 |
+
import tensorflow as tf
|
5 |
+
import tensorflow_hub as hub
|
6 |
+
import joblib
|
7 |
+
|
8 |
+
def load_model():
|
9 |
+
# Correct the path to your model
|
10 |
+
return tf.keras.models.load_model('path_to_my_model', custom_objects={'KerasLayer': hub.KerasLayer})
|
11 |
+
|
12 |
+
model = load_model()
|
13 |
+
|
14 |
+
# Correct the path to your label encoder
|
15 |
+
label_encoder = joblib.load('label_encoder.joblib')
|
16 |
+
|
17 |
+
st.title('Transaction Category Predictor')
|
18 |
+
|
19 |
+
user_input = st.text_input("Enter a transaction description:")
|
20 |
+
|
21 |
+
if user_input:
|
22 |
+
processed_input = re.sub(r'\d+', '', user_input)
|
23 |
+
input_df = pd.DataFrame([processed_input], columns=['transaction_desc'])
|
24 |
+
prediction = model.predict(input_df['transaction_desc'])
|
25 |
+
predicted_category_index = prediction.argmax()
|
26 |
+
predicted_category = label_encoder.inverse_transform([predicted_category_index])[0]
|
27 |
+
st.write(f"Predicted Category: {predicted_category}")
|