Skip to content

Nimesh861/invoice-intelligence-engine

Repository files navigation

Vendor Invoice Intelligence System

Freight Cost Prediction & Invoice Risk Flagging

📌 Table of Contents


📌 Project Overview

This project implements an end-to-end machine learning system designed to support finance teams by:

  1. Predicting expected freight cost for vendor invoices.
  2. Flagging high-risk invoices that require manual review due to abnormal cost, freight, or operational patterns.

🎯 Business Objectives

1. Freight Cost Prediction (Regression)

Objective:
Predict the expected freight cost for a vendor invoice using quantity, invoice value, and historical behavior.

Why it matters:

  • Freight is a non-trivial component of landed cost.
  • Poor freight estimation impacts margin analysis and budgeting.
  • Early prediction improves procurement planning and vendor negotiation.

2. Invoice Risk Flagging (Classification)

Objective:
Predict whether a vendor invoice should be flagged for manual approval due to abnormal cost, freight, or delivery patterns.

Why it matters:

  • Manual invoice review does not scale.
  • Financial leakage often occurs in large or complex invoices.
  • Early risk detection improves audit efficiency and operational control.

📂 Data Sources

Data is stored in a relational SQLite database (inventory.db) with the following tables:

  • vendor_invoice – Invoice-level financial and timing data
  • purchases – Item-level purchase details
  • purchase_prices – Reference purchase prices
  • begin_inventory, end_inventory – Inventory snapshots

SQL aggregation is used to generate invoice-level features.


📊 Exploratory Data Analysis (EDA)

EDA focuses on business-driven questions, such as:

  • Do flagged invoices have higher financial exposure?
  • Does freight scale linearly with quantity?
  • Does freight cost depend on quantity?

Statistical tests (t-tests) are used to confirm that flagged invoices differ meaningfully from normal invoices.


🤖 Models Used

Regression (Freight Prediction)

  • Linear Regression (baseline)
  • Decision Tree Regressor
  • Random Forest Regressor (final model)

Classification (Invoice Flagging)

  • Logistic Regression (baseline)
  • Decision Tree Classifier
  • Random Forest Classifier (final model with GridSearchCV)

Hyperparameter tuning is performed using GridSearchCV with F1-score to handle class imbalance.


📈 Evaluation Metrics

Freight Prediction

  • MAE
  • RMSE
  • R² Score

Invoice Flagging

  • Accuracy
  • Precision, Recall, F1-score
  • Classification report
  • Feature importance analysis

🖥 End-to-End Application

A Streamlit application demonstrates the complete pipeline:

  • Input invoice details
  • Predict expected freight
  • Flag invoices in real time
  • Provide human-readable explanations

📁 Project Structure

inventory-invoice-analytics/
│
├── data/
│   └── inventory.db
│
├── freight_cost_prediction/
│   ├── data_preprocessing.py
│   ├── model_evaluation.py
│   └── train.py
│
├── invoice_flagging/
│   ├── data_preprocessing.py
│   ├── model_evaluation.py
│   ├── model_evaluation.py
│   └── train.py
│
├── inference/
│   ├── predict_freight.py
│   └── predict_invoice_flag.py
│
├── models/
│   ├── predict_freight_model.pkl
│   ├── scaler.pkl
│   └── predict_flag_invoice.pkl
│
├── notebooks/
│   ├── Invoice Flagging.pkl
│   └── Predict Freight Cost.ipynb
│
├── app.py
├── README.md
└── .gitignore

How to Run This Project

  1. Clone the repository:
git clone https://github.com/yourusername/inventory-invoice-analytics.git
  1. Train and Save Best Fit Models:
python freight_cost_prediction/train.py
python invoice_flagging/train.py
  1. Test Models:
python inference/predict_freight.py
python inference/predict_invoice_flag.py
  1. Open Application:
streamlit run app.py

Author & Contact

Nimesh Patel
ML Engineer
📧 Email: pnimesh0806@gmail.com

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors