<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rohul Sharma</title>
    <description>The latest articles on DEV Community by Rohul Sharma (@rohul_sharma_b76920628e9b).</description>
    <link>https://dev.to/rohul_sharma_b76920628e9b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4015207%2Fdab6c309-7119-4ef8-84d5-55548d870a9c.png</url>
      <title>DEV Community: Rohul Sharma</title>
      <link>https://dev.to/rohul_sharma_b76920628e9b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rohul_sharma_b76920628e9b"/>
    <language>en</language>
    <item>
      <title>Vendor Invoice Project</title>
      <dc:creator>Rohul Sharma</dc:creator>
      <pubDate>Sat, 04 Jul 2026 15:23:01 +0000</pubDate>
      <link>https://dev.to/rohul_sharma_b76920628e9b/vendor-invoice-project-41pn</link>
      <guid>https://dev.to/rohul_sharma_b76920628e9b/vendor-invoice-project-41pn</guid>
      <description>&lt;p&gt;End-to-end data science project covering SQL analytics, freight cost&lt;br&gt;
prediction (regression), and invoice risk flagging (classification)&lt;br&gt;
on an inventory/purchasing dataset stored in SQLite.&lt;/p&gt;




&lt;h2&gt;
  
  
  Project structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vendor_invoice_project/
│
├── notebooks/
│   ├── predicting_freight_cost.ipynb   # EDA + regression notebook
│   ├── invoice_flagging.ipynb          # EDA + classification notebook
│   └── inventory.db                   # SQLite database (all source tables)
│
├── freight_cost_prediction/
│   ├── data_preprocessing.py           # Load, clean, feature-engineer, split
│   ├── train.py                        # Train &amp;amp; select best regression model
│   └── model_evaluation.py            # Residual diagnostics, R², plots
│
├── invoice_flagging/
│   ├── data_processing.py             # Load, join, label, split
│   ├── train.py                       # Train &amp;amp; tune classification models
│   └── model_evaluation.py           # ROC, PR curve, confusion matrix, t-tests
│
├── vendor_sql.sql                     # SQL analysis queries
├── requirements.txt
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Projects
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Predicting Freight Cost (Regression)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; Predict the freight cost for a vendor invoice given the order&lt;br&gt;
quantity and invoice dollar value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source table:&lt;/strong&gt; &lt;code&gt;vendor_invoice&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features:&lt;/strong&gt; &lt;code&gt;Quantity&lt;/code&gt;, &lt;code&gt;Dollars&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Target:&lt;/strong&gt; &lt;code&gt;Freight&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Models compared:&lt;/strong&gt; Linear Regression, Decision Tree, Random Forest&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best result:&lt;/strong&gt; Random Forest — R² ≈ 0.97&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key insight:&lt;/strong&gt; Bulk orders (high quantity) have significantly lower&lt;br&gt;
freight cost per unit, confirming economies of scale in shipping.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Invoice Risk Flagging (Classification)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; Flag invoices as risky (1) or normal (0) based on purchasing&lt;br&gt;
behaviour patterns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source tables:&lt;/strong&gt; &lt;code&gt;vendor_invoice&lt;/code&gt; joined with &lt;code&gt;purchases&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Labelling rules (rule-based, not model inputs):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dollar mismatch: &lt;code&gt;|invoice_dollars − total_item_dollars| &amp;gt; $5&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Receiving delay: &lt;code&gt;avg_receiving_delay &amp;gt; 10 days&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Features (leakage-free):&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;invoice_quantity&lt;/code&gt;, &lt;code&gt;Freight&lt;/code&gt;, &lt;code&gt;days_po_to_invoice&lt;/code&gt;, &lt;code&gt;days_to_pay&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;total_brands&lt;/code&gt;, &lt;code&gt;total_item_quantity&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note on methodology:&lt;/strong&gt; Labels are derived from business rules&lt;br&gt;
applied to the data. The labelling columns are intentionally&lt;br&gt;
excluded from model features to prevent leakage. In a production&lt;br&gt;
setting, labels would come from audited invoice records or&lt;br&gt;
confirmed fraud/dispute cases.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Models compared:&lt;/strong&gt; Logistic Regression, Decision Tree, Random Forest&lt;br&gt;
(all with &lt;code&gt;class_weight='balanced'&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tuning:&lt;/strong&gt; GridSearchCV on Decision Tree (cv=5, scoring=f1)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evaluation:&lt;/strong&gt; Confusion matrix, ROC-AUC, Precision-Recall curve,&lt;br&gt;
feature importance, Welch t-tests (flagged vs normal)&lt;/p&gt;




&lt;h3&gt;
  
  
  3. SQL Analysis (&lt;code&gt;vendor_sql.sql&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Analytical queries covering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Top vendors by purchase value&lt;/li&gt;
&lt;li&gt;Inventory movement (beginning vs ending)&lt;/li&gt;
&lt;li&gt;Most purchased products&lt;/li&gt;
&lt;li&gt;Freight cost efficiency by vendor&lt;/li&gt;
&lt;li&gt;Profit margin (purchase price vs retail price)&lt;/li&gt;
&lt;li&gt;ABC / Pareto analysis (80/20 rule)&lt;/li&gt;
&lt;li&gt;Vendor dependency analysis&lt;/li&gt;
&lt;li&gt;Inventory turnover indicator&lt;/li&gt;
&lt;li&gt;Sales vs inventory risk (estimated sales formula)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.10+&lt;/li&gt;
&lt;li&gt;See &lt;code&gt;requirements.txt&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Install dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Database
&lt;/h3&gt;

&lt;p&gt;Place &lt;code&gt;inventory.db&lt;/code&gt; in the &lt;code&gt;notebooks/&lt;/code&gt; directory (or update the&lt;br&gt;
&lt;code&gt;db_path&lt;/code&gt; argument in each script).&lt;/p&gt;

&lt;p&gt;The database contains these tables:&lt;br&gt;
&lt;code&gt;vendor_invoice&lt;/code&gt;, &lt;code&gt;purchases&lt;/code&gt;, &lt;code&gt;begin_inventory&lt;/code&gt;, &lt;code&gt;end_inventory&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;purchase_prices&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Running the pipelines
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Freight cost prediction
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;freight_cost_prediction/

&lt;span class="c"&gt;# Preprocess only&lt;/span&gt;
python data_preprocessing.py

&lt;span class="c"&gt;# Train all models and save best&lt;/span&gt;
python train.py

&lt;span class="c"&gt;# Evaluate saved model&lt;/span&gt;
python model_evaluation.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Invoice risk flagging
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;invoice_flagging/

&lt;span class="c"&gt;# Preprocess only&lt;/span&gt;
python data_processing.py

&lt;span class="c"&gt;# Train, tune, and save best model&lt;/span&gt;
python train.py

&lt;span class="c"&gt;# Evaluate saved model&lt;/span&gt;
python model_evaluation.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Saved models are written to &lt;code&gt;models/&lt;/code&gt; in each sub-folder.&lt;br&gt;
Evaluation plots are written to &lt;code&gt;evaluation_plots/&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Results summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Project&lt;/th&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Key Metric&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Freight cost&lt;/td&gt;
&lt;td&gt;Random Forest&lt;/td&gt;
&lt;td&gt;R² = 0.97&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invoice flagging&lt;/td&gt;
&lt;td&gt;Tuned Decision Tree&lt;/td&gt;
&lt;td&gt;F1 (risky) — see evaluation output&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Author
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Abhishek Thakur&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
