<?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 Nima Aref on Medium]]></title>
        <description><![CDATA[Stories by Nima Aref on Medium]]></description>
        <link>https://medium.com/@nima.aref6?source=rss-6f7c2c4a83e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MMMrIJD1iBDKypzqXR-WIA@2x.jpeg</url>
            <title>Stories by Nima Aref on Medium</title>
            <link>https://medium.com/@nima.aref6?source=rss-6f7c2c4a83e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 10:23:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nima.aref6/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[Taming the Braze Pipeline: How We Turned 300 Lines of SQL Into a CSV Row]]></title>
            <link>https://koho.dev/taming-the-braze-pipeline-how-we-turned-300-lines-of-sql-into-a-csv-row-0387f74aff71?source=rss-6f7c2c4a83e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/0387f74aff71</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Nima Aref]]></dc:creator>
            <pubDate>Fri, 20 Mar 2026 15:55:42 GMT</pubDate>
            <atom:updated>2026-03-20T15:55:42.665Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a seed file, six macros, and a well-prepared Claude session turned a pipeline nobody wanted to touch into one anyone can extend.</em></p><p>There’s a certain kind of SQL file that haunts every data team. You know the one. It works. Nobody’s sure exactly how. Nobody wants to find out.</p><p>Ours was report_snapshotted_user_attributes.sql, a 300-line monolith responsible for syncing user attributes from Redshift to Braze via Cloud Data Ingestion (CDI). It generated JSON payloads, detected attribute changes, and did a handful of other things that took real effort to understand. It had been written by smart people with good intentions. It had accreted logic over time, the way all pipelines do.</p><p>And every time the marketing team said <em>“hey, can we add a new attribute to Braze?”</em> A beat of silence would fall over the data team Slack channel.</p><h3>The Problem with Handcrafted JSON</h3><p>Before we get into the fix, a quick primer on what this pipeline actually does.</p><p>Braze is our customer engagement platform: it’s how KOHO sends push notifications, emails, and in-app messages. To make campaigns genuinely personalized, we sync user attributes from our data warehouse into Braze daily: things like active account, time since last activity, product eligibility flags, and more.</p><p>There are two ways to keep Braze user profiles up to date. The first is backend events: when a user takes an action, your application fires it directly to Braze in real time, but not every attribute can be expressed as a single event. When you need a rolling inactivity window, a product count, or a lifecycle state derived from months of history, you calculate it in your data warehouse and push the result to Braze on a schedule.</p><p>The pipeline uses <strong>Braze Cloud Data Ingestion (CDI)</strong>, a feature that pulls a JSON payload from Redshift on a schedule and merges it into Braze user profiles. Two key constraints:</p><ol><li>Every attribute needs to be formatted as a specific JSON key-value pair.</li><li>Only <em>changed</em> attributes should be sent (Braze charges per data point, so unnecessary sends add up fast).</li></ol><p>In practice, this meant our SQL had to:</p><ol><li>Pull the two most recent daily snapshots of user attributes</li><li>Compare current vs. previous state for every attribute</li><li>Format changed attributes as JSON (Redshift’s native JSON functions are limited, so most of the heavy lifting fell to string manipulation)</li><li>Handle type differences (booleans, strings, numbers) differently</li><li>Handle NULL values correctly per attribute</li></ol><p>Do that for 25+ attributes in raw SQL, and you get a lot of SQL. Each attribute was essentially handcrafted: its own comparison logic, its own JSON formatting, its own NULL handling. The structure was technically sound but fragile: a tower of perfectly balanced coins. Impressive to look at, terrifying to touch.</p><p>Adding a new attribute meant understanding the entire pattern, finding the right places to insert code across multiple files, and hoping you hadn’t missed anything.</p><h3>A Quiet Holiday, A Methodical Approach</h3><p>This refactor was next up on the sprint: well understood, clearly needed, and overdue for attention. The Christmas code freeze happened to be the right window, with focused time and no competing priorities pulling in other directions.</p><p>The approach: do the homework before touching any code.</p><p>We read through all the existing documentation: the architecture notes, the Notion context docs, everything that had been written down about how the pipeline worked and why decisions had been made. We made our own notes. We used Glean (our internal knowledge search tool) to fill in gaps about company context and ask questions we couldn’t answer from the docs alone. By the time we sat down to plan the refactor, we had a real mental model of what existed and what needed to change.</p><p>That preparation was the difference. The planning session wasn’t about offloading the thinking; it was about landing on a foolproof solution with the full picture already in hand. I used Claude to stress-test different approaches against the real constraints (Braze’s payload format, our Redshift data types, the change-detection requirement) and landed on a design before a single line of new code was written.</p><p>The solution: <strong>a seed-and-macro approach</strong>, where all attribute configuration lives in a single CSV file, and a set of macros dynamically generates the SQL at compile time.</p><h3>What We Built</h3><p>The solution has two parts that work together.</p><p>seeds__braze_attribute_config.csv defines every attribute in one place: seven columns capturing the Redshift source name, the Braze key, type information, NULL handling, and a description. Six dbt macros read from that seed at compile time and dynamically generate all the SQL: the column list, change-detection logic, type handling, JSON assembly. The model files themselves are nearly empty.</p><figure><img alt="Our new pipeline via seed + macro based approach." src="https://cdn-images-1.medium.com/max/1024/1*pTMAOtlKXFgksrA7vp5W6w.png" /></figure><p>Before, adding a new attribute meant reviewing 300 lines of handcrafted SQL, finding every place the pattern repeated, and carefully inserting your changes without breaking anything. Now it’s three steps:</p><ol><li>Add the column to the base model</li><li>Add one row to the CSV</li><li>Run your standard QA checks</li></ol><p>The next step was carefully deploying this change. We ran both pipelines in parallel for a couple of weeks against the same data. Zero mismatches. After cutover, we added three new attribute sets in quick succession. Each a small, focused PR. Work that would have taken <strong>at least a week</strong> to build and QA under the old design. The team is now shipping them routinely with high confidence. And these updates now come as part of the PR for building the initial attribute into the mart. It used to be a separate piece of work to prioritize; now it’s a checklist item.</p><h3>What We Didn’t Expect</h3><p>When we presented to the broader team, we found out the Braze pipeline had been on a shortlist of problems the team was exploring outside vendor solutions for. We’d just built it in-house, as a focused sprint task, in less time than a procurement process would have taken.</p><p>The other thing we didn’t see coming was the documentation problem it quietly solved. We had a handful of scattered spreadsheets with vague, half-maintained descriptions of what each attribute meant. The seed replaced all of them: every attribute already had a description column, so we surfaced it directly in a single Notion database using the MCP: type, freshness, default behaviour, always current. Documentation that stays in sync with the code sounds obvious. Usually, there’s a reason it doesn’t happen.</p><p>The technical patterns here are well-established dbt patterns for good reason. What’s worth passing on is something less technical: <strong>preparation before AI, not instead of it.</strong> The planning session worked because we showed up with a real understanding of the system: notes from the docs, context from Glean, and a clear picture of the constraints. AI is a good thinking partner when you bring the context. It’s a much weaker one when you’re asking it to build that context from scratch.</p><p>We turned a pipeline nobody wanted to touch into one where adding a new attribute is a genuinely low-stakes afternoon. That’s the win. And it’s a useful reminder that AI-assisted development isn’t just about shipping new things faster; it’s just as applicable to finally clearing the work that was always understood but never prioritized.</p><p><em>The refactored pipeline shipped in January 2026. This was a team effort. Thanks to everyone who reviewed PRs, asked hard questions, and helped think through the edge cases.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0387f74aff71" width="1" height="1" alt=""><hr><p><a href="https://koho.dev/taming-the-braze-pipeline-how-we-turned-300-lines-of-sql-into-a-csv-row-0387f74aff71">Taming the Braze Pipeline: How We Turned 300 Lines of SQL Into a CSV Row</a> was originally published in <a href="https://koho.dev/">KOHO Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Much Does Rushing Still Matter in the NFL? I Built a Model to Find Out.]]></title>
            <link>https://medium.com/@nima.aref6/how-much-does-rushing-still-matter-in-the-nfl-i-built-a-model-to-find-out-c88729183e3a?source=rss-6f7c2c4a83e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c88729183e3a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[nfl]]></category>
            <dc:creator><![CDATA[Nima Aref]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 18:14:56 GMT</pubDate>
            <atom:updated>2025-07-07T18:14:56.857Z</atom:updated>
            <content:encoded><![CDATA[<h4>Saquon Barkley, Super Bowl winner. Neil, my game-predicting model. And the surprising data behind who wins NFL games.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X2sAA6i6DohxghzR" /><figcaption>Saquon Barkely post Super Bowl championship.</figcaption></figure><p>If you watched <em>Hard Knocks</em>, followed Saquon Barkley’s contract drama, or play fantasy football, you’ve likely heard this debate:</p><p>“Does the run game really matter anymore?”</p><p>In an era of pass-happy offenses and analytics-driven front offices, running backs have been devalued. Barkley’s own team, the New York Giants, let him test free agency, ultimately watching him sign a 3-year, $37.75M deal with Philadelphia.</p><p><strong>The result?</strong></p><ul><li>Barkley broke Terrell Davis’ record for most rushing yards in a season (including playoffs): <strong>2,504 yards.</strong></li><li>He became the first player in NFL history to rush for 2,500+ yards in a season and the third to lead the league in rushing <strong>and</strong> win the Super Bowl.</li></ul><p>That got me thinking:</p><p><strong>What does the data actually say about rushing and winning in today’s NFL?</strong></p><h3>Rushing &gt; Passing &gt; Receiving</h3><p>When I looked at the results, the message was clear: <strong>rushing still matters a lot.</strong></p><p>Here’s how teams performed based on where they ranked for yardage in a given game (2018–2024):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*re_AWzsN8JPOgUql" /><figcaption>Rushing shows a higher impact to winning compared to passing and receiving.</figcaption></figure><p><strong>Rushing yards</strong></p><ul><li><strong>Top 25% of games</strong> → teams won <strong>70–75%</strong> of the time</li><li><strong>Bottom 25% of games</strong> → teams won <strong>~25–30%</strong> of the time</li></ul><p><strong>Passing yards &amp; Receiving yards</strong></p><ul><li><strong>Top 25%</strong> → ~55–60% win rate</li><li><strong>Bottom 25%</strong> → ~45–50% win rate</li></ul><p>I found this visual striking as it showed the difference it makes in a good running vs a good passing/receiving game.</p><h3>Building Neil</h3><p>At the start of the 2024 season, I wanted to build a simple model to predict weekly NFL games. It began as a fun side project: a basic notebook that pulled data using the nfl-data-py Python library, ran some logic, and generated weekly picks. I called the model <em>Neil</em>.</p><p>By the end of the season, I decided to formalize the process. I moved the code into a structured GitHub project and improved it with better engineering practices. With the help of LLMs like ChatGPT, I picked up some best practices around project structure, debugging, and reproducibility.</p><p>For training data, I used historical NFL results from 2018 through 2023. To simulate a true week-to-week prediction flow, I used a 3-week rolling average of team stats (rushing, passing, receiving, defensive, and turnover metrics) using only the most recent games available prior to each matchup. This ensured the model was learning from <em>realistic in-season signals</em>, not full-season hindsight.</p><p>For 2024, I treated the full season as an out-of-sample test set, generating weekly predictions with no data leakage from future games.</p><p>To improve model quality, I expanded the feature set and followed stronger modeling practices:</p><ul><li>I included difference features capturing the gap between each team’s scoring, defensive, and turnover stats.</li><li>I randomized which team was treated as “team 1” vs “team 2” in each row to prevent the model from learning positional bias based on team order.</li></ul><p>After retraining and backtesting Neil, I found that the improved version landed at about <strong>65% accuracy, a solid</strong> lift over the original version.</p><p><strong>How did it perform week to week?</strong></p><p>Neil started out uneven, struggled early, then spiked in Week 6 and delivered strong performance heading into the playoffs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/0*pdGNQIOAmwpp7wcv" /><figcaption>Peaks viewed in week 6 then continuous performance up until playoffs.</figcaption></figure><p>Cumulatively, the model’s accuracy steadily improved over the course of the season, ultimately landing around <strong>65% overall</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/0*MVmIUrYUnPA2j1Qv" /></figure><h3>Did Neil Beat the Market?</h3><p>To benchmark Neil’s performance, I tested two simple strategies:</p><ul><li>Bet 1 unit on Neil’s predicted winner (moneyline)</li><li>Bet 1 unit on the favorite (every game)</li></ul><p>(For clean results, I limited this to Weeks 1–17, avoiding noise from late-season rest weeks and playoff rotations.)</p><p><strong>Results:</strong></p><ol><li><strong>Neil’s Picks : </strong>+15.8 units</li><li><strong>Favorites Only:</strong> +12.0 units net</li></ol><p>Neil outperformed betting favorites and did so consistently across the season.</p><p>Here’s how it played out week to week:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JDph4WubS6wnYNNH" /></figure><p>And viewed cumulatively:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lL-QzDUlZINCgy1w" /></figure><p>Neil not only outperformed the baseline favorites strategy, it also built a steadier profit curve through the heart of the season. If you had followed the model, you would have finished ahead of a simple favorites betting approach.</p><h3>Favorite vs Dog — How Did Neil Play It?</h3><p>I broke down Neil’s picks by category:</p><ul><li><strong>Favorite winner:</strong> 112 games</li><li><strong>Favorite loser:</strong> 90 games</li><li><strong>Dog winner:</strong> 25 games</li><li><strong>Dog loser:</strong> 58 games</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pRSpb2y_HssGUDpv" /></figure><p>Neil leaned favorites (~71% of picks), but wasn’t afraid to call an underdog. And when it did? It nailed some key ones including the <strong>Eagles in the Super Bowl</strong> (with Barkley in the backfield).</p><h3>What Mattered Most</h3><p>When I looked at feature importance across the season, several patterns emerged:</p><ul><li><strong>Rushing yard differential</strong> consistently ranked among the top 2–3 most important features. The old-school view that “running the ball wins games” still holds water. Teams that control the ground game are far more likely to win.</li><li><strong>Reception rate differentia</strong>l was the single most consistently important feature across all weeks. Passing volume alone wasn’t predictive, but how efficiently teams passed mattered greatly.</li><li><strong>Turnover differential </strong>showed up as a top factor week after week. This is no surprise: teams that win the turnover battle win the game more often than not.</li><li><strong>Market signals (moneyline odds)</strong> were also highly influential which is expected. The betting market is efficient, and odds reflect a lot of underlying information. However, I plan to rerun the model without moneyline data to better test its independent predictive power.</li></ul><p>In short: running the ball, protecting the ball, and passing efficiently remain the strongest signals of NFL success and Neil’s picks reflected that.</p><h3>What’s Next?</h3><p>I’m happy with the results, but excited to push forward with some improvements:</p><ul><li>Digging deeper in rushing, passing, receiving, and turnover metrics to create additional features.</li><li>Completing some hyperparameter tuning using tools like XG boost.</li><li>Create a public facing website highlighting Neil’s picks.</li></ul><h3>Final Takeaway</h3><p><strong>Rushing still matters. A lot.</strong></p><p>In an era where every NFL broadcast hypes air yards and next-gen passing stats, it’s easy to forget: <strong>the ability to run the ball and control games still wins championships.</strong></p><p>Just ask Saquon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c88729183e3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>