<?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: Melnus</title>
    <description>The latest articles on DEV Community by Melnus (@melnus).</description>
    <link>https://dev.to/melnus</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3633826%2F4a532137-e492-4bc5-b7fc-bc47af7fb74e.jpeg</url>
      <title>DEV Community: Melnus</title>
      <link>https://dev.to/melnus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/melnus"/>
    <language>en</language>
    <item>
      <title>[ShowDev] I Built an Open-Source "Audit Tool" to Detect Government Waste Using Python &amp; Math 🐍📊</title>
      <dc:creator>Melnus</dc:creator>
      <pubDate>Fri, 28 Nov 2025 04:45:48 +0000</pubDate>
      <link>https://dev.to/melnus/showdev-i-built-an-open-source-audit-tool-to-detect-government-waste-using-python-math-a4i</link>
      <guid>https://dev.to/melnus/showdev-i-built-an-open-source-audit-tool-to-detect-government-waste-using-python-math-a4i</guid>
      <description>&lt;h2&gt;
  
  
  The Problem: "Vanity Metrics" in the Public Sector
&lt;/h2&gt;

&lt;p&gt;Governments love big numbers.&lt;br&gt;
&lt;em&gt;"Total budget: $100M!"&lt;/em&gt; &lt;em&gt;"Cumulative users: 30,000!"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the startup world, we call these &lt;strong&gt;"Vanity Metrics"&lt;/strong&gt;—numbers that look good on paper but mean nothing in reality. They often hide the &lt;strong&gt;denominator&lt;/strong&gt; (population or actual needs) to create an illusion of success.&lt;/p&gt;

&lt;p&gt;I live in Kashiwa City, Japan. Recently, the city proudly announced &lt;strong&gt;"3,000 users!"&lt;/strong&gt; for a new app project. It sounded impressive until I ran a simple calculation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;City Population: 430,000&lt;br&gt;
&lt;strong&gt;Penetration Rate: 0.7%&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It wasn't a success. It was a statistical error.&lt;br&gt;
I realized we needed a standardized framework to debug these "political bugs." So, I built one.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Solution: Standard Block Comparison Method (SBCM)
&lt;/h2&gt;

&lt;p&gt;I developed a logic called &lt;strong&gt;SBCM&lt;/strong&gt;. It normalizes huge, vague numbers into a "Standard Block"—the capacity of a single average municipality.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. The Algorithm
&lt;/h3&gt;

&lt;p&gt;Instead of looking at the raw number ($V$), we calculate the &lt;strong&gt;Effectiveness Impact ($I$)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;I=VB
I = \frac{V}{B}
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;I&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;V&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Where $B$ (Standard Block) is defined as:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;B=P×RN
B = \frac{P \times R}{N}
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;B&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;P&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;×&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;R&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;P (Population):&lt;/strong&gt; Total population of the country (e.g., Japan: 124M)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;N (Number):&lt;/strong&gt; Total number of basic municipalities (Japan: 1,718)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;R (Ratio):&lt;/strong&gt; Target audience ratio (0.0 - 1.0)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By using $N=1718$ as a constant, we define &lt;strong&gt;"How many average towns could this project cover?"&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The Verdict Logic (v2.0)
&lt;/h3&gt;

&lt;p&gt;I codified the criteria to judge the "Social Implementation Stage."&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Impact ($I$)&lt;/th&gt;
&lt;th&gt;Verdict&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;I &amp;lt; 1.0&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Error Level&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;💀 Does not even cover 1 municipality.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1.0 &amp;lt;= I &amp;lt; 17&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Localized&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;⚠️ Less than 1% national reach. Experimental.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;17 &amp;lt;= I &amp;lt; 172&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Penetration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;🚀 1% - 10%. "One per classroom" level.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;I &amp;gt;= 859&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Social OS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;👑 Over 50%. Infrastructure like water/electricity.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Code: Building the CLI Tool 🛠️
&lt;/h2&gt;

&lt;p&gt;I implemented this logic as a Python CLI tool. It uses &lt;code&gt;argparse&lt;/code&gt; for easy input and &lt;code&gt;pandas&lt;/code&gt; for analyzing financial datasets.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;sbcm-calc&lt;/code&gt;: Simple Calculator
&lt;/h3&gt;

&lt;p&gt;A tool to verify single metrics instantly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_impact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target_ratio&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;municipalities&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1718&lt;/span&gt;
    &lt;span class="n"&gt;standard_block&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;target_ratio&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;municipalities&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;standard_block&lt;/span&gt;

&lt;span class="c1"&gt;# Usage: 3,000 users vs 124M population
# Result: Impact = 0.04 (Verdict: Error Level)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;sbcm-audit&lt;/code&gt;: Budget Portfolio Analysis
&lt;/h3&gt;

&lt;p&gt;This is the core feature. It loads a CSV of government spending (Financial Statements) and calculates the &lt;strong&gt;"Budget Distortion Index ($D_{index}$)"&lt;/strong&gt;.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;Dindex=IbudgetIcoverage
D_{index} = \frac{I_{budget}}{I_{coverage}}
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;D&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;in&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;d&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;e&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;I&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;co&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;v&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;er&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;a&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;g&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;e&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;I&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mathnormal mtight"&gt;b&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;u&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;d&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;g&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;e&lt;/span&gt;&lt;span class="mord mathnormal mtight"&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;If $D_{index}$ is extremely high, it means &lt;strong&gt;"High Cost, Low Reach"&lt;/strong&gt;—a classic sign of &lt;strong&gt;Pork-barrel projects&lt;/strong&gt; (wasteful spending).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result Visualization (The Matrix):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Quadrant 1 (High Cost / High Reach):&lt;/strong&gt; Infrastructure ✅&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Quadrant 2 (Low Cost / High Reach):&lt;/strong&gt; Innovation (Good DX) 💎&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Quadrant 4 (High Cost / Low Reach):&lt;/strong&gt; &lt;strong&gt;Distortion (Audit Required) 🚨&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demo: Auditing Kashiwa City 🇯🇵
&lt;/h2&gt;

&lt;p&gt;I ran this tool against my city's financial report.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python budget_distortion_analyzer.py kashiwa_data.csv &lt;span class="nt"&gt;--pop&lt;/span&gt; 435000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Project A (Tablets):   Budget $10M  | Impact 0.5  | Distortion 20.0  -&amp;gt; 🚨 Q4 (Distorted)
Project B (App):       Budget $2.5M | Impact 0.01 | Distortion 200.0 -&amp;gt; 🚨 Q4 (Distorted)
Project C (Station):   Budget $7M   | Impact 3.0  | Distortion 0.1   -&amp;gt; 💎 Q2 (Efficient)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It successfully detected that the Tablet project and the App project were highly inefficient compared to infrastructure investments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Python 3.10+&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Pandas:&lt;/strong&gt; For data manipulation.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;NumPy:&lt;/strong&gt; For Monte Carlo simulations (to verify statistical robustness).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Matplotlib:&lt;/strong&gt; For visualizing the distortion matrix.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It Yourself!
&lt;/h2&gt;

&lt;p&gt;I open-sourced this project. You can find the Python scripts, AI prompts for parsing PDFs, and Google Sheets formulas in the repo.&lt;/p&gt;

&lt;p&gt;If you are interested in &lt;strong&gt;Civic Tech&lt;/strong&gt;, &lt;strong&gt;Data Journalism&lt;/strong&gt;, or &lt;strong&gt;Open Government&lt;/strong&gt;, please check it out and give it a ⭐!&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/Melnus/Standard-Block-Comparison-Method" rel="noopener noreferrer"&gt;GitHub: Standard-Block-Comparison-Method&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's debug our governments with code. 💻🏛️&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>python</category>
      <category>opensource</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
