Skip to content

satorucommit/Personal-Expense-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personal Expense Tracker with ML Insights

A Flask-based web application that helps you track personal expenses with machine learning-powered insights.

Features

  • 📝 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

Tech Stack

  • 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

Installation

  1. Clone or download this repository
  2. Install the required packages:
    pip install -r requirements.txt

Usage

Run the application with:

python app.py

The app will start on http://localhost:5000. Open this URL in your browser to access the application.

How It Works

Adding Expenses

  1. Navigate to the "Add Expense" tab
  2. Enter the amount, date, and description
  3. Optionally click "Auto-Categorize" to let ML predict the category from the description
  4. Add the expense to your records

Dashboard

View your spending patterns:

  • Total spent and daily averages
  • Spending by category (doughnut chart)
  • Daily spending trend (line chart)
  • Recent expenses table

Predictions

  • Forecast next month's spending using linear regression
  • See category predictions for sample descriptions

Insights

  • Weekend vs. weekday spending comparison
  • Top spending categories
  • Personalized budget recommendations (10% savings suggestion)

ML Models

  1. Text Classification: Uses Naive Bayes with TF-IDF to categorize expenses from descriptions
  2. Time Series Forecasting: Linear regression to predict future spending
  3. Pattern Analysis: Compares weekend vs. weekday spending

Data Persistence

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.

Project Structure

├── 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

Customization

You can modify the categories by manually entering them when adding expenses. The ML model will learn from your categorizations over time.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors