A Flask-based web application that helps you track personal expenses with machine learning-powered insights.
- 📝 Add Expenses: Simple form to record your spending with auto-categorization
- 🤖 Auto-categorization: ML predicts expense categories from descriptions using Naive Bayes + TF-IDF
- 📊 Dashboard: Visualize spending patterns and trends with interactive charts
- 🔮 Predictions: Forecast future spending using linear regression
- 💡 Insights: Weekend vs. weekday spending analysis and budget recommendations
- Backend: Flask - Python web framework
- Frontend: HTML, CSS, JavaScript with Chart.js for data visualization
- ML: Scikit-learn - For category prediction and forecasting
- Data Processing: Pandas & NumPy
- Data Storage: CSV files for persistence
- Clone or download this repository
- Install the required packages:
pip install -r requirements.txt
Run the application with:
python app.pyThe app will start on http://localhost:5000. Open this URL in your browser to access the application.
- Navigate to the "Add Expense" tab
- Enter the amount, date, and description
- Optionally click "Auto-Categorize" to let ML predict the category from the description
- Add the expense to your records
View your spending patterns:
- Total spent and daily averages
- Spending by category (doughnut chart)
- Daily spending trend (line chart)
- Recent expenses table
- Forecast next month's spending using linear regression
- See category predictions for sample descriptions
- Weekend vs. weekday spending comparison
- Top spending categories
- Personalized budget recommendations (10% savings suggestion)
- Text Classification: Uses Naive Bayes with TF-IDF to categorize expenses from descriptions
- Time Series Forecasting: Linear regression to predict future spending
- Pattern Analysis: Compares weekend vs. weekday spending
All expense data is automatically saved to expenses.csv in the same directory. The trained ML model is saved as category_model.pkl and vectorizer.pkl.
├── app.py # Flask application backend
├── requirements.txt # Python dependencies
├── expenses.csv # Expense data (created automatically)
├── category_model.pkl # Trained ML model (created automatically)
├── vectorizer.pkl # Text vectorizer (created automatically)
├── templates/
│ └── index.html # Main HTML page
└── static/
├── style.css # Styling
└── script.js # Frontend JavaScript
You can modify the categories by manually entering them when adding expenses. The ML model will learn from your categorizations over time.