<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raghav Singh on Medium]]></title>
        <description><![CDATA[Stories by Raghav Singh on Medium]]></description>
        <link>https://medium.com/@raghavsingh4161?source=rss-b2e043d8b64a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*p6n2UTlBBCOB0vHI.</url>
            <title>Stories by Raghav Singh on Medium</title>
            <link>https://medium.com/@raghavsingh4161?source=rss-b2e043d8b64a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:12:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raghavsingh4161/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Designing a Data-Driven Power BI Sales Dashboard with DAX-Powered KPIs]]></title>
            <link>https://medium.com/@raghavsingh4161/designing-a-data-driven-power-bi-sales-dashboard-with-dax-powered-kpis-204c9502e41a?source=rss-b2e043d8b64a------2</link>
            <guid isPermaLink="false">https://medium.com/p/204c9502e41a</guid>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[kpi]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[dax]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Raghav Singh]]></dc:creator>
            <pubDate>Tue, 21 Oct 2025 11:46:59 GMT</pubDate>
            <atom:updated>2025-10-21T11:46:59.109Z</atom:updated>
            <content:encoded><![CDATA[<p>Working as a data analyst, you quickly find out that real-world data is never clean, and even after the arduous process of cleaning it, you have to put a lot of effort into gleaning actionable insights from the data. This is where Dax (Data Analysis Expressions) becomes invaluable.</p><p>DAX empowers analysts to build dynamic measures, perform complex calculations, and unlock deeper layers of understanding from their data. In this article, I’ll walk you through 12 critical DAX measures that formed the foundation of a Product Performance Dashboard I built using Power BI. These examples not only showcase essential business KPIs but also offer insight into how DAX works and how it can be used to solve real-world analytical problems. We’ll also demonstrate each measure in Power BI, with screenshots to help you visualize how they come to life in a real dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ej0imBx8bI1zES_8cnT2xw.png" /></figure><h4>1. Total Sales</h4><p>This is the most fundamental metric in any business dashboard. It tells you how much revenue your company is generating overall.</p><pre>Total Sales = SUM(sales_data_sample[SALES])</pre><p><strong>2. Total Quantity Ordered</strong></p><p>This measure provides a quick snapshot of overall sales volume, helping stakeholders understand how many units have been moved during a selected time period. This is especially useful for tracking demand, inventory planning, and identifying sales trends.</p><pre>Total Quantity Ordered = SUM(sales_data_sample[QUANTITYORDERED])</pre><h4>3. Fulfillment Rate</h4><p>Fulfillment Rate measures the percentage of orders that were successfully fulfilled out of the total orders placed. It’s a key operational KPI that reflects how well your business is delivering on customer expectations.</p><p>Assuming you have a column like STATUS that indicates whether an order was fulfilled (e.g., values like &quot;Shipped&quot; or &quot;Resolved&quot;), here’s a sample DAX measure:</p><pre>Fulfillment Rate =<br>DIVIDE(<br>    CALCULATE(COUNTROWS(sales_data_sample), sales_data_sample[STATUS] = &quot;Shipped&quot;),<br>    COUNTROWS(sales_data_sample),<br>    0<br>)</pre><ul><li>COUNTROWS(sales_data_sample) counts all orders.</li><li>CALCULATE(..., sales_data_sample[STATUS] = &quot;Shipped&quot;) counts only the fulfilled orders.</li><li>DIVIDE(...) calculates the percentage, safely handling division by zero.</li></ul><p>You can adjust “Shipped” to match the actual status values in your dataset that indicate fulfillment.</p><h4>4. Average Order Value</h4><p>Average Order Value (AOV) measures the average revenue generated per order. It is calculated by dividing total sales by the number of orders. This KPI helps businesses understand customer purchasing behavior and evaluate the effectiveness of pricing and upselling strategies.</p><pre>Average Order Value = DIVIDE(SUM(sales_data_sample[SALES]), COUNT(sales_data_sample[ORDERNUMBER]))</pre><ul><li><strong>SUM(sales_data_sample[SALES])</strong><br> This part calculates the <strong>total revenue</strong> from all sales. It adds up the values in the SALES column of your dataset.</li><li><strong>COUNT(sales_data_sample[ORDERNUMBER])</strong><br> This counts the <strong>total number of orders</strong>. Each unique ORDERNUMBER represents one order placed by a customer.</li><li><strong>DIVIDE(...)</strong><br> The DIVIDE function safely divides the total sales by the number of orders. It’s preferred over the / operator because it handles division by zero gracefully (returns blank instead of an error).</li></ul><h4>5. Average Price Per Product</h4><p>KPI are useful because they help you understand your pricing strategy and customer purchasing behavior at a granular level. By dividing total sales revenue by the total quantity of products sold, you get a clear view of how much, on average, each unit is being sold for.</p><pre>Average Price Per Product = DIVIDE(SUM(sales_data_sample[SALES]), SUM(sales_data_sample[QUANTITYORDERED]))</pre><p>This metric is valuable for several reasons:</p><ul><li>It helps identify pricing trends over time, such as whether discounts or promotions are lowering the average price.</li><li>It allows you to compare performance across product categories, regions, or customer segments.</li><li>It supports margin analysis by showing whether products are being sold at a sustainable price point relative to their cost.</li><li>It can highlight opportunities for upselling or bundling if the average price is lower than expected.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b5L0olWIiQ6mImUdEaTzsQ.png" /></figure><p>6. Product Margin</p><p>Calculating product margin percentage is crucial for understanding the profitability of individual products. It allows businesses to assess how much profit they make on each item relative to its suggested retail price, highlighting which products contribute most to the bottom line.</p><pre>Product Margin % =<br>AVERAGEX(<br>    VALUES(sales_data_sample[PRODUCTCODE]),<br>    DIVIDE(<br>        (AVERAGE(sales_data_sample[MSRP]) - AVERAGE(sales_data_sample[PRICEEACH])),<br>        AVERAGE(sales_data_sample[MSRP])<br>    )<br>)</pre><ul><li><strong>VALUES(sales_data_sample[PRODUCTCODE])</strong><br> This returns a distinct list of product codes from the sales_data_sample table. It ensures that the calculation is done <strong>per product</strong>, not across the entire dataset.</li><li><strong>AVERAGEX(...)</strong><br> This is an <strong>iterator function</strong> that goes row by row over the distinct product codes and calculates the average of the expression inside it. It’s ideal for <strong>row-context-aware</strong> calculations.</li></ul><p><strong>Inside the iterator:</strong></p><ul><li><strong>AVERAGE(sales_data_sample[MSRP])</strong>: Calculates the average <strong>Manufacturer&#39;s Suggested Retail Price</strong> for each product.</li><li><strong>AVERAGE(sales_data_sample[PRICEEACH])</strong>: Calculates the average <strong>actual selling price</strong> for each product.</li><li><strong>DIVIDE(...)</strong>: Safely divides the difference between MSRP and actual price by MSRP to get themargin percentage. DIVIDE handles divide-by-zero errors gracefully.</li></ul><h4>7. Year over Year Sales Growth</h4><p>Year-over-year (YoY) sales growth is a key performance indicator that helps businesses evaluate how their revenue is trending over time. This DAX formula calculates the percentage change in sales between the current year and the previous year, offering a clear view of growth momentum.</p><pre>Sales YoY Growth % =<br>VAR CurrentYearSales = <br>    CALCULATE(<br>        SUM(sales_data_sample[SALES]),<br>        sales_data_sample[YEAR_ID] = MAX(sales_data_sample[YEAR_ID])<br>    )<br>VAR LastYearSales = <br>    CALCULATE(<br>        SUM(sales_data_sample[SALES]),<br>        sales_data_sample[YEAR_ID] = MAX(sales_data_sample[YEAR_ID]) - 1<br>    )<br>RETURN<br>DIVIDE(CurrentYearSales - LastYearSales, LastYearSales, 0)</pre><p><strong>VAR CurrentYearSales</strong><br> Stores the total sales for the current year. It uses CALCULATE to sum the SALES column where the YEAR_ID matches the latest year in the current filter context (determined by MAX(sales_data_sample[YEAR_ID])).</p><p><strong>VAR LastYearSales</strong><br> Stores the total sales for the previous year. It also uses CALCULATE, but filters for one year before the current year by subtracting 1 from the maximum YEAR_ID.</p><p><strong>CALCULATE(…)</strong><br> Evaluates an expression in a modified filter context. In this case, it calculates total sales for a specific year by applying a filter directly inside the function.</p><p><strong>MAX(sales_data_sample[YEAR_ID])</strong><br> Returns the highest year value in the current context, which is assumed to be the most recent year in the dataset or visual.</p><p><strong>DIVIDE(…)</strong><br> Safely divides the difference between current year sales and last year sales by last year sales to get the growth percentage. The third argument (0) ensures that if last year’s sales are zero, the formula returns zero instead of an error.</p><h4>8. Unique Products Sold</h4><p>This function counts the number of unique product codes in the sales_data_sample table. Unlike a regular count, which includes duplicates, DISTINCTCOUNT ensures that each product is only counted once, regardless of how many times it appears in the dataset.</p><pre>Unique Products Sold = DISTINCTCOUNT(sales_data_sample[PRODUCTCODE])</pre><h4>9. Top Product by Total Sales</h4><p>This measure is important because it identifies the single best-performing product based on total sales, helping businesses quickly recognize which item is driving the most revenue. It’s especially useful for sales dashboards, executive summaries, and performance reviews, where decision-makers need to focus on top contributors.</p><pre>Top Product by Total Sales =<br>CALCULATE(<br>    MAX(sales_data_sample[PRODUCTCODE]),<br>    TOPN(<br>        1,<br>        SUMMARIZE(<br>            sales_data_sample,<br>            sales_data_sample[PRODUCTCODE],<br>            &quot;TotalSales&quot;,<br>            SUM(sales_data_sample[SALES])<br>        ),<br>        [TotalSales],<br>        DESC<br>    )<br>)</pre><p><strong>CALCULATE(…)</strong><br> Evaluates an expression in a modified filter context. In this case, it returns the product code with the highest total sales.</p><p><strong>MAX(sales_data_sample[PRODUCTCODE])</strong><br> Returns the maximum (alphabetically last) product code from the filtered result. Since CALCULATE is used with TOPN, this will return the product code of the top-selling product.</p><p><strong>TOPN(1, …, [TotalSales], DESC)</strong><br> Returns the top 1 row from a table, ordered by the TotalSales column in descending order. This ensures that only the product with the highest sales is selected.</p><p><strong>SUMMARIZE(…)</strong><br> Creates a temporary table that groups the data by PRODUCTCODE and calculates the total sales for each product. It adds a new column called “TotalSales” using SUM(sales_data_sample[SALES]).</p><h4>10. Top Product Line Name</h4><p>This measure is similar to the last one, except here we are looking for a product line rather than a product code.</p><pre>Top Product Line Name =<br>CALCULATE(<br>    MAX(sales_data_sample[Product Line]),<br>    FILTER(<br>        sales_data_sample,<br>        sales_data_sample[SALES] = <br>            CALCULATE(<br>                MAXX(<br>                    SUMMARIZE(<br>                        sales_data_sample,<br>                        sales_data_sample[Product Line],<br>                        &quot;TotalSales&quot;, SUM(sales_data_sample[SALES])<br>                    ),<br>                    [TotalSales]<br>                )<br>            )<br>    )<br>)</pre><h4>11. Top Product Line Sales.</h4><p>This measure helps identify which product lines are contributing the most to overall revenue. By focusing on the top sellers, businesses can prioritize resources, marketing efforts, and inventory planning around their most successful categories. It also enables executives and analysts to quickly assess which segments are driving growth, making it a valuable component of any sales performance dashboard.</p><pre>Top Product Line Sales =<br>CALCULATE(<br>    SUM(sales_data_sample[SALES]),<br>    TOPN(<br>        5,<br>        VALUES(sales_data_sample[Product Line]),<br>        CALCULATE(SUM(sales_data_sample[SALES])),<br>        DESC<br>    )<br>)</pre><h4>12. Total Orders</h4><p>This measure helps track how many individual orders were placed, which is a key indicator of customer activity and transaction volume. Unlike total sales, which reflects revenue, total orders show how often customers are buying. It’s useful for analyzing order frequency, customer behavior, and operational performance. Businesses can use this metric to monitor growth, evaluate marketing effectiveness, and optimize logistics and fulfillment processes.</p><pre>Total Orders = DISTINCTCOUNT(sales_data_sample[ORDERNUMBER])</pre><h4>Conclusion</h4><p>Designing a data-driven Power BI sales dashboard with DAX-powered KPIs is more than just a technical exercise — it’s about transforming raw data into meaningful insights that drive business decisions. Each measure we explored plays a specific role in helping stakeholders understand performance, identify opportunities, and respond to challenges. From tracking total sales and fulfillment rates to analyzing product margins and year-over-year growth, DAX enables analysts to build dynamic, context-aware metrics that reflect real-world business needs.</p><p>By combining these measures into a cohesive dashboard, you create a powerful tool that not only informs but empowers decision-makers to act with confidence. Whether you’re optimizing operations, refining pricing strategies, or identifying top-performing products, a well-designed Power BI dashboard backed by DAX logic is an essential asset in any data analyst’s toolkit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=204c9502e41a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tokenized Dollars vs. Banking: Data, Policy, and the Trillion-Dollar Fight]]></title>
            <link>https://medium.com/@raghavsingh4161/tokenized-dollars-vs-banking-data-policy-and-the-trillion-dollar-fight-7913f50c1730?source=rss-b2e043d8b64a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7913f50c1730</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[banking]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[congress]]></category>
            <dc:creator><![CDATA[Raghav Singh]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 19:08:11 GMT</pubDate>
            <atom:updated>2025-12-09T01:42:50.746Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*D62GDcIreuGZZ43zP9DU-A.avif" /></figure><h4>Stablecoins vs. Banks: The GENIUS Act and the Fight Over Financial Infrastructure</h4><p>The GENIUS Act, which established the first federal framework for stablecoins, has become a flashpoint in the escalating tension between the cryptocurrency industry and traditional banking. While the law prohibits stablecoin issuers from paying interest directly to holders, platforms like Coinbase and Circle have introduced “rewards” programs that functionally mimic interest-bearing accounts. Banks argue that this undermines their core business model and exposes consumers to risk, since stablecoins lack FDIC insurance and could siphon trillions in deposits away from the traditional banking system. The Treasury Department has echoed these concerns, warning of potential economic disruption if stablecoins continue to offer competitive yields.</p><p>The limitations of the GENIUS Act have sparked debate over how best to regulate the fast-evolving crypto sector. Traditional banks and their lobbyists favor targeted amendments that would close specific loopholes, such as banning “rewards” programs that mimic interest payments. Bank lobbyists are pushing for this kind of surgical intervention, arguing that it would prevent stablecoin issuers from undermining deposit-based lending without overhauling the entire regulatory landscape.</p><p>In contrast, the proposed Digital Asset Market Clarity Act is a broader framework that aims to create a comprehensive set of rules governing the entire digital asset ecosystem. This would include not only stablecoins, but also crypto exchanges, custody services, and decentralized finance platforms. Supporters of this approach argue that piecemeal fixes risk stifling innovation and creating regulatory uncertainty. They believe a holistic framework is necessary to define the roles of agencies like the SEC, CFTC, and Treasury, while also protecting consumers and ensuring market integrity.</p><p>This tension between narrow fixes and comprehensive reform reflects deeper philosophical divides: banks seek to preserve stability and control, while crypto advocates push for flexibility and innovation.</p><h4>Data Analysis — USDC Market Cap and Banking Metrics</h4><p>Over the past year,<strong> </strong>USDC’s market capitalization has shown a steady upward trend<strong>,</strong> rising from around $40 billion to nearly $70 billion, with notable growth spurts in January and July. This trajectory unfolds within a macroeconomic backdrop shaped by elevated short-term interest rates, money market fund (MMF) expansion, and a post-2023 banking system recalibration.</p><p>When risk-free yields such as those from SOFR and 3-month Treasury bills are high, the opportunity cost of holding a non-yielding stablecoin like USDC increases. This dynamic often redirects cash toward MMFs, which invest at those rates and may even channel funds into the Federal Reserve’s Overnight Reverse Repo (ON RRP) facility. Meanwhile, H.8 bank deposit data reflects shifts in traditional bank funding as consumers and institutions reallocate capital.</p><p>As of October 17, 2025, USDC’s market cap stood at approximately $75.93 billion, while U.S. commercial bank deposits totaled around $18.52T — highlighting the scale of traditional finance versus tokenized dollars. With short-term rates elevated (SOFR at 4.29%, 3-month Treasury yield at 4.03%), the opportunity cost of holding non-yielding stablecoins rises. ON RRP balances at $6.96B reflect institutional liquidity preferences, reinforcing the competitive tension between stablecoins and traditional banking products.</p><p>If you are interested in learning how to do this analysis, follow along with <a href="https://github.com/Raghav82/crypto-vs-banking-data">my code on GitHub</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*Mn92boz9oLVvucNwuu730A.png" /></figure><p>USDC’s market capitalization rose steadily over the past year, with notable surges around January and July. This upward trend reflects growing adoption of stablecoins as a viable alternative to traditional banking products. As users seek faster, lower-cost, and more accessible financial tools, USDC’s expansion signals a shift in consumer trust — from centralized banks to decentralized digital assets.</p><p>Mid-2025 saw the passage of the GENIUS Act, which created regulatory clarity that likely encouraged broader adoption of USDC. Later in the year, the Federal Reserve cut interest rates twice, in September and October, shifting monetary policy toward easing, which tends to increase risk appetite and liquidity, supporting stablecoin usage. At the same time, crypto market dynamics, including Bitcoin price rallies and ETF inflows, drove demand for stablecoins as traders positioned capital. Additionally, USDC-specific factors such as Circle’s growing integrations and exchange “rewards” programs that mimic interest-bearing accounts attracted more balances, despite regulatory scrutiny.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_kK-KIcYWNeERRIN8hmew.jpeg" /></figure><p>A comparison between USDC’s market capitalization and U.S. commercial bank deposits reveals a growing competitive tension in the financial system. While USDC has steadily climbed to nearly $76 billion, traditional bank deposits hover around $18.52 trillion, showing slower and more volatile growth. This divergence suggests a shift in consumer and institutional preferences, with tokenized dollars gaining traction as an alternative to conventional banking products.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*g3Tg48ldkAXDXus790NvvQ.png" /></figure><p>The lead-lag cross-correlation chart reveals that ON RRP (overnight reverse repo) and SOFR (secured overnight financing rate) exhibit modest leading behavior at short horizons, particularly at +1 week, implying liquidity tightening or funding cost changes often precede shifts in stablecoin supply.</p><p>Conversely, bank deposits show a slight lagging tendency, with negative correlations at -1 and -2 weeks, suggesting that deposit outflows may follow USDC expansion rather than drive it. Interestingly, the 3M Treasury yield sends mixed signals: a weak positive correlation when leading by 1–2 weeks but a stronger negative correlation when lagging, highlighting its dual role as both a liquidity proxy and a risk sentiment indicator.</p><p>USDC supply dynamics respond more acutely to shifts in short-term funding conditions than to movements in traditional banking deposits. This behavior underscores the stablecoin’s heightened sensitivity to liquidity signals and monetary policy transmission mechanisms, particularly those reflected in repo operations and SOFR rates.</p><p>When rates like SOFR and Treasury yields rise, the correlation with USDC tends to weaken or turn negative, suggesting that higher yields may divert capital away from non-yielding stablecoins. Additionally, lead-lag patterns indicate that changes in traditional financial metrics often precede movements in USDC, implying that stablecoin adoption may be reactive to broader economic trends rather than driving them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*my27YENBsrxEOwBHvCeVaA.png" /></figure><p>USDC shows a consistent upward trajectory, more than doubling from its baseline, signaling sustained growth in stablecoin adoption. In contrast, bank deposits remain virtually flat, indicating minimal movement in traditional banking liquidity relative to the rapid expansion of USDC.</p><p>The Overnight Reverse Repurchase Agreement (ON RRP), however, exhibits pronounced volatility, with sharp spikes and deep troughs, reflecting episodic liquidity absorption by the Federal Reserve.</p><p>ON RRP are short-term transactions where the Federal Reserve borrows cash from financial institutions overnight by selling them securities and agreeing to repurchase them the next day. This temporarily removes excess money from the economic system and helps the Fed control short-term interest rates. High ON RRP usage usually means there’s a lot of extra liquidity in the market, and institutions prefer to park funds safely with the Fed rather than lend elsewhere.</p><p>These fluctuations in ON RRP highlight its role as a short-term liquidity buffer. At the same time, the steady rise in USDC underscores a structural shift toward digital dollar instruments that operate independently of traditional deposit flows. The stark divergence between these series suggests that stablecoin growth is decoupled from conventional banking reserves and more influenced by broader liquidity conditions and monetary policy interventions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wY6uTudLKdh7RuCLojwUbg.png" /></figure><p>Comparing the USDC market cap with the ON RRP utilization reveals a striking divergence in institutional liquidity behavior. While USDC’s market cap steadily increased throughout the year, ON RRP balances fluctuated and ultimately declined. This suggests that institutions may be reallocating capital away from the Federal Reserve’s overnight facility and toward tokenized assets. The downward trend in ON RRP utilization, especially during periods of USDC growth, reinforces the idea that stablecoins are becoming a more attractive liquidity option, challenging the role of traditional tools in short-term cash management.</p><h4>The Trillion-Dollar Realignment</h4><p>The rise of tokenized dollars like USDC is a structural challenge to the foundations of traditional banking. As the GENIUS Act and its surrounding controversy reveal, stablecoins are forcing regulators, banks, and policymakers to confront uncomfortable questions about competition, consumer protection, and the future of financial infrastructure. The banking industry’s alarm over “rewards” programs is about defending a business model built on insured deposits and interest-bearing accounts that is now facing pressure from decentralized platforms offering speed, transparency, and yield.</p><p>There is no doubt about it, stablecoins are gaining ground. USDC’s market cap has surged while bank deposits have stagnated, and ON RRP balances have declined. Correlation and lead-lag analysis show that stablecoin adoption is increasingly responsive to macroeconomic conditions, particularly interest rates and institutional liquidity flows. Normalized trend comparisons reveal that USDC is outpacing legacy financial instruments in relative growth, and the divergence between USDC and ON RRP utilization suggests a reallocation of institutional capital toward digital assets.</p><p>Stablecoins offer programmable liquidity, global reach, and real-time settlement, features that legacy systems struggle to match. Yet they also raise questions about systemic risk, regulatory oversight, and consumer safeguards. The GENIUS Act may be the first attempt to draw boundaries, but the fight over how to regulate, integrate, or resist tokenized finance is far from over.</p><p>Behind the scenes, the bank lobby is a powerful force shaping this debate, pushing for narrow fixes that protect deposit-based lending and preserve its dominance in the financial system. But trust is a central issue on both sides: as public confidence in institutions and government continues to erode, people are increasingly turning to decentralized alternatives. This shift threatens the stability of traditional finance, which relies on trust in regulated systems, insured deposits, and centralized oversight.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7913f50c1730" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Forecasting U.S. Inflation with Prophet and FRED API: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@raghavsingh4161/forecasting-u-s-inflation-with-prophet-and-fred-api-a-step-by-step-guide-72c527fd2a58?source=rss-b2e043d8b64a------2</link>
            <guid isPermaLink="false">https://medium.com/p/72c527fd2a58</guid>
            <category><![CDATA[education]]></category>
            <category><![CDATA[inflation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Raghav Singh]]></dc:creator>
            <pubDate>Wed, 15 Oct 2025 20:15:55 GMT</pubDate>
            <atom:updated>2025-10-16T21:53:39.004Z</atom:updated>
            <content:encoded><![CDATA[<p>Inflation affects everything — from the price of groceries to the cost of borrowing. As a business intelligence developer, I wanted to explore how we can use machine learning to forecast inflation trends using publicly available data. In this project, I used the FRED API (Federal Reserve Economic Data API) to retrieve Consumer Price Index (CPI) data and Prophet, a powerful time series forecasting tool developed by Meta, to predict future inflation.</p><p>This article walks you through the entire process — from data collection to model evaluation — and shows how you can build your own inflation forecasting model in Python.</p><p>We start by installing the necessary packages and importing libraries. The complete code is in my <a href="https://github.com/Raghav82/CPI-Prediction-With-Prophet">GitHub repository</a>.</p><pre>#Install Fred API, Scikit Learn, and Prophet<br>!pip install fredapi<br>!pip install scikit-learn<br>!pip install prophet<br><br>#Import Libraries<br>import fredapi as fa<br>import pandas as pd<br>import plotly.express as px<br>from prophet import Prophet<br>from prophet.diagnostics import cross_validation,performance_metrics<br>from prophet.plot import plot_cross_validation_metric</pre><p>Next, we are going to use our API key and get time series data. You can request yours on <a href="https://fred.stlouisfed.org/">https://fred.stlouisfed.org/</a>. You can also find the dataset codes there. We are looking at the most popular CPI dataset, which is CPIAUCSL</p><pre>#Save API key to a variable<br>fred = fa.Fred(api_key=&#39;Put your key in here&#39;)<br><br>#get CPI series<br>cpi_series = fred.get_series(&#39;CPIAUCSL&#39;)</pre><p>Now we need to do some data cleaning to get it into the correct format. We are going to rename the series ‘values’ to avoid an unnamed column error and create an index column.</p><p>So we have:</p><pre>Date         Value<br>1990-01-01    130.7<br>1990-02-01    131.2<br>...</pre><p>And we want:</p><pre>index   values<br>0  1990-01-01   130.7<br>1  1990-02-01   131.2<br>...</pre><p>In our code, we can achieve this by using the reset_index function. Before we do so, we will name our series to avoid an unnamed column error.</p><pre># Renamed the series so that when it&#39;s converted to a dataframe, the column will be labeled &#39;values&#39; to avoid possible unnamed column errors<br>cpi_series.name = &#39;values&#39;<br><br># Convert the time series into a DataFrame by turning the date index into a column<br>. df = cpi_series.reset_index()</pre><p>I am going to create a subset of the data to start from 1990.</p><pre>#Create a subset starting from 1990<br>df2 = df[df[&#39;index&#39;]&gt; &#39;1989-12-01&#39;]<br></pre><p>Now we can plot this using the plot.line() pandas dataframe method.</p><pre>#Plot CPI data from 1990 - 2022<br>fig = df2.plot.line( x=&#39;index&#39;, y = &#39;values&#39; , title = &#39;CPI Average 1990 - 2022&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*g1YhmUgBKIO7uY1Jxn3DHw.png" /></figure><p>Now I want to introduce you to Plotly Express, which is an invaluable tool for creating interactive plots. Unlike static charts, this interactive line graph allows readers to hover over each year to see the exact CPI value, zoom into specific time periods, and pan across the timeline. This interactivity makes it easier to spot trends, such as the steady rise in CPI over the decades and the inflation spikes around 2008 and 2021.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bhIvsrn1bbHjypVairBhRQ.png" /></figure><p>The toolbar on the top right allows you to download the graph as a .png, zoom, pan, or reset the axis. With a Plotly account, you can use Chart Studio to share, embed, or collaborate with other users.</p><h4>Prophet</h4><p>Now, let’s use Meta to forecast CPI trends for the next decade. First, we need to rename our columns so that they are compatible with Prophet.</p><pre># Rename columns for Prophet compatibility<br>df2 = df2.rename(columns = {&#39;index&#39; : &#39;ds&#39;, &#39;values&#39;:&#39;y&#39;})</pre><p>Prophet is a forecasting tool developed by Facebook that is designed to model time series data. It’s not a neural network or deep learning model. Instead, it uses a statistical approach to break down time series into components like trend, seasonality, and holiday effects. This makes it easy to interpret and ideal for business and economic forecasting.</p><p>Now, we are going to create the model.</p><pre># Initialize the Prophet model<br>ml = Prophet()</pre><p>At this point, the model has been created, but it is empty. We need to train it. The fit() function in Prophet trains the time series model using historical data. It applies a Bayesian approach to estimate the optimal parameters for key components like trend, seasonality, and holiday effects. The input data must include a ‘ds’ column for timestamps and a ‘y ’column for observed values.</p><pre>ml.fit(df2)</pre><p>With the model trained, let’s create a dataframe to represent the future duration over which we want to make a prediction.</p><pre># Create future dataframe for prediction (next 10 years = 120 months)<br>future = ml.make_future_dataframe(periods=120 , freq = &#39;MS&#39;)</pre><p>This line uses the trained Prophet model to generate forecasts for all dates in the ‘future’ DataFrame. The output includes predicted values (yhat) along with uncertainty intervals (yhat_lower, yhat_upper)and component breakdowns like trend and seasonality.</p><pre># Predict future CPI values<br>result = ml.predict(future)</pre><p>To make plotting and forecasting easier, let’s get rid of some unnecessary columns.</p><pre>result[[&#39;ds&#39;,&#39;yhat&#39;,&#39;yhat_lower&#39;, &#39;yhat_upper&#39;]]</pre><p>Now we can easily plot using the built-in function. This line generates a plot of the overall forecast. It shows the predicted values (yhat) over time, along with the uncertainty intervals (yhat_lower, yhat_upper). The plot includes both historical data and future projections, giving a clear visual of the model’s forecast.</p><pre>fig2 = ml.plot(result)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hFfaYyZWyvJ3cwv9XXzMQ.png" /></figure><p>The plot_components() function creates individual plots for each component that contributes to the forecast. These include the overall trend, seasonal patterns (such as yearly or weekly cycles), and any specified holiday effects. By breaking down the forecast into its parts, this visualization helps you understand how each factor influences the predicted values over time.</p><pre>fig2 = ml.plot_components(result)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfMegn_t8IpfGPsmBwgSYQ.png" /></figure><h4>Cross Validation</h4><p>Now that we have made a prediction, let’s do cross-validation. Cross-validation is a technique used to evaluate a model’s performance by testing it on unseen data. Instead of training and testing on the same dataset, the data is split into multiple segments. The model is trained on one part and tested on another to see how well it generalizes to new data.</p><p>In time series forecasting, cross-validation is different because the order of data matters. Prophet uses rolling or sliding windows to simulate forecasting at different points in time.</p><pre>cv_results = cross_validation(<br>    model=ml,<br>    initial=pd.Timedelta(days=30*20),   # 20 months of training data<br>    period=pd.Timedelta(days=30*5),     # Make a new forecast every 5 months<br>    horizon=pd.Timedelta(days=30*12)    # Forecast 12 months into the future<br>)<br>``</pre><ul><li>Initial: The amount of data used to train the model in each round (20 months).</li><li>Period: How often to make a new forecast (every 5 months).</li><li>Horizon: How far into the future each forecast goes (12 months).</li></ul><p>Next, we will take the results from Prophet’s cross-validation and compute a set of performance metrics that help evaluate how well the model forecasts future values.</p><p>These metrics include:</p><ul><li><strong>RMSE (Root Mean Squared Error)</strong>: Measures the average magnitude of forecast errors. Lower values indicate better accuracy.</li><li><strong>MAE (Mean Absolute Error)</strong>: The average absolute difference between predicted and actual values.</li><li><strong>MAPE (Mean Absolute Percentage Error)</strong>: Shows the error as a percentage, which helps in understanding relative accuracy.</li><li><strong>Coverage</strong>: Indicates how often the true value falls within the forecast’s uncertainty interval.</li></ul><pre># Calculate performance metrics<br>df_pm=performance_metrics(cv_results)<br>df_pm.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhHE9bf7pHGbcbkTuNLEvQ.png" /></figure><p>This plot helps you evaluate how reliable your model is over time. If RMSE stays low across all horizons, your model is consistently accurate. If it spikes at longer horizons, you might need to adjust your model or limit how far ahead you forecast.</p><pre># Plot RMSE metric from cross-validation<br>fig_cvm = plot_cross_validation_metric(cv_results,metric=&#39;rmse&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_BtvMLOxQl_oUXxrBZPiAA.png" /></figure><p>The RMSE vs. Horizon graph illustrates how the model’s forecast accuracy changes as it predicts further into the future. The x-axis represents the forecast horizon in days — essentially how far ahead the model is trying to predict. The y-axis shows the Root Mean Squared Error (RMSE), which measures the average difference between the expected and actual values. Lower RMSE values indicate better accuracy.</p><p>Each grey dot on the graph corresponds to an individual RMSE value from a specific cross-validation fold, while the blue line shows a smoothed trend of how RMSE behaves across different horizons. In this case, the RMSE values mostly stay below 10, suggesting that the model maintains consistent accuracy across both short-term and long-term forecasts. There’s no sharp increase in error as the horizon grows, which means the model performs reliably even when forecasting up to a year ahead. The slight fluctuations are normal and reflect natural variability in the data or model performance across different time windows.</p><h4>Conclusion</h4><p>In this project, we demonstrated how machine learning — specifically, Prophet — can be used to forecast inflation trends using publicly available CPI data from the FRED API. We walked through the entire pipeline: data collection, cleaning, visualization, model training, forecasting, and evaluation.</p><p>One of the key takeaways from this analysis is how well Prophet handles long-term forecasting with minimal configuration. The model was able to capture both the steady upward trend in CPI and the seasonal fluctuations that occur year to year. By using cross-validation, we were able to assess the model’s reliability across different forecast horizons and identify where its predictions remain strong and where they begin to diverge.</p><p>The RMSE plot revealed that while short-term forecasts are pretty accurate, the error tends to increase as we look further into the future — a common challenge in time series forecasting. This insight is valuable for policymakers, analysts, and businesses who rely on inflation forecasts to make strategic decisions.</p><p>Overall, this project shows that with just a few lines of Python code and the right tools, anyone can build a robust inflation forecasting model. It also highlights the importance of evaluating model performance, not just generating predictions — a step often overlooked in beginner projects. Whether you’re a student, data scientist, or economist, this approach offers a scalable and interpretable way to explore economic trends.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72c527fd2a58" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>