import joblib import gradio as gr import pandas as pd def clean_text(text:str)->str: if pd.isna(text): return "" text = str(text).lower() text = ''.join(char for char in text if char.isalpha() or char.isspace()) return text LogisticModel = joblib.load(r'transaction_classifier_model_Logistic_Regression.joblib') Vectorizer = joblib.load(r'tfidf_vectorizer.joblib') def predict_category(description:str)->str: cleaned_text = clean_text(description) X = Vectorizer.transform([cleaned_text]).toarray() predict = LogisticModel.predict(X)[0] return predict demo = gr.Interface( fn=predict_category, inputs=gr.Textbox(label="Enter Transaction Description"), outputs=gr.Textbox(label="Predicted Category"), title="Transaction Classifier", description="Enter a transaction description to predict its category!" ) demo.launch(share=True)