import pandas as pd import matplotlib.pyplot as plt import plotly.express as px import streamlit as st from transformers import pipeline # Upload CSV file containing transaction data uploaded_file = st.file_uploader("Upload Expense CSV", type="csv") if uploaded_file is not None: # Load the file into a DataFrame df = pd.read_csv(uploaded_file) # Debug: Display the column names to check if 'Description' exists st.write("Columns in the uploaded file:", df.columns) # Check if the 'Description' column exists if 'Description' not in df.columns: st.error("Error: The CSV file does not contain a 'Description' column.") else: # Initialize Hugging Face's zero-shot text classification model model_name = 'distilbert-base-uncased' classifier = pipeline('zero-shot-classification', model=model_name) # List of possible expense categories categories = ["Groceries", "Rent", "Utilities", "Entertainment", "Dining", "Transportation", "Salary"] # Function to classify transaction descriptions into categories def categorize_expense(description): result = classifier(description, candidate_labels=categories) return result['labels'][0] # Choose the most probable category # Apply the categorization function to the 'Description' column in the dataset df['Category'] = df['Description'].apply(categorize_expense) # Show the categorized data st.write("Categorized Data:", df.head()) #