<?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 Jillysyuki on Medium]]></title>
        <description><![CDATA[Stories by Jillysyuki on Medium]]></description>
        <link>https://medium.com/@jillysyuki?source=rss-fe0dc4144372------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zmJXkqP7FhefX-kt</url>
            <title>Stories by Jillysyuki on Medium</title>
            <link>https://medium.com/@jillysyuki?source=rss-fe0dc4144372------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:51:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jillysyuki/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[Combine, Then Compare: A Beginner’s Path Through Joins and Window Functions]]></title>
            <link>https://medium.com/@jillysyuki/combine-then-compare-a-beginners-path-through-joins-and-window-functions-3dbfe7f1d50f?source=rss-fe0dc4144372------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dbfe7f1d50f</guid>
            <category><![CDATA[sql-window-functions]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-beginner]]></category>
            <category><![CDATA[sql-joins]]></category>
            <dc:creator><![CDATA[Jillysyuki]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 05:04:33 GMT</pubDate>
            <atom:updated>2026-09-15T05:04:33.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UCrs5oPiUm3rkwdzI4ZncA.png" /></figure><p>If you’ve worked with SQL for even a short time, you’ve probably used JOIN to pull data from two tables together. But what happens when you need to compare rows within the same table — like finding the top purchase per customer, or a running total by month? That’s where window functions come in. This article walks through both: how joins combine data, and how window functions let you analyze it without losing any rows.</p><h3>Part 1:Joins — Combining data From Different Tables.</h3><p>In most real projects, the data you need may not be sitting in one table. You might have a customers table with names and location and a separate one with order table with purchase amounts and dates.</p><p>To answer almost any question, you need to bring the tables together, and that&#39;s exactly what joins do.</p><p>SQL Joins used to combine rows from two or more tables based on columns that they share, usually an ID column.</p><h4>Types of joins</h4><ul><li>Inner join</li><li>left join</li><li>right join</li><li>Full outer join</li><li>self join</li></ul><h4>1) Inner join</h4><p>An inner join only keeps rows that match in both tables.</p><h4>2) Left join</h4><p>left join keeps everything from the first(left) table no matter what and fills in blanks(NULLs) where there is no match in the second table.</p><p>Useful when you don’t want to lose rows just because there is no matching data yet .</p><h4>3)Right join</h4><p>Right join returns all rows from the right table and matches from the left.</p><p>Null if no matches, and the order of the tables matters.</p><h4>4)Full outer join</h4><p>Full outer join returns all rows from both tables.</p><p>It&#39;s a combination of left join and right join and gives NULL where there is no match.</p><h4>5) Self join</h4><p>self join is a table joined to itself.</p><p>It is when rows in a table reference other rows in the same table.</p><h3>Part 2: Window function</h3><p>Joins bring data together. But once your data is combined, you’ll often run into a different kind of question: <em>“how does this row compare to others in its group?”</em> — like finding each customer’s top purchase, or a running total by month.</p><p>Your first instinct might be GROUP BY. The problem is that GROUP BY collapses your rows into one summary row per group — you lose the individual detail underneath. If you had ten orders and wanted to see each one alongside the customer&#39;s total spend, GROUP BY won&#39;t get you there. This is exactly the problem window functions solve.</p><p>A window function calculates something across a group of related rows — a “window” — while keeping every individual row in the output.</p><p>Every window function follows the same basic shape:</p><pre>FUNCTION_NAME(column) OVER (<br>  PARTITION BY grouping_column<br>  ORDER BY sorting_column<br>)</pre><ul><li>PARTITION BY — defines the group (the &quot;window&quot;) the calculation applies to</li><li>ORDER BY — defines the order rows are processed in (needed for ranking, running totals, and row-to-row comparisons)</li></ul><p>Now let’s go through the functions themselves.</p><h4>1. Ranking Functions — putting rows in order</h4><p><strong>ROW_NUMBER()</strong> — gives every row a unique, sequential number within its partition; no ties allowed.</p><pre>SELECT<br>  customer_id,<br>  order_id,<br>  amount,<br>  ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY amount DESC) AS row_num<br>FROM orders;</pre><p>Even if two orders have the same amount, they’ll get different numbers (1, 2, 3…).</p><p><strong>RANK()</strong> — same idea, but ties share a rank, and the next rank skips accordingly.</p><pre>RANK() OVER (PARTITION BY customer_id ORDER BY amount DESC) AS order_rank</pre><p>If two orders tie for 1st, the next one jumps to 3rd (1, 1, 3, 4…).</p><p><strong>DENSE_RANK()</strong> — like RANK(), but no gaps after ties.</p><pre>DENSE_RANK() OVER (PARTITION BY customer_id ORDER BY amount DESC) AS dense_order_rank</pre><p>Ties still share a rank, but the next row continues immediately after (1, 1, 2, 3…).</p><p><strong>When to use which:</strong> ROW_NUMBER when you need a strict unique order (e.g., “give me only the top 1 order per customer”). RANK or DENSE_RANK when ties genuinely matter, and you want that reflected in the output.</p><h4>2. Aggregate Window Functions — totals, averages, and counts without collapsing rows</h4><p>Any aggregate function you already know — SUM, AVG, COUNT, MIN, MAX — becomes a window function the moment you add OVER (...).</p><pre>SELECT<br>  customer_id,<br>  order_id,<br>  amount,<br>  SUM(amount) OVER (PARTITION BY customer_id) AS customer_total,<br>  AVG(amount) OVER (PARTITION BY customer_id) AS customer_avg,<br>  COUNT(order_id) OVER (PARTITION BY customer_id) AS customer_order_count<br>FROM orders;</pre><p>Every row keeps its own amount, but now also shows the customer&#39;s total, average, and order count — all attached without needing a separate query or a self-join.</p><p>This is also how you build a <strong>running total</strong> — just add ORDER BY:</p><pre>SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_id) AS running_total<br></pre><p>Without ORDER BYthe sum is calculated across the whole partition at once. WithORDER BY, it accumulates row by row — that&#39;s the difference that trips people up the first time.</p><h4>3. LEAD() and LAG() — looking at neighboring rows</h4><p><strong>LEAD()</strong> pulls a value from the <em>next</em> row in the partition.</p><pre>LEAD(amount) OVER (PARTITION BY customer_id ORDER BY order_id) AS next_order_amount</pre><p><strong>LAG()</strong> pulls a value from the <em>previous</em> row.</p><pre>LAG(amount) OVER (PARTITION BY customer_id ORDER BY order_id) AS previous_order_amount</pre><p>Both return NULL when there&#39;s no next/previous row (e.g., the first or last order for that customer). These are the functions you reach for when comparing a row to what came right before or after it — like measuring the change between two consecutive purchases, without a manual self-join.</p><p>4. NTILE() — splitting rows into equal buckets</p><pre>NTILE(4) OVER (ORDER BY amount DESC) AS spending_quartile</pre><p>This divides rows into a specified number of roughly equal groups — quartiles, deciles, whatever number you pass in. Useful for segmenting customers by spending tier or students by score band, without manually setting cutoff values.</p><p>Every window function you’ve just seen does the same underlying thing: it looks at a defined group of rows (the “window”), performs a calculation, and returns that result alongside every row — never collapsing your data the way GROUP BY does. Once that clicks, the specific function you use (RANK, SUM, LEAD, NTILE, whatever) is just a matter of picking the right tool for the comparison you&#39;re trying to make.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dbfe7f1d50f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding unsupervised machine learning.]]></title>
            <link>https://medium.com/@jillysyuki/understanding-unsupervised-machine-learning-97b1ac0f3cb8?source=rss-fe0dc4144372------2</link>
            <guid isPermaLink="false">https://medium.com/p/97b1ac0f3cb8</guid>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <dc:creator><![CDATA[Jillysyuki]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 11:14:31 GMT</pubDate>
            <atom:updated>2026-09-07T11:14:31.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E2GXDaR404GuMvsDwZvPIA.png" /></figure><p>Imagine someone hands you a dataset containing 1000 rows of Netflix movies. No genre column. No “horror”, “thriller”, “romance” label anywhere.</p><p>Just numbers: runtime, release year, how violent it is, how much dialogue versus action, average watch time before people drop off.</p><p>Now imagine they say: “Group this dataset into categories that make sense”.</p><p>No one told you how many groups to make. No one told you what to call them. You just have raw numbers and a blank page.</p><p>This is exactly what unsupervised learning solves. You feed it numbers, and instead of you deciding the categories by hand, the algorithm looks at which movies behave similarly, have similar runtimes, similar pacing, and groups them on its own.</p><p><strong>What I just described is unsupervised learning</strong></p><p>Unsupervised learning is the branch of machine learning where the model is not given any labels/answers.</p><p>It tries to find patterns, structure, or relationships in the input data without any human supervision.</p><p>This is different from supervised learning, where you show a model thousands of examples with correct answers/labels, like this is a cat or this is a dog, and it learns the patterns. But with our Netflix dataset, there are no answer/labels. Just numbers and a question: What groups exist here?</p><h4>Types of unsupervised learning machines.</h4><ol><li><strong>Clustering.</strong></li><li><strong>Dimensionality reduction.</strong></li></ol><h4>1). Clustering.</h4><p>Clustering groups data points into clusters based on similarity.</p><p>Clustering figures it out on its own based on similarity in the dataset itself.</p><p><strong>Example: A supermarket looks at 5000 shoppers’ purchase histories with no labels — just what they bought and how often. Clustering might reveal groups like weekly bulk shoppers — categories nobody defined in advance just patterns that emerged from the numbers.</strong></p><h4>Common algorithms for clustering:</h4><ol><li>K-Means</li><li>Hierarchical Clustering</li><li>DBSCAN</li></ol><h4>1. K-Means clustering.</h4><p>K-Means groups unlabelled data into groups of K distinct clusters.it works iteratively by assigning data points to the nearest cluster center(centroid) and updating those centroids until positions stabilize.</p><p><strong>How it works:</strong></p><ol><li>Pick K and drop K random center points into your data.</li><li>Assign every point to its nearest center.</li><li>Move each center to the average position of the points now assigned to it.</li><li>Repeat steps 2–3 until nothing changes anymore.</li></ol><p><strong>Example (students):</strong> A university has data on 2,000 students — hours studied per week, attendance rate, and quiz scores. Running K-Means with K=3 might reveal:</p><ul><li>Cluster 1: high study hours, high attendance, high scores → “consistent achievers”.</li><li>Cluster 2: low study hours, sporadic attendance, mixed scores → “at risk”.</li><li>Cluster 3: low study hours but high scores → “naturally strong / crammers”.</li></ul><p>Nobody labeled any student this way beforehand — the groups emerged from the numbers.</p><h4>2. Hierarchical Clustering.</h4><p><strong>The idea:</strong> Instead of picking K upfront, you build a full tree showing how every point relates to every other point, from “completely separate” to “one giant group.” You decide afterward where to “cut” the tree to get your final groups.</p><p><strong>How it works (agglomerative/bottom-up):</strong></p><ol><li>Every point starts as its own cluster.</li><li>Merge the two closest clusters.</li><li>Repeat until everything has merged into one.</li></ol><p><strong>Example (movies):</strong> You’re clustering 500 Netflix movies by runtime and pacing. Individual fast-paced action movies merge together first, then merge with similarly-paced thrillers into a broader “high-energy” cluster. Meanwhile, slow character dramas merge with slow-burn mysteries into a “contemplative” cluster. Eventually, every cluster merges into one. You can then decide: do I want 3 broad categories, or 12 narrow ones? Same tree, you just pick where to slice it.</p><p><strong>Best for:</strong> Smaller datasets, when you want to see relationships at multiple levels of detail rather than one fixed number of groups.</p><h4>3. DBSCAN(Density-Based clustering)</h4><p><strong>The idea:</strong> A cluster is just a “crowded” area of similar points. If a point has enough neighbors nearby, it belongs to a cluster. If it’s sitting off on its own, it’s labeled as noise/an outlier — not forced into any group.</p><p><strong>How it works:</strong></p><ol><li>You set two rules: how close points need to be to count as neighbors, and how many neighbors count as “crowded”.</li><li>The algorithm expands outward from crowded areas, connecting nearby dense regions into clusters.</li><li>Anything left over that isn’t part of a dense region gets flagged as noise.</li></ol><p><strong>Example (customers):</strong> A bank analyzes 10,000 customers’ transaction patterns. Most customers naturally form dense clusters around typical behaviors — regular grocery spenders, bill-payers, savers. But one customer’s transaction pattern looks nothing like any of these groups — erratic amounts, unusual timing, no resemblance to any dense cluster. DBSCAN doesn’t force that customer into the nearest group; it flags them as an outlier, which is often exactly what you want when you’re hunting for fraud or unusual behavior.</p><p><strong>Best for:</strong> Irregularly shaped clusters and situations where outliers matter (fraud detection, anomaly spotting) rather than getting swallowed into the nearest group.</p><h3>2. Dimensionality reduction</h3><p>When your data has <em>too many columns</em>, dimensionality reduction squishes it down into fewer columns while keeping as much of the important information as possible.</p><p><strong>Analogy:</strong> Imagine trying to describe a movie using 200 different numbers — runtime, budget, number of explosions, dialogue density, color palette, camera cuts per minute, and 194 more. That’s way too much to look at, plot, or even reason about. But a lot of those numbers overlap or move together (movies with more explosions also tend to have less dialogue, faster cuts, and bigger budgets). Dimensionality reduction finds those overlapping patterns and compresses 200 columns down into maybe 2 or 3 that still capture most of the story — say, one score for “action-heavy vs. dialogue-heavy” and another for “big-budget spectacle vs. indie.”</p><p>You lose a little detail, but you gain something huge: you can actually see and work with the data.</p><h4>Main algorithms</h4><ol><li><strong>PCA(Principal component Analysis)</strong></li></ol><p><strong>What it does:</strong> Takes your many columns and squishes them into a few “combined” columns that still capture most of the important information.</p><p><strong>Simple way to think about it:</strong> If 10 of your columns are all secretly measuring almost the same thing, PCA merges them into 1–2 columns instead of keeping all 10.</p><p><strong>Example (students):</strong> Instead of 40 separate columns (attendance, quiz scores, homework, participation, sleep), PCA compresses it all into 2 columns — maybe “overall engagement” and “consistency.” Now you can actually plot every student on a simple chart.</p><p><strong>Use it for:</strong> A general first step to simplify data — often done before clustering.</p><h3>2. t-SNE</h3><p><strong>What it does:</strong> Built purely for making a picture. It squishes your data down to 2D and makes sure similar things stay close together on the chart.</p><p><strong>Simple way to think about it:</strong> It’s obsessed with keeping “who’s similar to whom” accurate, even if the overall picture gets a bit warped.</p><p><strong>Example (movies):</strong> Thousands of movies with hundreds of hidden features get squished to 2D, and you visually see clumps — a group of comedies sitting together, a group of dramas sitting together — without ever labeling genres yourself.</p><p><strong>Use it for:</strong> Visualizing whether your clusters actually look separated and make sense.</p><h3>3. UMAP</h3><p><strong>What it does:</strong> Basically the same job as t-SNE (making a 2D picture of your data), but faster, and does a slightly better job of keeping the “big picture” layout meaningful too.</p><p><strong>Simple way to think about it:</strong> t-SNE’s faster cousin.</p><p><strong>Example (customers):</strong> 60 columns of customer financial behavior get squished to 2D, and you see customer groups form — with risky customers landing visibly far from the “safe” groups.</p><p><strong>Use it for:</strong> Same as t-SNE, but preferred when you have a lot of data since it runs quicker.</p><h3>Where it’s used today.</h3><p><strong>1. Streaming platforms (your Netflix example, made real)</strong><br> Netflix, Spotify, and YouTube use clustering-like techniques to group users and content based on behaviour, not manual tags — leading to those oddly specific categories you get suggested, without a human labeling every title.</p><p><strong>2. Customer segmentation in marketing</strong><br> Companies take raw purchase/browsing data (no labels) and let clustering reveal natural customer groups — “bargain hunters,” “loyal repeat buyers,” “one-time impulse shoppers” — so marketing teams can target each group differently, without deciding those categories by hand in advance.</p><p><strong>3. Fraud and anomaly detection</strong><br> Banks and payment processors (Visa, PayPal, etc.) use anomaly detection to flag transactions that don’t resemble normal patterns — no one needs to have seen that exact type of fraud before; it just needs to look different from everything “normal.”</p><p><strong>4. Genomics and biology research</strong><br> Scientists cluster gene expression data to discover new subtypes of diseases (e.g., different subtypes of cancer that respond differently to treatment) — patterns that weren’t known or labeled beforehand, only discoverable by letting the algorithm find structure in the raw data.</p><p><strong>5. Image compression and organization</strong><br> Google Photos groups your pictures by similar faces or similar scenes without you manually tagging anyone — clustering pixel/feature patterns to group similar images together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97b1ac0f3cb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parametric vs Non-parametric.]]></title>
            <link>https://medium.com/@jillysyuki/parametric-vs-non-parametric-1e35b41328c8?source=rss-fe0dc4144372------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e35b41328c8</guid>
            <dc:creator><![CDATA[Jillysyuki]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 03:57:56 GMT</pubDate>
            <atom:updated>2026-07-30T03:57:56.314Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered why researchers/analysist choose different statistical tests to analyse similar datasets?</p><p>The answer often depends on one important question: <strong>Does the data satisfy certain assumptions?</strong> In hypothesis testing, statistical tests are broadly classified into <strong>parametric</strong> and <strong>non-parametric</strong> tests based on the assumptions they make about the underlying data. Understanding the difference between these two approaches is essential for selecting the appropriate test and drawing reliable conclusions from data.</p><blockquote><em>Before comparing these two approaches, it is important to understand what a </em><strong><em>parameter</em></strong><em> is, as the distinction between parametric and non-parametric tests is based on the assumptions made about population parameters.</em></blockquote><h4>Parametric test.</h4><p>A parameter is a numerical characteristic of a population such as population means, population variance, or population proportion.</p><p>Parametric tests are statistical hypothesis tests that make assumptions about the population from which the sample is drawn. These tests are called <em>parametric</em> because they rely on one or more <strong>population parameters</strong>, such as the population means and the population standard deviation, to make inferences about the data.</p><p>The primary objective of a parametric test is to determine whether the observed differences or relationships in a sample are statistically significant and can be generalised to the larger population. Because these tests rely on specific assumptions about the data, they are generally more powerful than non-parametric tests when those assumptions are satisfied. In statistics, a <strong>powerful</strong> test has a higher probability of detecting a true effect when it actually exists.</p><h3>Types of Parametric Tests.</h3><h4>Z-Test</h4><p>A z-test is used when the population standard deviation is known, and the sample size is generally 30 or more; the Z-Test is reliable for large datasets.</p><p>A Z-test is used to determine whether there is a significant difference between a sample mean and a population mean.</p><h4>When to use it</h4><p>1.) Comparing a sample mean with a population mean.</p><p>2.) Comparing two population means.</p><p>3.) Testing population proportions.</p><h4>Assumptions</h4><ol><li>) Data are normally distributed.</li><li>) Observations are independent.</li><li>)The data should be continuous</li><li>)The data should be randomly selected.</li><li>)Known population variance or standard deviation.</li></ol><h3>Example</h3><p>A manufacturer claims that the average weight of a packet of rice is <strong>5 kg</strong>. A quality inspector collects <strong>50 packets</strong> and wants to determine whether the true average weight differs from 5 kg. Since the sample is large and the population standard deviation is known, a <strong>Z-test</strong> is appropriate.</p><h4>2.T-TEST</h4><p>Types of T-Tests.</p><ol><li>One-sample t-test</li><li>Paired t-test</li><li>Independent t-test</li></ol><h4>2.1 One-sample t-test</h4><p>Compares a sample mean to a known population mean. Unlike a Z-test, it is used when the population standard deviation is unknown.</p><h4>When to use it</h4><ol><li>Comparing one sample mean against a known value.</li></ol><p><strong>Assumptions.</strong></p><ul><li>Data are approximately normally distributed.</li><li>Observations are independent.</li><li>Data are continuous.</li><li>Random sampling.</li></ul><h3>Example</h3><p>A university claims that students study an average of <strong>20 hours per week</strong>. A researcher collects data from 25 students to determine whether their average study time differs from 20 hours.</p><h3>2.2 Independent Samples t-Test</h3><p>The <strong>independent samples t-test</strong> compares the means of <strong>two unrelated groups</strong> to determine whether they differ significantly.</p><p>It answers questions such as:</p><p><em>“Do male and female students have different average examination scores?”</em></p><h3>When to use it</h3><ul><li>Comparing two independent groups.</li></ul><h3>Assumptions</h3><ul><li>The groups are independent.</li><li>Data are normally distributed.</li><li>Equal variances between groups.</li><li>Continuous dependent variable.</li><li>Random sampling</li></ul><h3>Example</h3><p>A researcher compares the average blood pressure of patients receiving <strong>Drug A</strong> with those receiving <strong>Drug B</strong>.</p><h3>2.3 Paired Samples t-Test</h3><p>The <strong>paired samples t-test</strong> compares the means of <strong>the same individuals measured twice</strong> or matched pairs.</p><p>Instead of comparing different groups, it measures whether an intervention or treatment causes a significant change.</p><h3>When to use it</h3><p>1.Before-and-after studies.</p><p>2. Repeated measurements.</p><p>3. Matched participants.</p><h3>Assumptions</h3><ol><li>Paired observations.</li></ol><p>2. Differences between pairs are normally distributed.</p><p>3. Continuous data.</p><h3>Example</h3><p>A fitness instructor measures participants’ body weight <strong>before and after</strong> a 12-week exercise programme to determine whether the programme led to significant weight loss.</p><h3>3. Analysis of Variance (ANOVA)</h3><p>ANOVA is used when comparing the means of <strong>three or more groups</strong>.</p><p>Instead of performing several t-tests — which increases the chance of making a Type I error — ANOVA tests all groups simultaneously.</p><h3>Types of ANOVA</h3><h3>One-Way ANOVA</h3><p>Compares one independent variable with three or more groups.</p><p>Example:</p><p>Comparing exam scores among students taught using:</p><ol><li>Traditional learning</li></ol><p>2. Online learning</p><p>3. Hybrid learning</p><h3>Two-Way ANOVA</h3><p>Examines the effects of <strong>two independent variables</strong> simultaneously.</p><p>Example:</p><p>A researcher investigates whether exam scores depend on:</p><ul><li>Teaching method</li><li>Gender</li></ul><p>It also determines whether the two variables interact.</p><h3>Assumptions</h3><ul><li>Normal distribution.</li><li>Equal variances.</li><li>Independent observations.</li><li>Continuous dependent variable.</li></ul><h3>Non-Parametric Tests</h3><p>A <strong>non-parametric test</strong> is a statistical hypothesis test that makes <strong>few or no assumptions about the underlying population distribution</strong>. Unlike parametric tests, which assume that the data follow a specific distribution (typically the normal distribution) and rely on population parameters such as the mean and standard deviation, non-parametric tests analyse data without requiring these assumptions.</p><h3>Non-parametric tests are particularly useful when:</h3><ul><li>The data are <strong>not normally distributed</strong>.</li><li>The sample size is <strong>small</strong>.</li><li>The data are <strong>ordinal</strong> (ranked) or <strong>nominal</strong> (categorical).</li><li>The data contain <strong>outliers</strong> that could affect parametric tests.</li><li>The assumptions required for parametric tests have been violated.</li></ul><h3>1. Chi-Square Test</h3><p>The <strong>Chi-Square test</strong> is used to determine whether there is a significant relationship between categorical variables or whether observed frequencies differ from expected frequencies. It analyses <strong>frequency counts</strong> rather than numerical measurements.</p><h3>Types</h3><h3>a) Chi-Square Test of Independence</h3><p>Determines whether two categorical variables are associated.</p><p><strong>Example</strong></p><p>Is there an association between <strong>gender</strong> and <strong>preferred programming language</strong>?</p><h3>b) Chi-Square Goodness-of-Fit Test</h3><p>Determines whether observed frequencies match an expected distribution.</p><p><strong>Example</strong></p><p>A company expects equal demand for four smartphone colours. The Chi-Square Goodness-of-Fit Test determines whether the observed sales differ significantly from the expected distribution.</p><h3>When to use</h3><ul><li>Categorical data</li><li>Frequency counts</li><li>Independent observations</li></ul><h3>2. Mann–Whitney U Test</h3><p>The <strong>Mann–Whitney U test</strong> is the non-parametric alternative to the <strong>independent samples t-test</strong>. It compares <strong>two independent groups</strong> by ranking observations instead of comparing their means.</p><p>Instead of asking whether two groups have different means, it asks whether one group tends to have higher or lower values than the other.</p><h3>Example</h3><p>A researcher wants to compare customer satisfaction ratings between two restaurants. Since the ratings are on a Likert scale (1–5), the Mann–Whitney U test is more appropriate than the independent t-test.</p><h3>When to use</h3><ul><li>Two independent groups</li><li>Ordinal data</li><li>Non-normal continuous data</li></ul><h3>3. Wilcoxon Signed-Rank Test</h3><p>The <strong>Wilcoxon Signed-Rank Test</strong> is the <strong>nonparametric alternative to the paired-samples t-test</strong>. It compares two related samples by analysing the ranks of the differences between paired observations.</p><h3>Example</h3><p>A hospital measures patients’ pain levels before and after treatment to determine whether the treatment reduced pain.</p><h3>When to use</h3><ul><li>Before-and-after studies</li><li>Matched participants</li><li>Ordinal or non-normal continuous data</li></ul><h3>4. Kruskal–Wallis Test</h3><p>The <strong>Kruskal–Wallis Test</strong> is the non-parametric equivalent of the <strong>one-way ANOVA</strong>. It compares <strong>three or more independent groups</strong>.</p><p>Instead of comparing group means, it compares the average ranks of the observations.</p><h3>Example</h3><p>A researcher compares customer satisfaction ratings among three supermarkets.</p><h3>When to use</h3><ul><li>Three or more independent groups</li><li>Ordinal data</li><li>Non-normal continuous data</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e35b41328c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Hypothesis Testing Is the Most Underrated Skill in Data Science.]]></title>
            <link>https://medium.com/@jillysyuki/why-hypothesis-testing-is-the-most-underrated-skill-in-data-science-8d1317486c38?source=rss-fe0dc4144372------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d1317486c38</guid>
            <category><![CDATA[hypothesis-test]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jillysyuki]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 12:14:04 GMT</pubDate>
            <atom:updated>2026-06-28T12:14:04.254Z</atom:updated>
            <content:encoded><![CDATA[<h3>A coffee shop, a new recipe, and the question every data scientist has to answer</h3><p>Maya runs a small coffee shop near a university campus. One slow Tuesday, she decides to tweak her cold brew recipe — a little less bitter, a little smoother. She serves it to customers for a week without telling them anything changed.By Friday, she notices something: more people seem to be buying a second cup.</p><p>She’s excited. She tells her business partner, “The new recipe is working! Sales are up!”</p><p>Her partner, who happens to be taking an online data science course, asks one simple question:</p><blockquote><em>“Up compared to what? And how do you know it’s not just because it’s warmer this week, or because more students are on campus?”</em></blockquote><p>Maya doesn’t have an answer. And this — right here — is the exact problem that <strong>hypothesis testing</strong> was invented to solve.</p><p><strong>The Problem: Our Brains Are Bad at Telling Signal from Noise</strong></p><p>Here’s something that trips up almost every beginner in data science: when you look at <em>any</em> two numbers — last week’s sales vs. this week’s, Group A vs. Group B, old design vs. new design — they will rarely be exactly equal.</p><p>There will always be <em>some</em> difference. That’s just how random variation works.</p><p>So the real question is never “is there a difference?” It’s almost always:</p><blockquote><strong><em>“Is this difference big enough — and consistent enough — that it’s unlikely to be just random luck?”</em></strong></blockquote><p>That question is impossible to answer by eyeballing a chart or trusting a gut feeling. You need a formal process. That process is hypothesis testing.</p><h3>Back to Maya’s Coffee Shop</h3><p>Let’s slow down and walk through what a data scientist would actually do here, because this is where the concept stops being abstract.</p><h3>Step 1: State two competing explanations</h3><p>A data scientist would frame Maya’s situation as two competing stories:</p><ul><li><strong>The null hypothesis (H₀):</strong> The new recipe made no real difference. Any change in sales is just a random fluctuation — maybe the weather, maybe finals week, maybe pure chance.</li><li><strong>The alternative hypothesis (H₁):</strong> The new recipe genuinely increased how much people buy.</li></ul><p>Notice something important here: we <em>start</em> by assuming nothing happened (H₀). That’s deliberate. In data science, the burden of proof is on showing something <em>did</em> happen — not the other way around. This protects us from getting excited over every random blip in the data.</p><h3>Step 2: Collect real evidence — not just a vibe</h3><p>Maya’s “more people bought a second cup” is just an impression. A proper test would compare actual numbers: average cups sold per customer <em>before</em> the recipe change vs. <em>after</em>, across enough days to smooth out noise (not just one lucky Friday).</p><h3>Step 3: Ask “How surprising is this, if nothing really changed?”</h3><p>This is where the famous <strong>p-value</strong> comes in — and it trips up almost everyone the first time they learn it, so let’s make it concrete.</p><p>The p-value answers this exact question:</p><blockquote>“If the recipe actually changed nothing, what’s the probability we’d see a sales bump this big just by random chance?”</blockquote><p>If that probability is tiny — say, less than 5% — it’s a strong hint that the null hypothesis (H₀) is probably wrong, and something real is going on. If it’s not so tiny — say, 40% — then this kind of bump happens by chance often enough that it’s not convincing evidence of anything.</p><p>That 5% cutoff — called the <strong>significance level (α)</strong> — is something the data scientist decides <em>before</em> looking at results. That order matters a lot. If you peek at the data first and then pick whatever threshold makes your result look good, you’re not testing a hypothesis anymore — you’re just telling yourself a story you already wanted to believe.</p><h3>Step 4: Make a decision — and admit you could be wrong</h3><p>Let’s say Maya’s data comes back with a p-value of 0.02. That’s below the 5% threshold, so she rejects H₀ and concludes the new recipe likely did boost sales.</p><p>But here’s the part beginners often skip: <strong>this conclusion could still be wrong.</strong> There are two specific ways:</p><ul><li><strong>Type I error (false positive):</strong> Concluding the recipe worked when it actually didn’t — she got a lucky week.</li><li><strong>Type II error (false negative):</strong> Concluding the recipe didn’t work when it actually did — maybe her sample was too small to detect a real but modest effect.</li></ul><p>This is precisely why companies don’t bet everything on a one-week test. They run experiments longer, with more data, specifically to shrink the odds of both kinds of mistakes.</p><h3>Why This Tiny Coffee Shop Story Is Secretly About All of Data Science</h3><p>Maya’s situation looks small, but swap out the details, and you’ll recognize it everywhere:</p><ul><li>A streaming app changes its homepage layout and watches whether people stream more (this is <strong>A/B testing</strong>, and it runs entirely on hypothesis testing).</li><li>A researcher tests whether a new drug lowers blood pressure more than a placebo.</li><li>A data scientist checks whether a new feature actually improves a machine learning model, or whether the “improvement” is just noise from a lucky train/test split.</li><li>An analyst investigates whether customers in one region really spend more than another, or whether the apparent gap is small-sample randomness.</li></ul><p>In every one of these, the underlying question is identical to Maya’s: <em>is this real, or did we just get unlucky/lucky with the data we happened to collect?</em></p><p>That’s why hypothesis testing isn’t just “one topic in a statistics course.” It’s the quiet logic running underneath nearly every data-driven claim you’ll ever evaluate.</p><h3>What Happens Without It</h3><p>Imagine a version of Maya who never learns this. She changes her recipe, sees a good week, and declares victory. Next month, a slow week, and she panics and reverts to the recipe. The month after, she tries something else entirely, chasing whatever the most recent random fluctuation seemed to suggest.</p><p>She’s not making decisions anymore — she’s chasing noise.</p><p>Now scale that up. A company without rigorous testing might roll out an expensive redesign based on a single good week, lay off based on a misleading quarterly fluctuation, or scrap a genuinely good feature because a small early sample looked weak. Without a method for separating signal from noise, every decision becomes a coin flip dressed up as insight.</p><h3>The Takeaway</h3><p>Hypothesis testing matters in data science for one essential reason: <strong>almost everything we observe in data is a sample, not the full truth</strong>, and samples are noisy by nature. Hypothesis testing is the disciplined, repeatable way of asking, <em>“Is this pattern real, or did I just get a weird sample?”</em> — before staking a decision on the answer.</p><p>Maya, by the way, did eventually run the comparison properly — two full weeks, same days of the week compared fairly, customer counts accounted for. The new recipe held up. The smoother cold brew wasn’t a fluke.</p><p>It’s a small story. But it’s the same logic guarding nearly every “the data shows…” claim you’ll ever read — including the ones you’ll eventually make yourself.</p><p><em>If you’re learning data science, here’s the practical habit to take from this: the next time you see a difference in any dataset — sales, click-through rates, test scores, anything — pause and ask Maya’s partner’s question: “Compared to what, and how do we know it’s not just chance?” That single habit is hypothesis testing in action.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d1317486c38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PYTHON AND ITS ROLE IN DATA ANALYTICS.]]></title>
            <link>https://medium.com/@jillysyuki/python-and-its-role-in-data-analytics-7bca58985852?source=rss-fe0dc4144372------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bca58985852</guid>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Jillysyuki]]></dc:creator>
            <pubDate>Sat, 09 May 2026 21:25:54 GMT</pubDate>
            <atom:updated>2026-05-09T21:25:54.530Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>INTRODUCTION.</strong></p><ul><li>python is a high-level programming language used in data analysis, web development, automation, artificial intelligence, and more.</li><li>Python is a programming language used to communicate with computers. Just like humans use English or Swahili to communicate, we use Python to give instructions to a computer..</li><li>It is designed to be simple and easy to read, which makes it perfect for beginners. Python is used in many real-world applications such as analyzing data, building websites, automating repetitive tasks, and developing artificial intelligence systems.</li><li>When you write Python code, you are simply telling the computer what to do step by step.</li><li>We can run Python in Jupyter notebook ,Jupyter lab on Anaconda, IDE like pycharm, or spider or use text edit and terminal(for a system with python interplater installed)</li><li>The first thing beginners need to understand is that programming is about writing instructions and seeing results.</li><li>The print() function is one of the most basic and important tools in Python. It tells the computer to display something on the screen.</li><li>example of a python language is</li></ul><pre>print(&quot;Hello, world!&quot;)</pre><p>This kind of code instrusts te computer to show the text Hello World on the screen.</p><p>Print() displays output.</p><p>Python has its on rules like:</p><ol><li>a string must be written in quotes</li><li>comment your code e.g</li></ol><pre>#calculate average marks<br>average = sum(sales_)/len(sales)</pre><p>3.Following the PEP 8 rules</p><p>It recommends :</p><p>.proper spacing</p><p>.clear naming</p><p>.readable formating.</p><pre>g = 5<br>y = 8<br>total = x + y </pre><h3>. Variables and Data Types.</h3><ul><li>A variable is like a container used to store information. Instead of repeating values again and again, we store them in variables and reuse them.</li><li>A data type is a classification that tells a computer what kind of value a variable is storing and what operation can be perfomed on it.</li></ul><p>Examples:</p><pre>name = &quot;grace&quot;<br>age = 18<br>height = 1.75<br></pre><p>Concepts:</p><ul><li>Variables store data</li><li>Common data types:</li><li>— String (text)</li></ul><pre>name = &quot; Aisha&quot;</pre><ul><li>— Integer (whole numbers) example like 20</li></ul><pre>age = 20</pre><ul><li>— Float (decimals).example :</li></ul><pre>price = 99.50</pre><ul><li>— Boolean (True/False)</li></ul><pre>is_logged_out = true</pre><p>.List- stores multiple values in one variable.</p><p>example:</p><pre>fruits = [&quot;apple&quot;, &quot;oranges&quot;,&quot;mango&quot;]</pre><p>. — Tuple — similar to alist but values cannot be changed</p><p>Example:</p><pre>marks(10, 20,30, 40)</pre><p>. — dictionary(dict)- stores data in key_value pairs.</p><p>example:</p><pre>student = {<br>    &quot;name&quot; : &quot;john&quot;,<br>    &quot;age&quot; :  20,<br>}</pre><p>“name” are the keys while “john” are the values</p><p><strong>How to check a data type in python</strong></p><p>In checking of a data type you use a type()</p><p>Example:</p><pre>age = 26<br>print(type(age))</pre><pre>output<br>&lt;classs &#39;int&#39; &gt;</pre><p><strong>why is python popular in data analytics</strong></p><p>python has become popular in data analytics because it is easy to learn and use .python syntax is very simple and understable making it easy for beginners to learn.</p><p>python has a very large global community of developers,students and proffessionals. most likely you can find python tutorials in websites like youtube,udemy and tiktok.</p><p>python is used for many tasks like used for web development,data analysis and cyber security,</p><p>python can be used to integrate with other databases or other programming languages eg postgressql,excel files,mysql databases.</p><p>python has large collection of libraries that are specially designed for data analytics.The libraries make data analysis faster and easier by reducing the amount of code needed.</p><p>some of the libraries have learned this week is Pandas.</p><p>Pandas is used for working with tables and structured data.With pandas users can read CSV files,sort data , group data, perform calculation and clean missing data.</p><p>example:</p><pre>import pandas as pd<br> data = pd.read_csv(&quot;sales.csv&quot;)<br>print(data.head())<br></pre><p><strong>HOW PYTHON IS USED IN DATA ANALYTICS.</strong></p><p>Python is used in data collection.</p><p>Python can collect data from websites,excel files,csv files,APIs .</p><p>APIs allows analytics to retrieve live data from online platforms like mockaroo.</p><pre>import requests<br>response = requests.get(&quot;link from the github&quot;)<br>print(response.json())</pre><p><strong>Also used in data cleaning</strong></p><p>raw data can be very messy and dirty.Python can be used for missing values,remove duplicates,remove incorrect entries,formatting errors and e.t.c.</p><p><strong>3.data analysis</strong></p><p>python may be used to examine trends and patterns.Python helps in calculating averages,min(),max(),mean(),count()</p><pre>data[&quot;sales&quot;].mean()</pre><p><strong>4)predictive analytics</strong></p><p>Python is used for predicting analytics.Helps in forecasting future outcomes based on historical data like forecsating sales,detecting fraud,predicting stock prices and recommending products.</p><p><strong>5).Data visualization.</strong></p><p>visualizating of data helps people understand information more easily</p><p>examples of data visualization is use of sales dashboards by businesses,hospitals tracking patient statistics,governments monitoring population data,schools tracking students stastistics.</p><p>visualization improves communication and also reporting.</p><p><strong>REAL WORLD EXAMPLES OF PYTHON IN DATA ANALYTICS.</strong></p><p>Python is used in many industries like</p><h3>1. E-commerce — Customer Purchase Analysis</h3><p>Companies like Amazon analyze customer behavior using Python.</p><h3>Example:</h3><p>A retailer wants to know:</p><ul><li>Which products sell most</li><li>Which customers buy repeatedly</li><li>What time sales peak</li><li>Which products are commonly bought together</li></ul><h3>Python tools used:</h3><ul><li>Pandas → clean and analyze sales data</li><li>Matplotlib → create charts</li><li>NumPy → calculations</li></ul><h3>Simple workflow:</h3><pre>import pandas as pd</pre><pre>sales = pd.read_csv(&quot;sales.csv&quot;)</pre><pre>top_products = sales[&quot;product&quot;].value_counts()</pre><pre>print(top_products.head())</pre><h3>Business outcome:</h3><ul><li>Better inventory planning</li><li>Personalized recommendations</li><li>Increased revenue</li></ul><h3>2. Banking — Fraud Detection</h3><p>Banks use Python to detect suspicious transactions in real time.</p><h3>Example:</h3><p>A bank monitors:</p><ul><li>unusually large withdrawals</li><li>foreign transactions</li><li>rapid multiple purchases</li></ul><h3>Python libraries:</h3><ul><li>Scikit-learn</li><li>TensorFlow</li></ul><h3>Real impact:</h3><p>If a transaction pattern looks abnormal, the system can:</p><ul><li>freeze the transaction</li><li>send an alert</li><li>request verification</li></ul><p>This reduces fraud losses significantly.</p><h3>3. Healthcare — Patient Data Analysis</h3><p>Hospitals analyze patient records to improve treatment decisions.</p><h3>Example:</h3><p>Doctors may analyze:</p><ul><li>disease trends</li><li>recovery rates</li><li>patient readmission patterns</li></ul><p>Python helps identify:</p><ul><li>high-risk patients</li><li>common symptoms</li><li>effectiveness of treatments</li></ul><h3>Libraries:</h3><ul><li>Pandas</li><li>NumPy</li><li>Jupyter Notebook</li></ul><h3>4. Social Media — Sentiment Analysis</h3><p>Platforms like X, Meta, and marketing agencies analyze public opinions.</p><h3>Example:</h3><p>A company launches a new phone and wants to know:</p><ul><li>Are people happy?</li><li>What complaints appear most?</li></ul><p>Python can analyze thousands of comments automatically.</p><h3>Tools:</h3><ul><li>NLTK</li><li>spaCy</li></ul><h3>Example result:</h3><pre>72% Positive<br>18% Neutral<br>10% Negative</pre><h3>5. Logistics — Delivery Optimization</h3><p>Companies like Uber and FedEx use Python for route optimization.</p><h3>Example:</h3><p>Python analyzes:</p><ul><li>traffic</li><li>fuel usage</li><li>delivery times</li><li>driver efficiency</li></ul><h3>Outcome:</h3><ul><li>Faster deliveries</li><li>Reduced fuel costs</li><li>Better customer satisfaction</li></ul><h3>6. Sports Analytics</h3><p>Sports teams use Python to analyze player performance.</p><h3>Example:</h3><p>A football club can analyze:</p><ul><li>pass accuracy</li><li>sprint speed</li><li>scoring patterns</li><li>injury risk</li></ul><h3>Libraries:</h3><ul><li>Pandas</li><li>Matplotlib</li><li>Plotly</li></ul><h3>7. Finance &amp; Trading</h3><p>Traders use Python to analyze markets and automate strategies.</p><h3>Example:</h3><p>Python can:</p><ul><li>track stock prices</li><li>calculate indicators</li><li>detect trends</li><li>backtest strategies</li></ul><h3>Common libraries:</h3><ul><li>Pandas</li><li>NumPy</li><li>yfinance</li></ul><h3>Why Python Is Popular in Data Analytics</h3><p>Python is widely used because it is:</p><ul><li>Easy to learn</li><li>Good for automation</li><li>Excellent for visualization</li><li>Strong for machine learning</li><li>Supported by huge libraries and community</li></ul><h3>Typical Python Data Analytics Stack</h3><p>PurposeToolData cleaningPandasNumerical analysisNumPyVisualizationMatplotlib / PlotlyMachine learningScikit-learnDashboardsStreamlitSQL connectionSQLAlchemy</p><h3>Beginner Project Idea</h3><p>You could build a simple sales dashboard using:</p><ul><li>Python</li><li>Pandas</li><li>Matplotlib</li><li>CSV sales data</li></ul><p>It would teach:</p><ul><li>data cleaning</li><li>grouping/filtering</li><li>chart creation</li><li>business insights</li></ul><p>If you want, I can also show you:</p><ol><li>A full beginner-friendly Python analytics project</li><li>A roadmap to become a data analyst with Python</li><li>Real datasets you can practice on</li><li>The exact Python skills companies look for in analysts</li></ol><h3>1. E-commerce — Customer Purchase Analysis</h3><p>Companies like Amazon analyze customer behavior using Python.</p><h3>Example:</h3><p>A retailer wants to know:</p><ul><li>Which products sell most</li><li>Which customers buy repeatedly</li><li>What time sales peak</li><li>Which products are commonly bought together</li></ul><h3>Python tools used:</h3><ul><li>Pandas → clean and analyze sales data</li><li>Matplotlib → create charts</li><li>NumPy → calculations</li></ul><h3>Simple workflow:</h3><pre>import pandas as pd</pre><pre>sales = pd.read_csv(&quot;sales.csv&quot;)</pre><pre>top_products = sales[&quot;product&quot;].value_counts()</pre><pre>print(top_products.head())</pre><h3>Business outcome:</h3><ul><li>Better inventory planning</li><li>Personalized recommendations</li><li>Increased revenue</li></ul><h3>2. Banking — Fraud Detection</h3><p>Banks use Python to detect suspicious transactions in real time.</p><h3>Example:</h3><p>A bank monitors:</p><ul><li>unusually large withdrawals</li><li>foreign transactions</li><li>rapid multiple purchases</li></ul><h3>Python libraries:</h3><ul><li>Scikit-learn</li><li>TensorFlow</li></ul><h3>Real impact:</h3><p>If a transaction pattern looks abnormal, the system can:</p><ul><li>freeze the transaction</li><li>send an alert</li><li>request verification</li></ul><p>This reduces fraud losses significantly.</p><h3>3. Healthcare — Patient Data Analysis</h3><p>Hospitals analyze patient records to improve treatment decisions.</p><h3>Example:</h3><p>Doctors may analyze:</p><ul><li>disease trends</li><li>recovery rates</li><li>patient readmission patterns</li></ul><p>Python helps identify:</p><ul><li>high-risk patients</li><li>common symptoms</li><li>effectiveness of treatments</li></ul><h3>Libraries:</h3><ul><li>Pandas</li><li>NumPy</li><li>Jupyter Notebook</li></ul><h3>4. Social Media — Sentiment Analysis</h3><p>Platforms like X, Meta, and marketing agencies analyze public opinions.</p><h3>Example:</h3><p>A company launches a new phone and wants to know:</p><ul><li>Are people happy?</li><li>What complaints appear most?</li></ul><p>Python can analyze thousands of comments automatically.</p><h3>Tools:</h3><ul><li>NLTK</li><li>spaCy</li></ul><h3>Example result:</h3><pre>72% Positive<br>18% Neutral<br>10% Negative</pre><h3>5. Logistics — Delivery Optimization</h3><p>Companies like Uber and FedEx use Python for route optimization.</p><h3>Example:</h3><p>Python analyzes:</p><ul><li>traffic</li><li>fuel usage</li><li>delivery times</li><li>driver efficiency</li></ul><h3>Outcome:</h3><ul><li>Faster deliveries</li><li>Reduced fuel costs</li><li>Better customer satisfaction</li></ul><h3>6. Sports Analytics</h3><p>Sports teams use Python to analyze player performance.</p><h3>Example:</h3><p>A football club can analyze:</p><ul><li>pass accuracy</li><li>sprint speed</li><li>scoring patterns</li><li>injury risk</li></ul><h3>Libraries:</h3><ul><li>Pandas</li><li>Matplotlib</li><li>Plotly</li></ul><h3>7. Finance &amp; Trading</h3><p>Traders use Python to analyze markets and automate strategies.</p><h3>Example:</h3><p>Python can:</p><ul><li>track stock prices</li><li>calculate indicators</li><li>detect trends</li><li>backtest strategies</li></ul><h3>Common libraries:</h3><ul><li>Pandas</li><li>NumPy</li><li>yfinance</li></ul><h3>Why Python Is Popular in Data Analytics</h3><p>Python is widely used because it is:</p><ul><li>Easy to learn</li><li>Good for automation</li><li>Excellent for visualization</li><li>Strong for machine learning</li><li>Supported by huge libraries and community</li></ul><h3>Typical Python Data Analytics Stack</h3><p>PurposeToolData cleaningPandasNumerical analysisNumPyVisualizationMatplotlib / PlotlyMachine learningScikit-learnDashboardsStreamlitSQL connectionSQLAlchemy</p><h3>Beginner Project Idea</h3><p>You could build a simple sales dashboard using:</p><ul><li>Python</li><li>Pandas</li><li>Matplotlib</li><li>CSV sales data</li></ul><p>It would teach:</p><ul><li>data cleaning</li><li>grouping/filtering</li><li>chart creation</li><li>business insights</li></ul><p>If you want, I can also show you:</p><ol><li>A full beginner-friendly Python analytics project</li><li>A roadmap to become a data analyst with Python</li><li>Real datasets you can practice on</li><li>The exact Python skills companies look for in analysts</li></ol><p>v1. E-commerce — Customer Purchase Analysis</p><p>Companies like Amazon analyze customer behavior using Python.</p><h3>Example:</h3><p>A retailer wants to know:</p><ul><li>Which products sell most</li><li>Which customers buy repeatedly</li><li>What time sales peak</li><li>Which products are commonly bought together</li></ul><h3>Python tools used:</h3><ul><li>Pandas → clean and analyze sales data</li></ul><h3>Business outcome:</h3><ul><li>Better inventory planning</li><li>Personalized recommendations</li><li>Increased revenue</li></ul><h3>2. Banking — Fraud Detection</h3><p>Banks use Python to detect suspicious transactions in real time.</p><h3>Example:</h3><p>A bank monitors:</p><ul><li>unusually large withdrawals</li><li>foreign transactions</li><li>rapid multiple purchases</li></ul><h3>Python libraries:</h3><ul><li>Scikit-learn</li><li>TensorFlow</li></ul><h3>Real impact:</h3><p>If a transaction pattern looks abnormal, the system can:</p><ul><li>freeze the transaction</li><li>send an alert</li><li>request verification</li></ul><p>This reduces fraud losses significantly.</p><h3>3. Healthcare — Patient Data Analysis</h3><p>Hospitals analyze patient records to improve treatment decisions.</p><h3>Example:</h3><p>Doctors may analyze:</p><ul><li>disease trends</li><li>recovery rates</li><li>patient readmission patterns</li></ul><p>Python helps identify:</p><ul><li>high-risk patients</li><li>common symptoms</li><li>effectiveness of treatments</li></ul><h3>Libraries:</h3><ul><li>Pandas</li><li>NumPy</li><li>Jupyter Notebook</li></ul><h3>4. Social Media — Sentiment Analysis</h3><p>Platforms like X, Meta, and marketing agencies analyze public opinions.</p><h3>Example:</h3><p>A company launches a new phone and wants to know:</p><ul><li>Are people happy?</li><li>What complaints appear most?</li></ul><p>Python can analyze thousands of comments automatically.</p><h3>5. Logistics — Delivery Optimization</h3><p>Companies like Uber and FedEx use Python for route optimization.</p><h3>Example:</h3><p>Python analyzes:</p><ul><li>traffic</li><li>fuel usage</li><li>delivery times</li><li>driver efficiency</li></ul><h3>Outcome:</h3><ul><li>Faster deliveries</li><li>Reduced fuel costs</li><li>Better customer satisfaction</li></ul><h3>6. Sports Analytics</h3><p>Sports teams use Python to analyze player performance.</p><h3>Example:</h3><p>A football club can analyze:</p><ul><li>pass accuracy</li><li>sprint speed</li><li>scoring patterns</li><li>injury risk</li></ul><h3>Libraries:</h3><ul><li>Pandas</li></ul><h3>7. Finance &amp; Trading</h3><p>Traders use Python to analyze markets and automate strategies.</p><h3>Example:</h3><p>Python can:</p><ul><li>track stock prices</li><li>calculate indicators</li><li>detect trends</li><li>backtest strategies</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bca58985852" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Subqueries vs CTEs in SQL: A Practical Guide for Data Analysts and Engineers]]></title>
            <link>https://medium.com/@jillysyuki/subqueries-vs-ctes-in-sql-a-practical-guide-for-data-analysts-and-engineers-1b6375a8deac?source=rss-fe0dc4144372------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b6375a8deac</guid>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Jillysyuki]]></dc:creator>
            <pubDate>Sat, 18 Apr 2026 09:50:06 GMT</pubDate>
            <atom:updated>2026-04-18T09:50:06.296Z</atom:updated>
            <content:encoded><![CDATA[<p>Structured Query Language (SQL) is the backbone of data work, and mastering its advanced features is essential for writing efficient and readable queries. Two of the most important concepts in SQL are <strong>subqueries</strong> and <strong>Common Table Expressions (CTEs)</strong>. While they often solve similar problems, they differ significantly in structure, readability, and use cases.</p><p>This article provides a clear and practical explanation of subqueries and CTEs, when to use each, and how they compare.</p><h3>What is a Subquery?</h3><p>A <strong>subquery</strong> is a query nested inside another SQL query. It is used to perform operations that depend on the result of another query.</p><h3>Example:</h3><pre>SELECT customer_name<br>FROM orders<br>WHERE sales &gt; (<br>    SELECT AVG(sales)<br>    FROM orders<br>);</pre><p>In this example:</p><ul><li>The inner query calculates the average sales.</li><li>The outer query uses that result to filter customers.</li></ul><h3>Types of Subqueries</h3><h3>1. Single-row Subquery</h3><p>Returns only one value.</p><pre>SELECT *<br>FROM employees<br>WHERE salary &gt; (<br>    SELECT AVG(salary) FROM employees<br>);</pre><h3>2. Multi-row Subquery</h3><p>Returns multiple values and uses operators like IN, ANY, or ALL.</p><pre>SELECT *<br>FROM employees<br>WHERE department_id IN (<br>    SELECT department_id FROM departments WHERE location = &#39;Nairobi&#39;<br>);</pre><h3>3. Correlated Subquery</h3><p>Runs once for each row of the outer query.</p><pre>SELECT e1.name<br>FROM employees e1<br>WHERE salary &gt; (<br>    SELECT AVG(salary)<br>    FROM employees e2<br>    WHERE e1.department_id = e2.department_id<br>);</pre><p>This is powerful but can be slow on large datasets.</p><h3>4. Scalar Subquery</h3><p>Returns a single value and is often used in the SELECT clause.</p><pre>SELECT <br>    name,<br>    (SELECT AVG(salary) FROM employees) AS avg_salary<br>FROM employees;</pre><h3>When Should You Use Subqueries?</h3><p>Use subqueries when:</p><ul><li>You need <strong>quick filtering logic</strong></li><li>The query is <strong>simple and short</strong></li><li>You don’t need to reuse the result multiple times</li><li>You are performing <strong>nested comparisons</strong></li></ul><p>Best for:</p><ul><li>Filters (WHERE)</li><li>Simple lookups</li><li>Inline calculations</li></ul><h3>What are CTEs (Common Table Expressions)?</h3><p>A <strong>CTE</strong> is a temporary result set defined using the WITH clause that you can reference within your query.</p><h3>Example:</h3><pre>WITH avg_sales AS (<br>    SELECT AVG(sales) AS avg_value<br>    FROM orders<br>)<br>SELECT *<br>FROM orders<br>WHERE sales &gt; (SELECT avg_value FROM avg_sales);</pre><p>Think of a CTE as a <strong>temporary named table</strong> that exists only during query execution.</p><h3>Types of CTEs and Use Cases</h3><h3>1. Simple CTE</h3><p>Used to simplify complex queries.</p><pre>WITH sales_summary AS (<br>    SELECT customer_id, SUM(sales) AS total_sales<br>    FROM orders<br>    GROUP BY customer_id<br>)<br>SELECT *<br>FROM sales_summary<br>WHERE total_sales &gt; 1000;</pre><h3>2. Multiple CTEs</h3><p>You can define more than one CTE.</p><pre>WITH sales_summary AS (<br>    SELECT customer_id, SUM(sales) AS total_sales<br>    FROM orders<br>    GROUP BY customer_id<br>),<br>top_customers AS (<br>    SELECT *<br>    FROM sales_summary<br>    WHERE total_sales &gt; 1000<br>)<br>SELECT * FROM top_customers;</pre><h3>3. Recursive CTE</h3><p>Used for hierarchical or tree-structured data.</p><pre>WITH RECURSIVE employee_hierarchy AS (<br>    SELECT id, manager_id, name<br>    FROM employees<br>    WHERE manager_id IS NULL</pre><pre>    UNION ALL</pre><pre>    SELECT e.id, e.manager_id, e.name<br>    FROM employees e<br>    JOIN employee_hierarchy eh ON e.manager_id = eh.id<br>)<br>SELECT * FROM employee_hierarchy;</pre><p>Useful for:</p><ul><li>Organizational charts</li><li>Category hierarchies</li><li>Graph traversal</li></ul><h3>When Should You Use CTEs?</h3><p>Use CTEs when:</p><ul><li>Queries are <strong>complex or long</strong></li><li>You need <strong>better readability</strong></li><li>You want to <strong>reuse logic multiple times</strong></li><li>You’re working with <strong>step-by-step transformations</strong></li><li>You need <strong>recursive logic</strong></li></ul><h3>Subqueries vs CTEs (Key Comparison)</h3><p>FeatureSubqueriesCTEsReadabilityHarder in complex queriesMuch easier to readReusabilityNot reusableReusable within queryPerformanceCan be slower (especially correlated)Often optimized betterStructureNested inside queryDefined at the top (WITH)DebuggingHarderEasier (step-by-step logic)</p><h3>Performance Considerations</h3><ul><li><strong>Subqueries</strong></li><li>Correlated subqueries can be slow</li><li>May execute multiple times</li><li><strong>CTEs</strong></li><li>More optimized in modern databases</li><li>Easier for query planners to understand</li><li>But in some cases (older PostgreSQL versions), they may not inline</li></ul><p>Rule of thumb:</p><ul><li>Use <strong>CTEs for clarity</strong></li><li>Use <strong>subqueries for simplicity</strong></li></ul><h3>Practical Example (Side-by-Side)</h3><h3>Using Subquery</h3><pre>SELECT product_name, SUM(sales)<br>FROM orders<br>GROUP BY product_name<br>HAVING SUM(sales) &gt; (<br>    SELECT AVG(total_sales)<br>    FROM (<br>        SELECT SUM(sales) AS total_sales<br>        FROM orders<br>        GROUP BY product_name<br>    ) t<br>);</pre><h3>Using CTE (Cleaner)</h3><pre>WITH product_sales AS (<br>    SELECT product_name, SUM(sales) AS total_sales<br>    FROM orders<br>    GROUP BY product_name<br>),<br>avg_sales AS (<br>    SELECT AVG(total_sales) AS avg_value<br>    FROM product_sales<br>)<br>SELECT *<br>FROM product_sales<br>WHERE total_sales &gt; (SELECT avg_value FROM avg_sales);</pre><p>Same result, but the CTE version is far easier to understand and maintain.</p><h3>Conclusion</h3><p>Subqueries and CTEs are both essential tools in SQL, but they serve different purposes:</p><ul><li>Use <strong>subqueries</strong> for quick, simple operations</li><li>Use <strong>CTEs</strong> for complex, readable, and reusable logic</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b6375a8deac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MY JOURNEY LEARNING SQL USING DBEAVER — A BEGINNER'S GUIDE.]]></title>
            <link>https://medium.com/@jillysyuki/my-journey-learning-sql-using-dbeaver-a-beginners-guide-2d11d7639fe2?source=rss-fe0dc4144372------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d11d7639fe2</guid>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Jillysyuki]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 13:09:30 GMT</pubDate>
            <atom:updated>2026-04-12T13:09:30.962Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>INTRODUCTION.</strong></p><p>This week, I have been learning how to build a database using SQL in DBeaver. The goal is to understand how databases are created, managed, and queried.</p><p><strong>Understanding DDL And DML.</strong></p><p>SQL has different categories, but we will discuss the two important ones.</p><p>1)DML(data manipulation language)-used to manage data inside tables, examples: INSERT, UPDATE, DELETE, and many more.</p><p>DDL(data definition language)-used to create and modify databases structure example, CREATE, ALTER, DROP and etc.</p><p><strong>SECTION A -BUILDING THE DATABASE (DDL)</strong></p><p><strong>Creating the database.</strong></p><p>I will be creating a dataset called Nairobi Academy.</p><p>Open DBeaver, right click, SQL editor, new SQL script.</p><p>Create a new SQL script.</p><p>Create a schema called nairobi_academy and run the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tx61anA9S9RcGzLH3U29Xg.png" /></figure><p><strong>STEP 2: Create tables.</strong></p><p>Creating three tables using CREATE TABLE.</p><ol><li>students table</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*OXIZnY3feYf3n0RVouc-ag.png" /></figure><p>2.subjects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*p_Algw5BpoTwK7ziJnm5Tg.png" /></figure><p>3.exam_results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*PVhOUNVe9XIrHgDDT7vk3g.png" /></figure><p>STEP 4:ALTER TABLE.</p><p>ALTER TABLES is used to change a certain table. In this case, we will use it to add a new column in the students table called phone number with a varchar(20).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*YWiGTaNasSzVqicowGcC5g.png" /></figure><p><strong>Renaming the column credit_hours in the subjects table to credits.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*H3h8Awee6sYVkM14DAdu7g.png" /></figure><p>If the school decides they no longer need the phone_number column added, I will write a SQL to remove it completely from the students table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*lXMg3yFnQV00dXoulLBPXg.png" /><figcaption>removing the phone_number column.</figcaption></figure><p><strong>SECTION B FILLING THE DATABASE (DML: INSERT, UPDATE, DELETE)</strong></p><p>We will insert 10 students, exam_results, and 10 subjects into the students table.</p><p>After inserting, run a select query to confirm all 10 rows exist in each of the three tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ZEc_vaJYCRl8dpFMe6rkA.png" /><figcaption>students table.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oc9MZfqTmv_GxEtVZI6FHw.png" /><figcaption>subjects table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RRc-9mRoyw_Mz_trzFjIBA.png" /><figcaption>exam_results table.</figcaption></figure><p>Esther Akinyi has moved from Nakuru to Nairobi. I will write an update statement to change her city for student_id 5, and the mark result_id 5 was entered incorrectly. The correct marks are 59, not 49, so we will update using UPDATE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*ZKuNAMmW34Hy_sNXaylgSw.png" /></figure><p>The exam result with result_id 9 has been cancelled by the school, so we will write a delete statement to delete it from the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*YaUjL-0J10aPRWWPSpqV_w.png" /></figure><p><strong>SECTION C: QUERYING THE DATA (FILTERING WITH WHERE)</strong></p><p>The WHERE clause helps filter data.</p><p>Examples I used:</p><p>.=(equal to)</p><p>.greater than</p><p>.between</p><p>.and</p><p>.or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*w5K2UZGPgyu0OWRUPpt63g.png" /></figure><p><strong>between, in/not in, like, count.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*-nMinDX3wXtNiLs2U-NQHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*3KnANbvEO_0MeeQ_LwNQUA.png" /></figure><p><strong>CASE WHEN</strong>.</p><p>case when helps transform data into meaningful categories.</p><p>For example, in this case, I transformed</p><p>marks above 80 -distinction</p><p>marks ≥60- merit</p><p>marks ≥40-pass</p><p>Marks below 40- fail</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*plpyCrB61u28nxrKZ5geuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yC1jHeKyPISw-dO6BFJOIA.png" /></figure><p><strong>reflection</strong></p><p>This assignment helped me to understand how databases work from creation to querying.</p><p>SQL is a powerful tool for managing and analyzing data.Using DBeaver made it easier to write and test queries visually.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d11d7639fe2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>