Veriflow: B2B Revenue Leakage & Invoice Auditing System
Project Overview
Veriflow is a production-oriented dual-model machine learning compliance platform that automatically monitors B2B transactions, identifies pricing discrepancies, and flags suspicious shipping rates to eliminate revenue leakage in enterprise supply chains. Connected to a 424MB relational SQLite database containing millions of retail wine and spirits distribution logs, the system helps corporate financial auditors isolate overcharges before payments are finalized.
- Automated Clearance: Approves baseline, low-risk invoices, saving audit resources.
- Plugs Revenue Leakages: Detects inflated shipping costs and cost variances.
- Tracks Vendor Compliance: Highlights delays and inflation trends per supplier.
Situation
Large retail and logistics companies process thousands of B2B transactions every month. Due to highly complex contracts, multi-tiered shipping rates, and manual processing errors, enterprise organizations routinely overpay suppliers by 1% to 5% annually. For Bibitor, LLC (the distribution catalog represented in the relational schema), auditing millions in billed volume manually is extremely resource-intensive, making automated leakage detection crucial.
Task
The goal was to engineer a production-ready machine learning framework and an interactive compliance dashboard that connects directly to the historical transaction database, extracts complex relational logs, builds highly expressive features, and implements a robust dual-model architecture to forecast expected logistics costs and classify high-risk billing anomalies.
Actions
- Database Integration & Join Querying: Connected the platform to the SQLite data store, performing complex left-joins across
purchases,vendor_invoice,purchase_prices, and inventory tables. - Expressive Feature Engineering: Derived features to isolate overcharges, including:
- Price Variance: Discrepancies between contract purchase orders and billed invoice totals.
- Quantity Discrepancies: Tracking if quantity billed exceeded quantity ordered.
- Freight-to-Invoice Ratio & Freight-per-Unit: Normalizing shipping costs to detect padded shipping bills.
- Billing Delays: Calculating days elapsed between purchase orders and invoice dates.
- Dual-Model Machine Learning Pipeline:
- Expected Cost Regressor: Trained a Random Forest Regressor ($R^2 = 0.9661$) to predict fair, baseline freight charges.
- Risk Classifier: Trained a Random Forest Classifier (90% weighted F1-Score) to flag compliance violations.
- Edge-Case Safeguarding: Implemented robust exception handling including unknown vendor ignoring via one-hot encoding setups, zero-division offset protection (+1e-5), and PO fallback layers.
- Compliance Dashboard: Developed a premium Streamlit interface equipped with executive variance stats, an interactive simulation auditing desk, and a filtered SQL ledger with CSV exporting.
Results
Veriflow analyzed 5,543 enterprise transactions totaling $21,080,266.39 in audited billing volume. The dual-model compliance pipeline successfully isolated 86 extreme freight overcharge anomalies (where shipping bills exceeded >0.8% of invoice values), offering immediate audit clarity and demonstrating significant potential for corporate savings.
Tech Stack
- Streamlit: Framework for the premium compliance dashboard UI.
- Scikit-learn: Employed for Random Forest models, preprocessors, and training validation metrics.
- SQLite: Relational relational database backend.
- Pandas & NumPy: Libraries for processing relational datasets and complex array metrics.
- Python: Scripting core for data extraction and modular inference APIs.