How biki989/invoice_flagging_prediction works
This application serves two procurement workflows: estimate freight from invoice dollars, and flag suspicious invoices using both sanity rules and a trained classifier. The browser dashboard sends requests to Flask, which loads saved models and returns results. Separate training pipelines prepare SQLite data, fit and evaluate models, and save artifacts; standalone inference scripts provide another way to run predictions. The README documents the database and broader training details, but the database file is absent from the supplied tree, and some training behavior is therefore represented from documentation rather than sampled source.
Main entry points: script.js Form Requests · app.py Invoice Endpoint · invoice_flagging/train.py Flag Training · Freight_cost_prediction/train.py Freight Training
Components 19
Dashboard
- Web Dashboard
templates/index.html - Form Requests
static/script.js - Prediction Results
static/script.js
Flask Serving
- Freight Endpoint
app.py - Invoice Endpoint
app.py - Sanity Rules
app.py
Freight Pipeline
- Freight Inference
inference/predict_freight.py - Freight Training
Freight_cost_prediction/train.py - Freight Preparation
Freight_cost_prediction/data_preprocessing.py - Regressor Evaluation
Freight_cost_prediction/model_evaluation.py
Invoice Pipeline
- Flag Inference
inference/predict_invoice_flag.py - Flag Training
invoice_flagging/train.py - Invoice Preparation
invoice_flagging/data_preprocessing.py - Classifier Evaluation
invoice_flagging/modeling_evaluation.py
Model Artifacts
- Freight Model
models/predict_freight_model.pkl - Flag Classifier
models/predict_flag_invoice.pkl - Feature Scaler
models/scaler.pkl
Other components
- Procurement User
- Inventory SQLite Data
Connections 23
- Procurement User → Web Dashboard: uses
- Web Dashboard → Form Requests: loads
- Form Requests → Freight Endpoint: posts freight
- Form Requests → Invoice Endpoint: posts invoice
- Freight Endpoint → Freight Model: predicts with
- Invoice Endpoint → Sanity Rules: checks inputs
- Invoice Endpoint → Feature Scaler: scales features
- Invoice Endpoint → Flag Classifier: predicts with
- Freight Endpoint → Form Requests: returns estimate
- Invoice Endpoint → Form Requests: returns flag
- Form Requests → Prediction Results: renders result
- Freight Inference → Freight Model: loads model
- Flag Inference → Flag Classifier: loads model
- Flag Inference → Feature Scaler: loads scaler
- Freight Training → Freight Preparation: loads and prepares
- Freight Training → Regressor Evaluation: trains and evaluates
- Freight Preparation → Inventory SQLite Data: reads invoices
- Freight Training → Freight Model: saves best model
- Flag Training → Invoice Preparation: prepares features
- Flag Training → Classifier Evaluation: trains and evaluates
- Invoice Preparation → Inventory SQLite Data: joins invoice and PO data
- Flag Training → Feature Scaler: saves scaler
- Flag Training → Flag Classifier: saves classifier