<?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 Shraddha Sunil Parakh on Medium]]></title>
        <description><![CDATA[Stories by Shraddha Sunil Parakh on Medium]]></description>
        <link>https://medium.com/@shraddhasunilparakh?source=rss-bd3550ff0b72------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*JKVHfkrRbo4jIQeV</url>
            <title>Stories by Shraddha Sunil Parakh on Medium</title>
            <link>https://medium.com/@shraddhasunilparakh?source=rss-bd3550ff0b72------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:57:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shraddhasunilparakh/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[From 7 Messy Files to One Clear Story: Leading a Healthcare Analytics Hackathon]]></title>
            <link>https://medium.com/@shraddhasunilparakh/from-7-messy-files-to-one-clear-story-leading-a-healthcare-analytics-hackathon-fe45ca78d97e?source=rss-bd3550ff0b72------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe45ca78d97e</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[healthcareanalyst]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Shraddha Sunil Parakh]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 21:21:23 GMT</pubDate>
            <atom:updated>2026-10-22T21:21:23.218Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vnvLExsUjFzbmE8re4xKQ.png" /></figure><h4><em>Heart Failure Analytics, Part 1: one week, four teammates, 2,008 patients, and the number that changed our plan.</em></h4><p>Two numbers in our descriptive notebook didn’t agree.</p><p>One question counted comorbidities and found that 23.6% of our patients had chronic kidney disease. Another looked at a lab test, GFR, and found that 45.6% had kidney function below the clinical cut-off of 60. Same patients, same hospital stay. The second number came from a question we almost didn’t ask.</p><p>They weren’t really contradicting each other. One was a diagnosis that someone had written down at some point. The other measured how the kidneys were working during that admission. But the gap between them, nearly double, ended up shaping almost everything else we did.</p><p>This is the story of that week. In September 2026 I led Team 11 PyInsights, a team of four, through a Python hackathon organized by Numpy Ninja from September 22 to 29.</p><h4><strong>The brief:</strong></h4><p>Every team got the same dataset: the Zigong heart failure dataset from PhysioNet. It covers 2,008 patients admitted to a hospital in Zigong, China, with 168 variables split across seven CSV files: demographics, the hospital stay and its outcomes, lab results, heart condition and scan results, medical history, consciousness scores and prescriptions.</p><p>In one week we had to clean it, describe the patients in up to 10 questions (<em>descriptive analysis</em>), test how patient factors relate to each other and to outcomes in up to 30 more (<em>what the hackathon called prescriptive analysis</em>), build predictive models on what those relationships showed, and ship a working Python dashboard.</p><p>The brief was clear that the analysis should build into a story. Descriptive questions should set the stage, the variables in prescriptive analysis shouldn’t look random, and a model should exist because earlier findings called for one, not for its own sake. With 198 columns in our master table and four people working in parallel, the easy way to fail was 44 questions that didn’t connect. So I made the thread the rule: who are these patients, what happens to them, what drives it, and can we predict it? Each question had to help us decide what to look at next, and we wrote down why we were asking it before showing the result.</p><h4>The decision I wasn’t sure about:</h4><p>Nothing in the brief said we had to combine the seven files; whether to merge them, and how, was up to us. From my previous hackathon, I’d learned that working from one master table saves a lot of trouble later: every notebook starts from the same data. But one file didn’t fit. Six of the seven had one row per patient. Prescriptions had one row per drug: 15,362 rows for 2,007 patients. Join them as they were and each patient appears about 7.6 times on average, so every count and every average comes out quietly wrong.</p><p>I weighed two options. We could keep prescriptions as a separate table and bring it in only when a question needed it. Or we could reshape it into one row per patient, with a drug count and a yes/no column for each of the 25 drugs, and fold it into the master. I chose the second, and as a team we worked out the joins and built a single master table that every notebook and the dashboard would load. We checked the result in code: 2,008 rows, 198 columns, no duplicate patient IDs.</p><p>Even after deciding, I had doubts about how it would turn out. Summarizing a file means changing its shape, and I worried we’d lose detail a later question might need. I also worried the team would stop thinking about the detailed file once it was out of sight. So we kept it as a separate, frozen table next to the master, in case anyone needed to go back to it.</p><p>The worry turned out to be smaller than it felt. The detailed file held only two columns, patient ID and drug name, with no doses, no dates and no repeated pairs. The 25 yes/no columns captured all of it, and no later notebook needed the original.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*WrpOs90CZJDORcLCBlRJGA.png" /><figcaption><em>Prescriptions summarized to one row per patient, then joined and checked in code: 2,008 rows, 198 columns, no duplicate patient IDs. Code from our cleaning notebook, reformatted for readability.</em></figcaption></figure><h4>Cleaning: prove it’s wrong before you change it</h4><p>The rule I kept coming back to was simple: change a value only when we can show it can’t be real. In the whole project we deleted one record, a placeholder ID that appeared in no other table.</p><p>Most blanks stayed blank. Heart-scan values were missing for 35–91% of patients, because not every patient gets a scan. Filling those gaps with averages would have invented readings nobody took.</p><p>What we did fix were values no patient could have: 11 vital signs recorded as zero, three weights of zero, four heights outside 1.2–2.2 m, and 18 heart-valve readings with a slipped decimal point (409 instead of 4.09). For the valve readings we tested our fix against a column we hadn’t touched. The existing E/A ratio agreed with the corrected values in 381 of 392 rows.</p><p>Saying no to a fix mattered as much as making one. A proposed rule would have set Killip grade to 1, the mildest level, for every patient without a heart attack. That would have changed 1,366 of our 2,008 patients, 68% of the cohort. But Killip grade comes from clinical signs, such as crackles in the lungs, fluid on the lungs or shock, not from whether someone had a heart attack, and the data dictionary gave no basis for the rule. When we reviewed it, we turned it down, and the grades stayed as recorded.</p><p>Some records contradicted themselves, such as an outcome of “Alive” with a discharge destination of “Died”. The data dictionary doesn’t say which field wins, so we added flag columns rather than picking one.</p><p>GFR was recorded for 1,945 of 2,008 patients, so the kidney figures that follow come from real measurements, not filled-in ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*P50QYfDm-IKB3Pg31ijAug.png" /><figcaption>We changed only values no patient could have: zero vital signs set to missing, and decimal-entry errors corrected and cross-checked against the E/A ratio. <em>Code images are from our cleaning notebook, reformatted for readability. No patient-level data is shown.</em></figcaption></figure><h4>Following the kidney thread:</h4><p>It started with a simple count. When we listed patients’ other illnesses, chronic kidney disease was the most common, at 23.6%. But that flag is a recorded diagnosis, not a measurement.</p><p>Looking at our list of descriptive questions, we saw a gap. Heart and kidneys affect each other: a weak heart reduces blood flow to the kidneys, and weak kidneys hold on to fluid that strains the heart further. Yet none of our questions measured kidney function. So we added one on GFR.</p><p>Before running it, we wrote down what we expected: more patients would show impaired kidneys by the lab value than by the diagnosis flag. We also wrote down the obvious objection, that GFR might just repeat the flag. Our answer was that a flag shows what was recorded and GFR shows what was measured, so finding out whether they differ is a result in itself.</p><p>They differed. 886 of 1,945 patients with a GFR result, 45.6%, were below 60.</p><p>Then we tested the gap head-on. On paper the two should overlap, because the data dictionary defines the CKD flag with the same cut-off of 60. But they aren’t interchangeable. Chronic kidney disease means kidney function stays low for months, and one test during a heart failure admission can’t show that. So we treated it as a data-consistency question: how often do the two agree in this dataset? Less often than we expected: 479 patients had low GFR but no CKD flag, while only 55 had the flag with normal GFR, and agreement beyond chance was only moderate (Cohen’s kappa 0.42). From then on, measured GFR was our kidney variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*gEJ-cyi0thlPGhiDlNYmBw.png" /><figcaption>Measured kidney function (GFR) for 1,945 patients. Everything left of the dashed line at 60 counts as impaired: 45.6% of patients.</figcaption></figure><p>The next question was whether it mattered for what happened to patients. It did. Within six months, 44.8% of patients with GFR below 60 were readmitted, compared with 33.6% of those above it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*ReZaD8re0f_uwl5MzCRTCQ.png" /><figcaption>Six-month readmission was 44.8% for patients with GFR below 60, against 33.6% for those above it.</figcaption></figure><p>The comparison that stood out came when we split patients by both heart severity and kidney function. A patient with mild heart failure (NYHA class 2) and weak kidneys was readmitted about as often (40.9%) as one with severe heart failure (class 4) and healthy kidneys (42.2%). The test for that pattern gave p = 0.086, so we called it a trend, not a proven effect. Even so, it suggests that heart severity alone can make some patients look safer than they are.</p><p>Not every finding deserved that much attention. Patients on more medications stayed longer (Spearman 0.28, p &lt; 0.001), and each extra drug still meant about 0.64 more days after adjusting for severity. But drug count explained only 3.9% of the variation in stay length. With 2,008 patients even a weak link passes a significance test, so we reported it as real but minor, and as an association rather than a cause.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*29iORxbQWA_7D-aK3Gn3iw.png" /><figcaption>Each dot is one patient. More medications went with slightly longer stays (Spearman 0.28), but drug count explains only 3.9% of stay length.</figcaption></figure><h4>Can we predict it?</h4><p>Only 57 of the 2,008 patients died within six months. A model that predicts “everyone survives” is 97.2% accurate and catches none of those deaths. So, we chose our measure before building anything: ROC-AUC, which asks how well a model ranks higher-risk patients above lower-risk ones.</p><p>Our mortality model used only information available at admission. It scored 0.80, against 0.72 for heart severity alone, tested with repeated cross-validation and a permutation test (p = 0.005). That evidence comes from one hospital; the model hasn’t been tested on patients from anywhere else. Kidney function was one of its three clearest predictors, alongside Killip grade and BNP. The 20% of patients it ranked highest included 36 of the 57 deaths. That makes it a list for closer follow-up, not a diagnosis: about 1 in 11 flagged patients died.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*GmzuEJJIz5Bd8R2AJpufXQ.png" /><figcaption><em>Left: the admission-time model (AUC 0.80) ranks patients better than heart severity alone (0.72). Right: precision stays low because only 2.8% of patients died.</em></figcaption></figure><p>Readmission was a different story. Our models scored 0.54 for six months and 0.62 for 28 days. For comparison, <a href="https://bmjopen.bmj.com/content/11/8/e047576">a systematic review in BMJ Open</a> found that published heart failure readmission models average about 0.64. We reported the weak results as they were, and I come back to why below.</p><h4>Dashboard and teamwork:</h4><p>We brought it all together in a Stream lit dashboard that answers all 44 questions from the same master table, so a number on a slide always matched the one on screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*sx_T_UHEXlU6Vii5FzncHg.png" /><figcaption>We brought it all together in a Stream lit dashboard that answers all 44 questions, with every chart drawn from the same master table, so a number on a slide always matched the one on screen.</figcaption></figure><p>Behind it were four people working in parallel for eight days: 7 branches, 17 merged pull requests and 108 commits. Our biggest problem was the same notebook existing in several versions under different names; agreeing one naming pattern fixed it.</p><p>A lot of my week went into review. I checked findings before they went into the final notebooks, and realigned work to the method we’d agreed when it drifted. Next time I’d set up branches, file names and a protected main branch on day one, before anyone writes code.</p><h4>One mistake, and one I found later:</h4><p>In the Technical Challenges round on October 9, the organizers asked us to name one mistake we’d made in our analysis, and then what we’d do differently.</p><p>I said our mistake came from the choice I’d pushed for: depth over breadth. It gave us the kidney story, but it also meant we never properly studied several biomarkers in the dataset. We’d decided not to force variables into our models without solid evidence that they belonged, and I still think that was right. But we hadn’t gone looking for that evidence either.</p><p>For what we’d do differently, I said I’d add a readmission model built at discharge, when the length of stay and discharge medicines are known. I’d also have our 28-day model flag only the 20% of patients at highest risk, rather than 64% of them.</p><p>What I didn’t say, and wish I had, is why readmission was so hard to predict in the first place. Whether a patient comes back depends on care at home as much as care in hospital: support from family, getting to follow-up appointments, taking medicines. That is hard to record, and hard to rely on even when it is recorded.</p><p>Looking properly at the lab tests we left out is part of my Phase 2 work, and Part 3 will report what holds up.</p><p>The second mistake I only found afterwards, going back through our cleaning notebook: a check we’d written in only one direction.</p><p>We had looked for patients flagged as “not readmitted within six months” whose readmission date fell within 180 days. There were 5. We never looked the other way: 75 patients were flagged as readmitted within six months, but their recorded readmission came after 180 days.</p><p>If we go by the dates instead of the flag, six-month readmission drops from 38.5% to 35.0%. I reran the kidney comparison on the same 1,945 patients with the corrected outcome, and the gap held, widening slightly to 42.3% versus 29.3%. The other analyses that use this outcome still need rerunning, which is part of Phase 2. But checking each column on its own wasn’t enough. A yes/no flag needs to be checked against its date, in both directions.</p><h4>How I used AI:</h4><p>AI tools were allowed in the hackathon, and I used them to draft code, to question our questions and to explain statistics I hadn’t used before. I treated every answer like untested code: if a number couldn’t be traced back to our notebooks or the raw files, it didn’t go in.</p><p>That habit was still useful while writing this post. An AI tool told me one of our flag columns was missing from the master table. Checking the file showed it was there; the tool had searched for it under the wrong name.</p><h4>What’s next:</h4><p>I’m now rebuilding our cleaning as a tested ETL pipeline in my own repository, fixing the readmission definition and rerunning the analyses it affects. Part 2 walks through that pipeline, with code.</p><p><em>Thank you to my teammates for their support and encouragement throughout the week.</em></p><p><em>Data: Zhang, Z., Cao, L., Zhao, Y., Xu, Z., Chen, R., Lv, L., &amp; Xu, P. (2022). Hospitalized patients with heart failure: integrating electronic healthcare records and external outcome data (version 1.3). PhysioNet. </em><a href="https://physionet.org/content/heart-failure-zigong/1.3/"><em>https://doi.org/10.13026/5m60-vs44</em></a><em>. Original publication: Zhang, Z. et al. (2021). Electronic healthcare records and external outcome data for hospitalized patients with heart failure. Scientific Data, 8, 46. </em><a href="https://www.nature.com/articles/s41597-021-00835-9"><em>https://doi.org/10.1038/s41597-021-00835-9</em></a><em>. PhysioNet: Pollard, T. et al. (2026). PhysioNet as a global platform for biomedical research. Nature Health. </em><a href="https://www.nature.com/articles/s44360-026-00096-z"><em>https://doi.org/10.1038/s44360-026-00096-z</em></a><em>.</em></p><p><em>The dataset is under a restricted-access licence, and no patient-level data is shared in this post. Tools: Python, pandas, scikit-learn, statsmodels, Streamlit, Git.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe45ca78d97e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond SELECT *: 5 Essential SQL Patterns for Data Analysis]]></title>
            <link>https://medium.com/@shraddhasunilparakh/beyond-select-5-essential-sql-patterns-for-data-analysis-d90da1e1c7a7?source=rss-bd3550ff0b72------2</link>
            <guid isPermaLink="false">https://medium.com/p/d90da1e1c7a7</guid>
            <category><![CDATA[basic-sql]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[query-optimization]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Shraddha Sunil Parakh]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 14:24:52 GMT</pubDate>
            <atom:updated>2026-07-16T14:24:52.425Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LUMODBZQQBpklBWvng3srQ.png" /></figure><p><strong>What is Data Analytics (And Why SQL Matters)?</strong></p><p>At its core, <strong>Data Analytics</strong> is the art of exploring raw data to discover hidden patterns, answer business questions, and predict future trends. Think of a Data Analyst as a detective. Companies collect millions of clues every day — like what products people buy, when they log into an app, or why they abandon a shopping cart. The analyst’s job is to put these clues together to solve puzzles, such as <em>“How can we increase sales next month?”</em></p><p>To solve these puzzles, you need a way to talk to databases. That’s where <strong>SQL</strong> (Structured Query Language) comes in.</p><p>Here’s the thing nobody tells you when you’re starting out: knowing SELECT * FROM table doesn’t make you a data analyst. It just means you can <em>look</em> at data. The actual skill — the thing that separates “I can query a database” from “I can answer business questions” — is a small set of patterns that let you clean, group, label, and summarize data so it actually says something.</p><p>I want to walk through the five patterns I wish someone had slowed down and explained to me properly, instead of just throwing syntax at me. We’ll use three tables to practice with: sales, customers_dashboard, and user_profiles.</p><ol><li><strong>The Aggregator: </strong>GROUP BY + HAVING (<strong>Grouping things into piles)</strong></li></ol><p>Imagine you have a giant box of mixed colored beads (your raw data). If you want to know how many beads you have in total, you use an aggregate function like COUNT. But what if you want to know how many beads you have <strong>of each color</strong>?</p><p>You would first separate the beads into piles by color (GROUP BY), and then count each pile.</p><p><strong>Where people get tripped up: WHERE vs. HAVING</strong></p><ul><li><strong>WHERE</strong> happens <em>before</em> the sorting. It looks at individual beads one at a time and says “nope, this one’s broken, toss it” — before they ever get grouped into piles.</li><li><strong>HAVING</strong> happens <em>after</em> the sorting. It looks at entire piles and says “this pile only has 3 beads in it, that’s not enough to care about, get rid of the whole pile.”</li></ul><p>You genuinely cannot swap these two. If you try to filter on a <em>pile-level</em> total (like a SUM or COUNT) using WHERE, your query will just error out — because at the point WHERE runs, the piles don’t exist yet.</p><p>You genuinely cannot swap these two. If you try to filter on a <em>pile-level</em> total (like a SUM or COUNT) using WHERE, your query will just error out — because at the point WHERE runs, the piles don&#39;t exist yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*_lXmymAsaea6SUx36KStGQ.png" /><figcaption><strong>Practice table: sales</strong></figcaption></figure><p><strong>The goal : </strong>We want to find which product categories brought in more than <strong>$10,000</strong> total — but we don’t want a single $3 impulse buy to sneak in and mess with our numbers, so we ignore anything under $10 first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RhAAeg0AH20pfPECch6-Xg.png" /><figcaption>[Image Placeholder: A visual diagram showing raw data filtering through a WHERE clause, splitting into GROUP BY buckets, and finally filtering the buckets using HAVING.]</figcaption></figure><h4>2. The Data Classifier: CASE WHEN</h4><p>In an ideal world, data is perfectly labeled. In the real world, it’s chaotic. You might have a column of numbers (like customer spending) but your boss wants to see categories like “High Spender” or “Low Spender.”</p><p>CASE WHEN is essentially an <strong>IF-THEN</strong> statement directly inside your SQL query. It looks at your data row by row, checks if a rule is true, and gives it a custom label based on your decision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*zGOfGUXLnVXeMHTrcr_9rw.png" /><figcaption><strong>Sample Table: customers_dashboard</strong></figcaption></figure><p><strong>The goal: </strong>Marketing wants three customer tiers so they can send different discount emails to each group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*w49uLWFeop7Xx8kcCwGyMw.png" /></figure><p>One small habit worth building early: CASE WHEN checks conditions <strong>top to bottom</strong> and stops at the first one that&#39;s true. So always put your most specific or highest-priority condition first. If you&#39;d accidentally written the &quot;10-19&quot; check before the &quot;20+&quot; check, someone with 22 orders would never even get evaluated against it wrong — but in trickier cases, ordering absolutely can bite you.</p><h4>3. The Trend Tracker: Date Functions &amp; EXTRACT</h4><p>Dates and times are tricky in databases. A database might store a transaction time exactly like this: 2026-07-07 19:03:50.</p><p>As an analyst, you don’t care about the exact second someone bought a sandwich; you care about the <em>month</em> or the <em>year</em> so you can see if the business is growing over time. Date functions like EXTRACT allow you to reach into a messy timestamp and pluck out just the part you need (like the year, month, or day of the week).</p><h4>Practice table</h4><p>We’re reusing the sales table from earlier, just paying attention to the signup_timestamp column this time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*oNnVPMBsR0ib9nCamgzE4A.png" /></figure><p><strong>The goal : </strong>The product team wants to see new signups broken down by month, to check whether a summer campaign actually worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*056WBXESESvPcgSunNVvPA.png" /><figcaption>[Image Placeholder: A line graph showing user growth spiking month-over-month to visualize time-series data.]</figcaption></figure><p>Quick note on that GROUP BY 1, 2 line: instead of retyping the full column names, you can just reference them by their position in the SELECT list. It saves typing, but if you ever reorder your SELECT columns later, this will quietly break — so use it carefully, and if the query is going to be read by other people, spelling out the column names is usually the kinder choice.</p><h4>4. The Deduplicator: ROW_NUMBER() Window Function</h4><p>Duplicate data can completely ruin a data analyst’s report. If a user clicks a button three times, or updates their profile biography three times, you might have three rows for one person.</p><p>You might reach for DISTINCT — but DISTINCT only removes rows that are completely identical. Since each of those three bio updates has a different timestamp, DISTINCT won&#39;t touch any of them. They&#39;re all &quot;unique&quot; as far as it&#39;s concerned.</p><p>What you actually need is to look at <em>one user’s rows at a time</em>, rank them from newest to oldest, and grab whichever one is ranked #1. That’s exactly what ROW_NUMBER() does — it&#39;s a &quot;window function,&quot; which is a fancier way of saying &quot;it can see a whole group of related rows at once, instead of judging each row in total isolation.&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*qhmZXYRCTQgaerKT4ahhbw.png" /><figcaption>Notice user 101 shows up twice — same person, two different bios over time.</figcaption></figure><h4>The goal:</h4><p>Users can change their profile bios whenever they want. You want to pull a clean list showing <em>only</em> their most recent update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lte3VjvTrDcD-y6ROxLrkQ.png" /></figure><p>Break that OVER() clause down in plain English:</p><ul><li>PARTITION BY user_id → “restart the numbering every time you hit a new user” (so user 101’s numbering doesn’t bleed into user 102&#39;s)</li><li>ORDER BY updated_at DESC → “within each user’s rows, put the newest one first”</li><li>The result is that row number 1, for every user, is always their latest update.</li></ul><h3>5. The Organizer: Common Table Expressions (CTEs)</h3><p>When math problems get too big, you write down your intermediate steps on a piece of scratch paper so you don’t lose track. In SQL, a <strong>Common Table Expression (CTE)</strong> is your scratch paper.</p><p>Instead of writing a massive, terrifying query with subqueries stuffed inside other subqueries, a CTE lets you write a smaller query, name it like a temporary table using the WITH keyword, and then write a brand new query using that temporary data. It makes your code beautiful and easy for other analysts to read.</p><h4>The goal:</h4><p>You need to solve a two-step puzzle: first, find each individual customer’s <em>average</em> order value. Then, find the <em>overall average</em> of all those individual averages (sometimes called a “macro average,” and it’s genuinely different from just averaging every order directly — it gives every customer equal weight, instead of letting your most frequent shoppers dominate the number).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*IGntTlXR1T-e6deCgefGJA.png" /></figure><p>Once you get comfortable with one CTE, you’ll find you can chain several together (WITH first_step AS (...), second_step AS (...)), each one building on the last. It reads almost like a recipe: do this, then do this, then do this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*_NeSA8AB0Si-JCIurqKoNw.png" /></figure><h4><strong>The honest takeaway :</strong></h4><p>None of these five patterns are hard once you’ve written them a few times. The hard part is knowing <em>which one to reach for</em> when you’re staring at a messy table and a vague business question. My advice: the next time you’re tempted to write a giant, tangled query, stop and ask yourself which of these five shapes the problem actually fits. Most real-world analytics questions are just some combination of these five ideas stacked together — grouping, labeling, dating, ranking, and staging.</p><p>Once that clicks, SELECT * starts to feel like the very first step of a much longer, much more interesting conversation with your data.</p><ul><li>The result is that row number 1, for every user, is always their latest update.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d90da1e1c7a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scoring the Un-scoreable: How We Built a Multi-Organ Dysfunction Score for Sepsis Patients in…]]></title>
            <link>https://medium.com/@shraddhasunilparakh/scoring-the-un-scoreable-how-we-built-a-multi-organ-dysfunction-score-for-sepsis-patients-in-276cf810434d?source=rss-bd3550ff0b72------2</link>
            <guid isPermaLink="false">https://medium.com/p/276cf810434d</guid>
            <category><![CDATA[tableau-table]]></category>
            <category><![CDATA[sepsis]]></category>
            <category><![CDATA[mod-score]]></category>
            <dc:creator><![CDATA[Shraddha Sunil Parakh]]></dc:creator>
            <pubDate>Tue, 07 Jul 2026 21:26:41 GMT</pubDate>
            <atom:updated>2026-07-07T21:26:41.737Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scoring the Un-scoreable: How We Built a Multi-Organ Dysfunction Score for Sepsis Patients in Tableau</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*frpHo7mm4tb0pHuar_4Fkw.jpeg" /></figure><p><strong>Sepsis doesn’t fail one organ at a time : </strong>Sepsis is the body’s own immune response spiraling out of control in reaction to infection — and its danger isn’t really about any single organ. It’s about <em>how many</em> systems start failing at once, and how fast. A patient can look stable on any one vital sign while quietly deteriorating across four others. That’s the clinical reality our team set out to capture: <strong>can we turn a scattered set of hourly lab values into one number that tells you how sick a patient really is?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVtJad9b4Rjpgu85ryYEEw.png" /><figcaption>Raw SEPSIS Dataset from Kaggle</figcaption></figure><h3>The dataset: big, messy, and missing the one thing we wanted most</h3><p>Our dataset came from Kaggle’s sepsis ICU collection: <strong>1.5 million hourly records across 40,336 unique patients</strong>, spanning 43 features across demographics, vital signs, and lab values. Every patient falls into one of three groups based on their <em>Sepsis Label</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*oqPRCg9NSZcSCNp2IL-pjg.png" /></figure><p>Here’s the catch that shaped everything downstream: <strong>the dataset has no mortality column.</strong> There’s no ground truth for “did this patient survive.” So instead of asking “can we predict death,” our real question became: <strong>can we build a defensible proxy for severity using only what the data gives us</strong> — and can we validate that proxy makes clinical sense?</p><p>That’s what sent us toward Multi-Organ Dysfunction (MOD) scoring.</p><h4><strong>Why MOD scoring, specifically:</strong></h4><p>Established clinical severity frameworks (like SOFA and MODS in the medical literature) don’t just average a patient’s labs together — they score each organ system independently on a 0–4 scale, then sum the organ scores into a total. The reason this matters more than a single combined average: <strong>a patient with three organs in moderate dysfunction is a very different risk profile than a patient with one organ in severe dysfunction, even if their raw numbers look similar.</strong> Organ <em>count</em> carries real information that a single averaged score throws away.</p><p>Individual biomarkers, on their own, can’t easily answer the one question that actually matters: <strong><em>how sick is this patient, overall?</em></strong> A single elevated Lactate or a single abnormal Creatinine tells you one system is under stress — it doesn’t tell you whether that patient is mildly unwell or actively crashing across multiple systems at once. That gap is why we designed a composite MOD score: one metric that combines organ-specific dysfunction into a single, clinically meaningful severity signal.</p><h4>Clinical design philosophy</h4><p>This is where the project stopped being a formula exercise and became a design exercise. Before writing a single calculated field, we agreed on five guiding principles — and every technical decision downstream traces back to one of these:</p><ol><li><strong>Every organ should be scored independently.</strong> No organ’s dysfunction should be diluted by averaging it against a healthy one.</li><li><strong>Multiple biomarkers should be evaluated together</strong>, because one lab value rarely reflects complete organ function on its own.</li><li><strong>The worst abnormality determines that organ’s score.</strong> A single critical reading should be enough to flag the organ as critical — dysfunction doesn’t average itself away.</li><li><strong>Missing values should never falsely increase severity.</strong> A lab that wasn’t drawn is not the same as a lab that came back abnormal.</li><li><strong>Patient severity should reflect the highest dysfunction experienced during the ICU stay</strong>, not just the most recent reading.</li></ol><p>Keep these five in mind as you read the build below — you’ll see each one show up directly in a formula, not just in prose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*KjYtb6K5jb-VlMG_5TKxVw.jpeg" /></figure><p>We scored five systems: <strong>Respiratory, Cardiovascular, Renal, Hepatic, and Hematologic</strong> — each landing on a Total MOD Score, a Severity label, and a Mortality Rate proxy.</p><p><strong>Step 1: Matching biomarkers to organs (the part that took several passes)</strong></p><p>This is where the real analytical work happened — and where our first draft was actually wrong. Our earliest version of the Cardiovascular score included Creatinine, which got caught in review: Creatinine is a <em>kidney</em> clearance marker, not a cardiac one. Here’s the biomarker map we landed on:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*QAIA-ewnPcD5t8JMly2OBw.png" /></figure><p>A few judgment calls worth explaining, since they’re the kind of decisions that separate a real analysis from a plug-and-chug score:</p><p><strong>We estimated PaO₂ instead of leaving Respiratory incomplete.</strong> True PaO₂ requires an arterial blood gas draw, which isn’t available every hour in this dataset. Rather than drop the Respiratory score’s most important input, we derived it:</p><p>Estimated_PaO2<br>150 — ([PaCO2] / 0.8)</p><p>PF_Ratio<br>[Estimated_PaO2] / [FiO2]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*OcUNnpzt2rSTxLetZX3RLg.png" /><figcaption>Calculating PF Ratio</figcaption></figure><p>This is the standard alveolar gas equation simplification used when a direct PaO₂ reading isn’t available — it lets the Respiratory score function continuously across the whole dataset instead of going null every time an ABG wasn’t drawn.</p><p><strong>We kept the Renal score lean on purpose.</strong> An earlier draft folded in Chloride, Calcium, and Glucose as general “metabolic” markers — but that diluted the score’s specificity. A kidney score should move because of kidney dysfunction, not because a patient’s blood sugar spiked from stress hyperglycemia. We pruned it back to Creatinine, BUN, and Potassium — the three with the most direct causal link to renal failure.</p><p><strong>We didn’t force AKI staging into this version.</strong> True Acute Kidney Injury staging is defined by the <em>change</em> in Creatinine from a patient’s baseline, not a fixed threshold — which needs time-series delta logic, not a simple IF/THEN. We flagged this as a known limitation rather than fake an answer.</p><p><strong>Unit conversion mattered more than expected.</strong> Our Creatinine values are in mg/dL, but standard MOD/SOFA threshold tables use µmol/L — a small ×88.4 conversion that could have silently invalidated every renal threshold if missed.</p><p><strong>Step 2: Setting the thresholds</strong></p><p>For each organ, we built a 4-tier IF/ELSEIF cascade — Critical (4) down to Normal (0) — using <strong>OR logic across every biomarker in that organ.</strong> That detail matters clinically: any single biomarker crossing a critical threshold assigns the critical score for the whole organ, even if the others look fine. That mirrors real triage — you don’t average away a dangerously low MAP just because Lactate looks okay.</p><p>Here’s the Cardiovascular logic as the representative example (the same OR-cascade pattern repeats for all five organs, each with its own clinically sourced cutoffs):</p><p><strong>Cardiovascular</strong><br>IF ISNULL([MAP]) AND ISNULL([Lactate]) AND ISNULL([Troponin I]) THEN NULL<br>ELSEIF [MAP] &lt; 50 OR [Lactate] &gt;= 6 OR [Troponin I] &gt;= 5 THEN 4 // Critical<br>ELSEIF [MAP] &lt; 60 OR [Lactate] &gt;= 4 OR [Troponin I] &gt;= 2 THEN 3 // Severe<br>ELSEIF [MAP] &lt; 65 OR [Lactate] &gt;= 3 OR [Troponin I] &gt;= 0.5 THEN 2 // Moderate<br>ELSEIF [MAP] &lt; 70 OR [Lactate] &gt;= 2 OR [Troponin I] &gt;= 0.1 THEN 1 // Mild<br>ELSE 0 // Normal<br>END</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*df1W9ozcMY6-LKrA6rbm0A.png" /><figcaption>Lungs / Respiratory</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*cu3MT5_HDTCnT0aiPfffRg.png" /><figcaption>Kidney / Renal</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*uqNZetrqL_pWU7OAlZ2YPQ.png" /><figcaption>Liver / Hepatic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*LHFdtwaQfefb0hox_aEMww.png" /><figcaption>Blood / Hematology</figcaption></figure><p><strong>Step 3: Collapsing hourly noise into one score per patient</strong></p><p>With hourly data, a single patient can have 100+ rows — scoring at the row level would just be noise. Instead, each organ score rolls up to the <strong>worst value observed for that patient</strong>, using a FIXED Level of Detail expression:</p><p>PL_MOD_Cardiovascular<br>ROUND({ FIXED [Patient ID] : MAX([Score_Cardiovascular_nw]) }, 0)</p><p>This says: <em>for this patient, across every hour we have data, what’s the single worst state any organ reached?</em> — the right question for a severity score, since peak derangement (not average derangement) is what actually drives risk in sepsis.</p><p><strong>Step 4: Assembling the Total Score, Mortality Rate, and Severity label</strong></p><p>Total MOD Score<br>ZN([PL_MOD_Cardiovascular]) + ZN([PL_MOD_Hepatic]) + ZN([PL_MOD_Renal]) + ZN([PL_MOD_Respiratory]) + ZN([PL_MOD_Hematologic])</p><p>ZN() does real work here — without it, one missing organ score would null out the entire sum instead of just treating that organ as “no data available.”</p><p>Mortality Rate<br>([Total MOD Score] / 20) * 100</p><p>With 5 organs capped at 4 each, 20 is the max possible score — this simply rescales Total MOD Score to a 0–100% severity proxy. Worth stating plainly in the blog: <strong>this is a relative risk indicator, not a validated mortality prediction</strong>, since we have no real outcomes column to calibrate against.</p><p>Severity<br>IF [Organ Failure Count] &lt;= 1 AND [Total MOD Score] &lt; 6 THEN “Mild”<br>ELSEIF [Organ Failure Count] = 2 OR [Total MOD Score] &lt; 9 THEN “Moderate”<br>ELSEIF [Organ Failure Count] = 3 OR [Total MOD Score] &lt; 12 THEN “Severe”<br>ELSE “Critical”<br>END</p><p>This is the field that makes the score clinically meaningful rather than pure arithmetic — Severity is driven by <em>both</em> total score <em>and</em> organ count, because multi-organ involvement is the more dangerous pattern even at an equivalent total.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LahBIRdcS2xEFmuXMBgDkw.png" /></figure><p>What makes this table work as a storytelling tool rather than a data dump:</p><ul><li><strong>Color intensity per organ column</strong> — lets a reader scan for “which organ is driving this patient’s severity” at a glance, without reading every number</li><li><strong>Severity as a category, not just a number</strong> — “Critical” communicates urgency in a way “17” doesn’t</li></ul><h4>Conclusion</h4><p>Sepsis rarely announces itself through one bad number. It shows up as a quiet decline across several systems at once — which is exactly what a single vital sign or lab value can’t capture on its own. That’s the gap our MOD score was built to close: not a mortality prediction, but a disciplined, principle-driven way to turn 43 scattered biomarkers into one number that actually reflects how sick a patient is.</p><p>What made this more than a formula exercise was holding ourselves to the five principles before writing a single line of calculated-field syntax — and then checking, at every step, that the code actually did what the principle demanded. When our first draft misassigned Creatinine to the Cardiovascular score, that wasn’t a coding bug, it was a principle violation, and catching it that way is what made the rebuild worth doing.</p><p>The score isn’t finished — AKI staging, mortality validation, and a few of the ideas above are still open. But that’s the honest state of a real analytics project: a defensible framework, built transparently, with its limits stated plainly rather than hidden. That’s what we’re handing off in this dashboard, and it’s what we’d want anyone extending this work to start from.</p><p><em>This piece accompanies the MOD Score dashboard from our sepsis ICU analytics project, built in Tableau Public on a 1.5M-row, 40,336-patient dataset sourced from Kaggle.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=276cf810434d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>