shaymaxo/ai-financial-coach-test
0
💳 AI Personal Spending Coach (ML + LLM)
This project is an AI-powered financial behavior coach that turns transaction data into educational, personalized insights. It combines:
- A supervised ML model (classification) to estimate “high-spend risk”
- A Large Language Model (LLM) to generate friendly explanations and answer user questions
- A Streamlit app deployed on Hugging Face Spaces
Disclaimer: Educational only — not financial advice. No personally identifying financial data is required.
✅ What the App Does
- User uploads a CSV of transactions
- App computes a summary of recent behavior (last 30 days)
- ML model outputs a probability score + risk bucket
- User can ask questions in a chat interface (e.g., “What should I focus on this month?”)
- LLM generates coaching feedback based on the user’s summary + ML score
🧾 Expected CSV Columns
The app expects a CSV containing the following columns:
- Customer ID
- Gender
- Birthdate
- Transaction Amount
- Transaction Date
- Merchant Name
- Category
The app handles mixed date formats and fills missing Gender as “Unknown”.
🔐 LLM Setup (Hugging Face Token)
This app calls an LLM using the Hugging Face Inference API.
In your Hugging Face Space:
- Go to Settings → Variables and secrets
- Add a Secret:
- Name:
HF_TOKEN - Value: your Hugging Face Access Token (Read is sufficient)
If the token is missing or the LLM request fails, the app uses a safe fallback response.
🛡️ Security Note (Prompt Injection)
For safety, the app does not expose the system prompt to users. Exposing prompts can increase risk of prompt injection and misuse. Instead, the app provides a short “How it works” explanation and keeps prompts server-side.
🧠 Model Details (Summary)
- Model: Gradient Boosting Classifier (via scikit-learn pipeline)
- Decision Threshold: 0.60 (balanced)
- Key features: age (derived), gender, category, merchant
🚀 Running Locally
pip install -r requirements.txt
streamlit run src/streamlit_app.py