<?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 VENGATESH A on Medium]]></title>
        <description><![CDATA[Stories by VENGATESH A on Medium]]></description>
        <link>https://medium.com/@a.vengatesh123?source=rss-d30379eaaadc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bpXTi-XkM1Kc3nfZxK6chA.jpeg</url>
            <title>Stories by VENGATESH A on Medium</title>
            <link>https://medium.com/@a.vengatesh123?source=rss-d30379eaaadc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 10:08:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a.vengatesh123/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[SQL Operators Made Simple: A Practical Guide to Calculating, Comparing and Filtering Data]]></title>
            <link>https://medium.com/@a.vengatesh123/sql-operators-made-simple-a-practical-guide-to-calculating-comparing-and-filtering-data-8d44b8ea438e?source=rss-d30379eaaadc------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d44b8ea438e</guid>
            <category><![CDATA[big-data-analytics]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[VENGATESH A]]></dc:creator>
            <pubDate>Fri, 09 Oct 2026 15:07:33 GMT</pubDate>
            <atom:updated>2026-10-09T15:07:33.126Z</atom:updated>
            <content:encoded><![CDATA[<p><em>By Vengatesh A | Last updated: October 2026 | 10 min read</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*wP56csCPhxtxa-VF3aO-FQ.avif" /></figure><p>Most wrong SQL results don’t come from broken syntax. They come from a query that runs perfectly and quietly answers the wrong question. Nine times out of ten, the culprit is an operator used in a way you didn’t expect.</p><p>Operators are the small symbols and keywords that make a query do real work. They add numbers, compare values, match text, and decide which rows survive a filter. This guide walks through the six groups you’ll rely on every day, shows each one with queries you can adapt, and points out the pitfalls that catch people out.</p><h3>At a Glance</h3><p><strong>Topic</strong> The operators used to calculate, compare and filter data in SQL <strong>Best for</strong> Beginners, analysts, developers and engineers who write queries regularly <strong>Covered here</strong> Arithmetic, comparison, logical, LIKE, IN and BETWEEN <strong>You should know</strong> How a basic SELECT statement and a table are structured <strong>Main danger</strong> Precedence mix-ups and NULL values that change results without any error <strong>Rule to remember</strong> If a condition is complicated, wrap it in parentheses</p><h3>1. Arithmetic Operators: Doing Math Inside a Query</h3><p>Arithmetic operators let the database do the calculation for you, instead of exporting data and working it out in a spreadsheet.</p><p>Symbol What it does Quick example + Adds subtotal + delivery_fee - Subtracts revenue - cost * Multiplies units * unit_price / Divides points / attempts % Returns the remainder invoice_id % 2</p><p><strong>Adding values.</strong> Here we add a delivery fee to an item’s price:</p><pre>SELECT item_name, price, delivery_fee,<br>       price + delivery_fee AS final_price<br>FROM catalog;</pre><p><strong>Subtracting values.</strong> Profit is simply what’s left after costs:</p><pre>SELECT month_name, revenue, cost,<br>       revenue - cost AS profit<br>FROM monthly_finance;</pre><p><strong>Multiplying values.</strong> Line totals come from quantity times price:</p><pre>SELECT item_name, units_sold, unit_price,<br>       units_sold * unit_price AS line_total<br>FROM sales_lines;</pre><p><strong>Dividing values.</strong> Use division for averages and ratios:</p><pre>SELECT learner_name, total_score, tests_taken,<br>       total_score / tests_taken AS avg_score<br>FROM results;</pre><blockquote><strong><em>Two division traps.</em></strong><em> First, many databases (PostgreSQL and SQL Server among them) return a whole number when both sides are integers, so </em><em>7 / 2 becomes </em><em>3. Multiply by </em><em>1.0 to keep the decimals. Second, dividing by zero throws an error, which </em><em>NULLIF prevents:</em></blockquote><pre>SELECT total_score * 1.0 / NULLIF(tests_taken, 0) AS avg_score<br>FROM results;</pre><p><strong>Using the remainder.</strong> The % operator is a neat way to separate odd from even, or to spread rows across groups:</p><pre>-- Customers with an even ID<br>SELECT customer_id, customer_name<br>FROM customers<br>WHERE customer_id % 2 = 0;</pre><p><strong>Which calculation runs first?</strong> Multiplication, division and modulo run before addition and subtraction. Parentheses override everything:</p><pre>SELECT 10 + 5 * 2;    -- 20<br>SELECT (10 + 5) * 2;  -- 30</pre><p><em>A note on powers: there’s no universal power operator in SQL. PostgreSQL accepts </em><em>^ and </em><em>POWER(), while SQL Server and MySQL use </em><em>POWER().</em></p><h3>2. Comparison Operators: Asking “How Do These Two Values Relate?”</h3><p>Comparison operators check two values against each other. The answer is TRUE, FALSE or, when a NULL is involved, UNKNOWN.</p><p>Symbol Meaning = Equal to &lt;&gt; or != Not equal to &gt; Greater than &lt; Less than &gt;= Greater than or equal to &lt;= Less than or equal to</p><pre>-- Exact match<br>SELECT * FROM staff WHERE team = &#39;Support&#39;;</pre><pre>-- Everything except one value<br>SELECT * FROM catalog WHERE type &lt;&gt; &#39;Furniture&#39;;</pre><pre>-- Above a threshold<br>SELECT * FROM invoices WHERE amount &gt; 2500;</pre><pre>-- Below a threshold<br>SELECT * FROM results WHERE total_score &lt; 40;</pre><pre>-- At least a minimum<br>SELECT * FROM staff WHERE tenure_years &gt;= 3;</pre><pre>-- At most a maximum<br>SELECT * FROM catalog WHERE price &lt;= 20;</pre><h3>NULL Needs Special Treatment</h3><p>A NULL isn’t zero and it isn’t an empty string. It means “no known value.” Because of that, nothing equals NULL, not even another NULL. This query will always come back empty:</p><pre>-- Returns nothing, even if NULLs exist<br>SELECT * FROM customers WHERE phone = NULL;</pre><pre>-- Correct way to find missing values<br>SELECT * FROM customers WHERE phone IS NULL;</pre><pre>-- Correct way to find filled-in values<br>SELECT * FROM customers WHERE phone IS NOT NULL;</pre><p>There’s a quieter version of the same problem. A filter like type &lt;&gt; &#39;Furniture&#39; also drops rows where type is NULL. If you want them back, say so explicitly:</p><pre>SELECT * FROM catalog<br>WHERE type &lt;&gt; &#39;Furniture&#39; OR type IS NULL;</pre><h3>3. Logical Operators: Combining Conditions</h3><p>Real questions usually involve more than one condition. Logical operators let you join them.</p><ul><li><strong>AND</strong> keeps a row only when every condition is true, so it narrows results.</li><li><strong>OR</strong> keeps a row when any one condition is true, so it widens results.</li><li><strong>NOT</strong> flips a condition from true to false and back.</li></ul><pre>-- AND: support staff with more than 3 years of tenure<br>SELECT * FROM staff<br>WHERE team = &#39;Support&#39; AND tenure_years &gt; 3;</pre><pre>-- OR: furniture items, or anything with plenty of stock<br>SELECT * FROM catalog<br>WHERE type = &#39;Furniture&#39; OR stock &gt; 200;</pre><pre>-- NOT: learners who haven&#39;t completed the course<br>SELECT * FROM learners<br>WHERE NOT (completed = TRUE);</pre><p><em>Boolean columns differ between systems. PostgreSQL lets you write </em><em>WHERE NOT completed, while MySQL and SQL Server often store flags as 0 and 1, so </em><em>WHERE completed = 0 is safer there.</em></p><h3>The AND/OR Trap</h3><p>When a query contains both, SQL doesn’t read left to right. It handles <strong>NOT first, then AND, then OR</strong>.</p><p>Consider this query:</p><pre>SELECT * FROM staff<br>WHERE team = &#39;Support&#39; AND salary &gt; 40000 OR tenure_years &gt; 3;</pre><p>Because AND is resolved first, the database interprets it as:</p><blockquote><em>(Support </em><strong><em>and</em></strong><em> salary above 40,000) </em><strong><em>or</em></strong><em> (tenure above 3 years)</em></blockquote><p>So a long-serving person from <em>any</em> team is included. If your goal was different, add parentheses to spell it out:</p><pre>-- Support staff who earn over 40,000 OR have over 3 years of tenure<br>SELECT * FROM staff<br>WHERE team = &#39;Support&#39;<br>  AND (salary &gt; 40000 OR tenure_years &gt; 3);</pre><p>Even when you know the rules by heart, parentheses make the query easier for the next person to read.</p><h3>4. LIKE: Searching Text by Pattern</h3><p>When you don’t know the exact text, LIKE finds values that fit a pattern. It uses two wildcards:</p><p>Wildcard Stands for % Any number of characters, including none _ Exactly one character</p><pre>-- Names beginning with &quot;A&quot;<br>SELECT * FROM staff WHERE first_name LIKE &#39;A%&#39;;</pre><pre>-- Surnames ending in &quot;son&quot;<br>SELECT * FROM staff WHERE last_name LIKE &#39;%son&#39;;</pre><pre>-- Item names containing &quot;phone&quot; anywhere<br>SELECT * FROM catalog WHERE item_name LIKE &#39;%phone%&#39;;</pre><pre>-- Item names starting with &quot;Mega&quot;<br>SELECT * FROM catalog WHERE item_name LIKE &#39;Mega%&#39;;</pre><pre>-- One unknown letter: matches Grey and Gray<br>SELECT * FROM catalog WHERE color LIKE &#39;Gr_y&#39;;</pre><p>Wildcards can be mixed. &#39;_a%&#39; matches anything whose second character is &quot;a&quot;.</p><p><strong>Good to know:</strong></p><ul><li><strong>Case rules depend on the database.</strong> PostgreSQL’s LIKE respects case (use ILIKE to ignore it), whereas MySQL is typically case-insensitive.</li><li><strong>A leading </strong><strong>% is expensive.</strong> Patterns like &#39;%phone%&#39; usually can&#39;t use an index, so they get slow on big tables.</li><li><strong>To match a real </strong><strong>% or </strong><strong>_,</strong> add an ESCAPE character.</li></ul><h3>5. IN: Checking Against a List</h3><p>Instead of stacking up several OR conditions, IN lets you list the acceptable values once.</p><pre>-- The long way<br>SELECT * FROM staff<br>WHERE team = &#39;Support&#39; OR team = &#39;Sales&#39;;</pre><pre>-- The tidy way<br>SELECT * FROM staff<br>WHERE team IN (&#39;Support&#39;, &#39;Sales&#39;);</pre><p>It handles text, numbers and dates alike:</p><pre>SELECT * FROM shipments<br>WHERE state IN (&#39;Packed&#39;, &#39;In Transit&#39;, &#39;Delivered&#39;);</pre><h3>Feeding IN from a Subquery</h3><p>The list doesn’t have to be typed by hand. A subquery can build it:</p><pre>SELECT * FROM staff<br>WHERE branch_id IN (<br>    SELECT branch_id<br>    FROM branches<br>    WHERE city = &#39;Chennai&#39;<br>);</pre><h3>The NOT IN Pitfall</h3><p>If the list or subquery behind a NOT IN contains a single NULL, the whole condition can return zero rows. The safer pattern is NOT EXISTS:</p><pre>SELECT * FROM staff s<br>WHERE NOT EXISTS (<br>    SELECT 1 FROM former_staff f<br>    WHERE f.staff_id = s.staff_id<br>);</pre><p><em>On speed: modern optimizers generally treat </em><em>IN and an equivalent chain of </em><em>ORs the same way, so pick </em><em>IN for clarity rather than performance.</em></p><h3>6. BETWEEN: Filtering by Range</h3><p>BETWEEN keeps values that fall inside a range, and it <strong>includes both ends</strong>.</p><pre>-- Prices from 20 to 60, with 20 and 60 both included<br>SELECT * FROM catalog<br>WHERE price BETWEEN 20 AND 60;</pre><p>That’s the same as writing price &gt;= 20 AND price &lt;= 60. To exclude a range, use NOT BETWEEN.</p><h3>Date Ranges</h3><pre>SELECT * FROM invoices<br>WHERE invoice_date BETWEEN &#39;2025-01-01&#39; AND &#39;2025-06-30&#39;;</pre><blockquote><strong><em>Careful with timestamps.</em></strong><em> If the column also stores a time, </em><em>&#39;2025-06-30&#39; is read as midnight at the start of that day. Anything recorded later on June 30 gets left out. A half-open range avoids the problem:</em></blockquote><pre>WHERE invoice_date &gt;= &#39;2025-01-01&#39; AND invoice_date &lt; &#39;2025-07-01&#39;</pre><h3>A Classic Slip</h3><p>Suppose you want people with <em>more than</em> 3 years of tenure but no more than 8. This does <strong>not</strong> do that, because 3 itself qualifies:</p><pre>SELECT * FROM staff<br>WHERE tenure_years BETWEEN 3 AND 8;</pre><p>Spell out the boundaries instead:</p><pre>SELECT * FROM staff<br>WHERE tenure_years &gt; 3 AND tenure_years &lt;= 8;</pre><h3>Precedence Cheat Sheet</h3><p>Highest priority first:</p><ol><li>Parentheses ()</li><li>*, /, %</li><li>+, -</li><li>Comparison and pattern operators: =, &lt;&gt;, &lt;, &gt;, &lt;=, &gt;=, LIKE, IN, BETWEEN, IS NULL</li><li>NOT</li><li>AND</li><li>OR</li></ol><h3>Five Mistakes Worth Avoiding</h3><ol><li><strong>Combining AND with OR and no parentheses.</strong> Always group.</li><li><strong>Writing </strong><strong>= NULL.</strong> Use IS NULL or IS NOT NULL.</li><li><strong>Treating BETWEEN as exclusive.</strong> It’s inclusive on both sides.</li><li><strong>Letting integer division drop decimals.</strong> Cast or multiply by 1.0.</li><li><strong>Starting LIKE patterns with </strong><strong>% on huge tables.</strong> Consider full-text search instead.</li></ol><h3>Quick Recap</h3><ul><li>Operators let SQL calculate, compare and filter.</li><li>The six groups: arithmetic, comparison, logical, LIKE, IN and BETWEEN.</li><li>Precedence changes results, so use parentheses freely.</li><li>BETWEEN includes both boundary values.</li><li>Handle NULL on purpose, never by accident.</li></ul><h3>Mini Glossary</h3><p>Term Meaning Arithmetic operators Do math on numbers (+ - * / %) Comparison operators Compare two values and return TRUE, FALSE or UNKNOWN Logical operators Join conditions (AND, OR, NOT) LIKE Matches text against a wildcard pattern IN Tests a value against a list or subquery BETWEEN Tests whether a value sits within an inclusive range % Wildcard for zero or more characters _ Wildcard for exactly one character NULL A missing or unknown value Precedence The order in which operators are evaluated</p><h3>Frequently Asked Questions</h3><p><strong>Can AND, OR and NOT appear in the same query?</strong> Yes. Add parentheses so the order is exactly what you intend.</p><p><strong>What if I leave out parentheses?</strong> SQL falls back on its default order: NOT, then AND, then OR. That may differ from what you meant.</p><p><strong>Is BETWEEN inclusive?</strong> Yes, for numbers and dates. Both the start and end values are returned.</p><p><strong>How should I test for NULL?</strong> Use IS NULL or IS NOT NULL. Operators like = and &lt;&gt; won&#39;t work.</p><p><strong>Can I use </strong><strong>% and </strong><strong>_ together?</strong> Yes. LIKE &#39;A_%&#39; finds values that start with &quot;A&quot; and are at least two characters long.</p><p><strong>Does IN work with text and subqueries?</strong> Yes. It accepts numbers, text, dates and subquery results.</p><p><strong>What’s the number one operator mistake?</strong> Forgetting precedence when AND and OR share a condition, with NULL handling a close second.</p><h3>Wrapping Up</h3><p>Once operators click, your queries get shorter, clearer and far more reliable. Try each group on a small practice table, run conditions one at a time before combining them, and check the row count each time. If the number looks off, an operator is usually the reason.</p><p><em>Written by Vengatesh A</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d44b8ea438e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Kafka: A Complete Guide to Streaming Concepts]]></title>
            <link>https://medium.com/@a.vengatesh123/understanding-kafka-a-complete-guide-to-streaming-concepts-3e1c562fa369?source=rss-d30379eaaadc------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e1c562fa369</guid>
            <category><![CDATA[etl-pipeline]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[streaming]]></category>
            <dc:creator><![CDATA[VENGATESH A]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 14:57:16 GMT</pubDate>
            <atom:updated>2026-07-14T14:57:16.407Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E07soSZ8X-Yd5w_B9rwJdg.png" /></figure><p><em>By Vengatesh A · Data Engineer · 14 min read</em></p><p>Every large company today — banks, ride-hailing apps, streaming services — has some version of the same problem: data is being generated continuously, from many sources, and needs to reach many destinations, in real time, without loss. Apache Kafka became the de facto answer to this problem, and understanding it deeply means understanding a handful of core ideas that show up in almost every streaming system, not just Kafka.</p><p>This guide walks through those ideas one at a time — partitions, offsets, replication, consumer groups, schema registries, delivery guarantees, windowing, watermarking, and backpressure — with working code and a real pipeline example tying it all together at the end.</p><p><strong>In this guide:</strong></p><ol><li>Why Kafka Exists</li><li>Topics and Partitions</li><li>Offsets</li><li>Replication</li><li>Consumer Groups</li><li>Schema Registry</li><li>Delivery Semantics</li><li>Windowing</li><li>Watermarking</li><li>Backpressure</li><li>Putting It All Together: A Banking Pipeline</li></ol><h3>01 · Why Kafka Exists</h3><p>Before Kafka, a common pattern was to connect systems directly to each other. If Service A needed to notify Service B, C, and D whenever something happened, it called each of them directly. This works fine with two or three services. It breaks down completely once you have dozens of them, because every new service means new point-to-point connections, and every failure in one connection risks cascading into others.</p><p>Kafka solves this by sitting in the middle as a durable, append-only log. Producers write events into Kafka without knowing or caring who reads them. Consumers read events without knowing or caring who wrote them. This is what people mean by “decoupling” — the two sides no longer need to know about each other, only about the topic they’re publishing to or subscribing from.</p><pre>BEFORE (tight coupling)              AFTER (Kafka in the middle)</pre><pre> Service A ──▶ Service B                Service A ─┐<br>     │    ╲                                        │<br>     │     ╲──▶ Service C                Service B ─┼──▶  KAFKA  ──▶ Consumer 1<br>     └──────────▶ Service D                         │              ──▶ Consumer 2<br>                                        Service C ───┘              ──▶ Consumer 3</pre><pre>   N services = N² possible                Producers and consumers never<br>   connections to maintain                 talk to each other directly</pre><p>What makes Kafka particularly suited to this role is that it’s not just a message queue — it’s a distributed, replicated, ordered log that can sustain very high throughput while also being durable enough that a broker crashing doesn’t mean your data is gone. The rest of this guide is really an explanation of how that’s achieved.</p><h3>02 · Topics and Partitions</h3><p>A <strong>topic</strong> is simply a named category of events — orders, payments, user-clicks. But a topic on its own wouldn&#39;t scale; a single, unbroken log can only be written to and read by so many processes at once before it becomes a bottleneck. So Kafka splits every topic into <strong>partitions</strong> — independent, ordered logs that together make up the topic.</p><pre>Topic: &quot;bank-transactions&quot;  (split into 3 partitions)</pre><pre>Partition 0:  [txn1] [txn4] [txn7] [txn10] ...<br>Partition 1:  [txn2] [txn5] [txn8] [txn11] ...<br>Partition 2:  [txn3] [txn6] [txn9] [txn12] ...</pre><pre>Ordering is guaranteed WITHIN a partition,<br>never guaranteed ACROSS partitions.</pre><p>This distinction matters more than it sounds. Kafka only promises that messages within a single partition arrive in the order they were written. It makes no such promise across partitions — messages in partition 0 and partition 1 can be read in any relative order. This is a deliberate trade-off: strict global ordering would mean giving up parallelism, so Kafka instead lets you choose <em>what</em> needs to stay ordered by controlling how messages are assigned to partitions.</p><h3>Choosing a partition: keyed vs unkeyed writes</h3><p>When a producer sends a message, it can optionally attach a <strong>key</strong>. If a key is present, Kafka hashes it and uses that hash to consistently route every message with that key to the same partition. If no key is given, messages are spread round-robin across partitions for even load distribution — but with no ordering guarantee between messages.</p><pre>from kafka import KafkaProducer<br>import json</pre><pre>producer = KafkaProducer(<br>    bootstrap_servers=&#39;localhost:9092&#39;,<br>    value_serializer=lambda v: json.dumps(v).encode(&#39;utf-8&#39;),<br>    key_serializer=lambda k: k.encode(&#39;utf-8&#39;) if k else None,<br>    acks=&#39;all&#39;,<br>    retries=3<br>)</pre><pre>transaction = {<br>    &quot;account_id&quot;: &quot;ACC10234&quot;,<br>    &quot;amount&quot;: 4500.00,<br>    &quot;type&quot;: &quot;DEBIT&quot;,<br>    &quot;timestamp&quot;: &quot;2026-07-14T10:30:00&quot;<br>}</pre><pre># Using account_id as the key ensures every transaction<br># for this account lands in the same partition, in order.<br>producer.send(&#39;bank-transactions&#39;, key=&quot;ACC10234&quot;, value=transaction)<br>producer.flush()</pre><p>This single decision — what to use as a key — is one of the most consequential design choices in any Kafka-based system. Get it wrong, and you either lose ordering where you need it, or you concentrate all traffic onto one partition and lose the parallelism Kafka was supposed to give you.</p><h3>Custom partitioning logic</h3><p>Sometimes the default hash-based routing isn’t enough, and you need business rules to decide where a message goes:</p><pre>from kafka.partitioner import Partitioner</pre><pre>class VIPAwarePartitioner(Partitioner):<br>    # Route VIP customer transactions to a dedicated partition<br>    # so a downstream consumer can process them with priority.<br>    def partition(self, key, all_partitions, available):<br>        if key and key.decode().startswith(&quot;VIP&quot;):<br>            return 0<br>        return hash(key) % len(all_partitions)</pre><blockquote><strong><em>Worked example:</em></strong><em> In a banking pipeline, keying by </em><em>account_id guarantees that every transaction for a given account is processed in the order it happened — which matters enormously, because a balance calculation done out of order can produce an incorrect result. Without a key, two transactions for the same account could land in different partitions and be processed by two different consumers at roughly the same time, creating a race condition on the account balance.</em></blockquote><h3>How many partitions should a topic have?</h3><p>This is usually decided by two constraints working together: expected throughput, and the number of consumers you want reading in parallel. A rough starting formula is:</p><pre>partitions ≈ expected_throughput / per_partition_throughput</pre><pre># Example: need to sustain 100 MB/s, and one partition can handle ~10 MB/s<br># =&gt; at least 10 partitions</pre><pre># Also remember: within a single consumer group, the number of partitions<br># is the hard ceiling on how many consumers can work in parallel.<br># 6 partitions = at most 6 consumers actively doing work at once.</pre><p>It’s worth erring slightly on the side of more partitions than you currently need, because increasing partition count later is possible but re-shuffles existing key-to-partition mappings — which can silently break ordering guarantees your consumers were depending on.</p><h3>03 · Offsets</h3><p>Every message inside a partition gets a sequential, immutable position number called an <strong>offset</strong> — conceptually identical to an array index. Offsets are how a consumer keeps track of what it has already read, and how it resumes correctly after a restart or crash.</p><pre>Partition 0:   msg_A    msg_B    msg_C    msg_D    msg_E<br>offset:          0        1        2        3        4<br>                                     ▲<br>                            consumer&#39;s committed<br>                            offset = 2 (last processed)</pre><pre>                     On restart → resumes from offset 3,<br>                     not from the beginning, not from the latest.</pre><p>The critical design decision here is <em>when</em> a consumer commits its offset relative to when it actually finishes processing a message. Committing too early — before processing completes — risks losing messages if a crash happens in between. Committing manually, only after processing succeeds, is slower but far safer:</p><pre>from kafka import KafkaConsumer, TopicPartition</pre><pre>consumer = KafkaConsumer(<br>    bootstrap_servers=&#39;localhost:9092&#39;,<br>    group_id=&#39;fraud-detection-group&#39;,<br>    enable_auto_commit=False<br>)</pre><pre>tp = TopicPartition(&#39;bank-transactions&#39;, 0)<br>consumer.assign([tp])</pre><pre>for msg in consumer:<br>    process(msg.value)<br>    # Commit only AFTER processing succeeds.<br>    # If we crash before this line, the message is reprocessed on restart<br>    # rather than silently lost.<br>    consumer.commit({tp: OffsetAndMetadata(msg.offset + 1, None)})</pre><blockquote><strong><em>Common mistake:</em></strong><em> With auto-commit enabled, Kafka periodically commits offsets in the background regardless of whether your application has actually finished processing those messages. If the application crashes between the commit and the completion of processing, that message is gone for good — the consumer will resume from a point past it. For anything where losing a message has real consequences, such as payments, manual commits after successful processing are the safer default.</em></blockquote><h3>04 · Replication</h3><p>A single copy of any partition is a single point of failure — if the broker holding it goes down, that data is temporarily or permanently unavailable. Kafka addresses this with <strong>replication</strong>: each partition is copied across multiple brokers, with one designated as the leader and the rest as followers that continuously sync from it.</p><pre>Partition 0  (replication factor = 3)</pre><pre>  Broker 1  →  [LEADER]     (all reads and writes go here)<br>  Broker 2  →  [Replica]    (follower, stays in sync with leader)<br>  Broker 3  →  [Replica]    (follower, stays in sync with leader)</pre><pre>  If Broker 1 fails:<br>  Broker 2  →  [NEW LEADER]  (elected automatically)<br>  Broker 3  →  [Replica]</pre><p>All reads and writes for a partition go through its current leader; followers exist purely to take over if the leader fails. This failover is automatic and typically completes within seconds, which is what allows Kafka clusters to survive individual machine failures without any observable downtime to producers or consumers.</p><pre># Creating a topic with replication (CLI)<br>kafka-topics.sh --create \<br>  --topic bank-transactions \<br>  --partitions 6 \<br>  --replication-factor 3 \<br>  --bootstrap-server localhost:9092</pre><pre># min.insync.replicas=2 means at least 2 replicas (including the leader)<br># must acknowledge a write before it&#39;s considered successful —<br># protecting against data loss even if one broker goes down immediately after.</pre><blockquote><strong><em>Worked example:</em></strong><em> A banking system typically runs with a replication factor of 3. If the broker acting as leader for a partition crashes mid-transaction-day, one of the two replicas is promoted to leader automatically, and processing continues with no data loss. Without replication, that single broker failure would take down transaction processing entirely until it was manually recovered.</em></blockquote><h3>05 · Consumer Groups</h3><p>A <strong>consumer group</strong> is a set of consumers that cooperate to read a topic, with Kafka automatically dividing the topic’s partitions among them so that each partition is read by exactly one consumer in the group at a time. This is how Kafka achieves parallel processing without duplicated work.</p><pre>Topic: bank-transactions (3 partitions)<br>Consumer Group: &quot;fraud-detection&quot;</pre><pre>  Partition 0  ──▶  Consumer A<br>  Partition 1  ──▶  Consumer B<br>  Partition 2  ──▶  Consumer C</pre><pre>If Consumer B fails, Kafka REBALANCES automatically:</pre><pre>  Partition 0  ──▶  Consumer A<br>  Partition 1  ──▶  Consumer A   (picked up B&#39;s partition)<br>  Partition 2  ──▶  Consumer C</pre><pre>from kafka import KafkaConsumer</pre><pre># Running this same code in 3 separate processes, all with the same<br># group_id, causes Kafka to automatically split the 3 partitions<br># between them — no manual coordination needed.<br>consumer = KafkaConsumer(<br>    &#39;bank-transactions&#39;,<br>    bootstrap_servers=&#39;localhost:9092&#39;,<br>    group_id=&#39;fraud-detection-group&#39;,<br>    auto_offset_reset=&#39;earliest&#39;<br>)</pre><pre>for msg in consumer:<br>    print(f&quot;Partition {msg.partition} | Offset {msg.offset} | {msg.value}&quot;)<br>    run_fraud_check(msg.value)</pre><p>Scenario Result 3 partitions, 3 consumers in one group Perfect 1:1 mapping — full parallelism 3 partitions, 5 consumers in one group 2 consumers sit idle — wasted capacity 3 partitions, 1 consumer That consumer reads all 3 sequentially — no parallelism 2 separate consumer groups on the same topic Each group gets its own independent full read of the data</p><p>That last row is worth dwelling on: consumer groups are the mechanism by which the same event stream can be consumed independently by multiple applications — say, a fraud-detection service and an analytics pipeline both reading the same transaction topic — without either one affecting the other’s progress.</p><h3>06 · Schema Registry</h3><p>Kafka itself doesn’t care what’s inside a message — to Kafka, every message is just bytes. But producers and consumers absolutely need to agree on the structure of those bytes. A <strong>Schema Registry</strong> is a separate service that stores and versions the schemas used by topics, and enforces compatibility rules so that a schema change on the producer side doesn’t silently break every consumer.</p><pre>Producer                Schema Registry              Consumer<br>      │                          │                          │<br>      │──register schema────────▶│                          │<br>      │◀─────schema_id: 42───────│                          │<br>      │                          │                          │<br>      │──send(data + schema_id)──┼─────────────────────────▶│<br>      │                          │◀──fetch schema by id 42───│<br>      │                          │────schema definition─────▶│</pre><pre>{<br>  &quot;type&quot;: &quot;record&quot;,<br>  &quot;name&quot;: &quot;Transaction&quot;,<br>  &quot;fields&quot;: [<br>    {&quot;name&quot;: &quot;account_id&quot;, &quot;type&quot;: &quot;string&quot;},<br>    {&quot;name&quot;: &quot;amount&quot;, &quot;type&quot;: &quot;double&quot;},<br>    {&quot;name&quot;: &quot;type&quot;, &quot;type&quot;: &quot;string&quot;},<br>    // A field added later needs a default value to remain<br>    // backward-compatible with consumers using the older schema.<br>    {&quot;name&quot;: &quot;currency&quot;, &quot;type&quot;: &quot;string&quot;, &quot;default&quot;: &quot;INR&quot;}<br>  ]<br>}</pre><blockquote><strong><em>Why it matters:</em></strong><em> Without a schema registry, a producer team can add, remove, or rename a field, and every downstream consumer that assumed the old structure will fail — often in production, and often without a clear error message. The registry checks new schema versions for compatibility (backward, forward, or full) before allowing them into production, catching breaking changes at registration time instead of at 3 a.m. in an on-call alert.</em></blockquote><h3>07 · Delivery Semantics</h3><p>When we say a system delivers messages “exactly once” or “at least once,” we’re describing a guarantee about what happens under failure — network blips, consumer crashes, broker restarts. There are three possible guarantees, and each is a genuine trade-off rather than a strictly better or worse option.</p><p>Semantic Guarantee Typical use <strong>At-most-once</strong> A message might be lost, but is never processed twice Metrics, logs — occasional loss is tolerable <strong>At-least-once</strong> A message is never lost, but might be processed twice The common default for most pipelines <strong>Exactly-once</strong> Never lost, never duplicated Payments, banking transactions</p><h3>At-least-once, the common default</h3><pre>for msg in consumer:<br>    process(msg.value)      # if a crash happens right here...<br>    consumer.commit()       # ...this line never executes, and the message<br>                             # is reprocessed after restart<br>    # Result: duplicate processing is possible, so downstream<br>    # logic needs to tolerate or de-duplicate it.</pre><h3>Exactly-once, using Kafka’s transactional API</h3><pre>from kafka import KafkaProducer</pre><pre>producer = KafkaProducer(<br>    bootstrap_servers=&#39;localhost:9092&#39;,<br>    transactional_id=&#39;txn-producer-1&#39;,<br>    enable_idempotence=True<br>)<br>producer.init_transactions()</pre><pre>try:<br>    producer.begin_transaction()<br>    producer.send(&#39;bank-transactions&#39;, key=&quot;ACC101&quot;, value=debit_event)<br>    producer.send(&#39;audit-log&#39;, key=&quot;ACC101&quot;, value=audit_event)<br>    # Both writes succeed together, or both roll back — atomically.<br>    producer.commit_transaction()<br>except Exception:<br>    producer.abort_transaction()</pre><h3>A more practical alternative: idempotent consumers</h3><p>In real systems, exactly-once is often achieved not purely through Kafka’s transactional guarantees, but by designing consumer logic to be idempotent — safe to run twice with the same result:</p><pre>def process_transaction(txn):<br>    if db.exists(&quot;processed_txns&quot;, txn[&quot;transaction_id&quot;]):<br>        print(&quot;Already processed, skipping&quot;)<br>        return<br>    db.apply_debit(txn)<br>    db.insert(&quot;processed_txns&quot;, txn[&quot;transaction_id&quot;])<br>    # Even if this message is delivered twice, the existence check<br>    # prevents the debit from being applied more than once.</pre><blockquote><strong><em>Worked example:</em></strong><em> In banking, a ₹5,000 debit must never be applied twice — a customer being double-charged is a serious failure, so exactly-once semantics are non-negotiable. In clickstream analytics, on the other hand, losing or double-counting an occasional click barely affects the aggregate numbers, so at-least-once or even at-most-once is an acceptable and much cheaper trade-off.</em></blockquote><h3>08 · Windowing</h3><p>Streaming data has no natural end — it just keeps arriving. To compute anything meaningful over it (a sum, an average, a count), you need to define a boundary: “the last 5 minutes,” for instance. This boundary is called a <strong>window</strong>, and there are three common shapes.</p><pre>TUMBLING WINDOW  (fixed-size, non-overlapping)<br>|--- 0-5 min ---|--- 5-10 min ---|--- 10-15 min ---|</pre><pre>SLIDING WINDOW  (fixed-size, overlapping)<br>|--- 0-5 min ---|<br>       |--- 1-6 min ---|<br>              |--- 2-7 min ---|</pre><pre>SESSION WINDOW  (dynamic, defined by inactivity gaps)<br>[click][click][click]     &lt;30 min gap&gt;     [click][click]<br>└──────── session 1 ────┘                  └── session 2 ──┘</pre><p>Tumbling windows are the simplest — every event belongs to exactly one window, with no overlap. Sliding windows let you compute a rolling metric (like a moving average) that updates more frequently than the window size itself. Session windows don’t use fixed time boundaries at all; instead, a window closes when there’s been a gap of inactivity longer than some threshold, which suits use cases like tracking a single user’s browsing session.</p><pre># PySpark Structured Streaming — tumbling window example<br>from pyspark.sql.functions import window, col, sum</pre><pre>fraud_agg = transactions_stream \<br>    .groupBy(<br>        window(col(&quot;timestamp&quot;), &quot;5 minutes&quot;),<br>        col(&quot;account_id&quot;)<br>    ) \<br>    .agg(sum(&quot;amount&quot;).alias(&quot;total_5min&quot;)) \<br>    .filter(col(&quot;total_5min&quot;) &gt; 100000)</pre><pre>query = fraud_agg.writeStream \<br>    .outputMode(&quot;update&quot;) \<br>    .format(&quot;console&quot;) \<br>    .start()</pre><blockquote><strong><em>Worked example:</em></strong><em> A fraud rule like “flag any account that transacts more than ₹1,00,000 within a 5-minute span” is a natural fit for a tumbling window. Continuous monitoring for suspicious card-swipe patterns, where you want an up-to-date view every minute rather than waiting for a clean 5-minute boundary, is better served by a sliding window.</em></blockquote><h3>09 · Watermarking</h3><p>Windowing assumes events arrive in roughly the order they happened, but real networks don’t guarantee that — a mobile connection can delay an event by seconds or minutes. A <strong>watermark</strong> is the mechanism a streaming system uses to decide how long it will wait for late data before considering a window “closed” and finalizing its result.</p><pre>Event time:      10:00    10:01    10:02    10:03    10:04<br>Arrival order:     ✓        ✓     (late →)    ✓        ✓<br>                                  10:01 data actually arrives at 10:04!</pre><pre>Watermark = latest event time seen so far − allowed lateness<br>If an event&#39;s timestamp falls before the watermark, it&#39;s dropped —<br>the window it belonged to has already closed and finalized.</pre><pre># PySpark — combining a watermark with a window<br>fraud_agg = transactions_stream \<br>    .withWatermark(&quot;timestamp&quot;, &quot;2 minutes&quot;) \<br>    .groupBy(<br>        window(col(&quot;timestamp&quot;), &quot;5 minutes&quot;),<br>        col(&quot;account_id&quot;)<br>    ) \<br>    .agg(sum(&quot;amount&quot;).alias(&quot;total_5min&quot;))</pre><pre># Any event arriving more than 2 minutes after the window&#39;s<br># end time is considered too late and is dropped.</pre><blockquote><strong><em>Why it matters:</em></strong><em> Without a watermark, a streaming system has no principled way to decide when a window is “done” — it would need to wait indefinitely for the possibility of late data, which means holding state in memory forever and never actually emitting a final result. A watermark trades a small amount of correctness (rare, very late events get dropped) for the ability to finalize windows and free up memory in a bounded amount of time.</em></blockquote><h3>10 · Backpressure</h3><p>Producers and consumers rarely run at exactly the same speed. When a producer generates events faster than a consumer can process them, the excess has to go somewhere — and without a control mechanism, it ends up filling buffers until the system runs out of memory and crashes. <strong>Backpressure</strong> is the general term for mechanisms that slow down or throttle the faster side to match the slower one.</p><pre>Producer rate:   [fast] 1000 messages/sec<br>Consumer rate:   [slow]  200 messages/sec</pre><pre>Without backpressure → buffers grow unbounded → out-of-memory crash<br>With backpressure    → the pipeline throttles itself to ~200 msg/sec</pre><pre># Spark Structured Streaming — capping messages per micro-batch<br>df = spark.readStream \<br>    .format(&quot;kafka&quot;) \<br>    .option(&quot;kafka.bootstrap.servers&quot;, &quot;localhost:9092&quot;) \<br>    .option(&quot;subscribe&quot;, &quot;bank-transactions&quot;) \<br>    .option(&quot;maxOffsetsPerTrigger&quot;, 1000) \<br>    .load()</pre><pre># This stops Spark from pulling millions of messages into a single<br># micro-batch and overwhelming executor memory during traffic spikes.</pre><p>Backpressure is easy to overlook in a demo or a small-scale test, because everything fits comfortably in memory. It becomes essential the moment real traffic spikes hit — a sudden burst of transactions, a viral event, an upstream retry storm — and it’s usually the difference between a pipeline that degrades gracefully and one that crashes outright.</p><h3>11 · Putting It All Together: A Banking Pipeline</h3><p>Every concept above solves one specific problem in isolation. In a real system, they all operate together, each addressing a different failure mode. Here’s how they combine in a typical banking data pipeline, moving raw transaction events from source through to business-ready metrics.</p><pre>┌───────────────┐<br>│  Transaction  │   Producer sends each event with key = account_id<br>│   Generator   │   (guarantees per-account ordering)<br>└───────┬───────┘<br>        │<br>        ▼<br>┌──────────────────────────────────────────┐<br>│  Kafka Topic: bank-transactions           │<br>│  • 6 partitions — parallelism             │<br>│  • replication factor 3 — fault tolerance │<br>│  • Schema enforced via Schema Registry    │<br>└───────┬────────────────────────────────────┘<br>        │   Consumer Group: &quot;spark-ingestion&quot;<br>        ▼<br>┌──────────────────────────────────────────┐<br>│  Spark Structured Streaming               │<br>│  • withWatermark(&quot;timestamp&quot;, &quot;2 min&quot;)    │<br>│  • 5-minute window aggregations           │<br>│  • maxOffsetsPerTrigger — backpressure    │<br>└───────┬────────────────────────────────────┘<br>        │<br>        ▼<br>┌───────────┐   ┌───────────┐   ┌───────────┐   ┌───────────┐<br>│    Raw    │──▶│  Bronze   │──▶│  Silver   │──▶│   Gold    │<br>│  (as-is)  │   │(cleaned)  │   │(validated)│   │ (business │<br>│           │   │           │   │           │   │  metrics) │<br>└───────────┘   └───────────┘   └───────────┘   └───────────┘<br>                                                        │<br>                                                        ▼<br>                                                  PostgreSQL</pre><p>Mapped against the concepts covered in this guide, this single pipeline uses nearly all of them at once:</p><ul><li><strong>Partitioning by account_id</strong> keeps every account’s transaction history in strict order.</li><li><strong>Manually committed offsets</strong>, tied to successful checkpoint writes, ensure no transaction is silently dropped on a consumer restart.</li><li><strong>A replication factor of 3</strong> means the loss of any single broker doesn’t interrupt transaction processing.</li><li><strong>A consumer group</strong> of Spark executors reads partitions in parallel, scaling ingestion throughput with the cluster size.</li><li><strong>A schema registry</strong> protects the bronze layer from being broken by an unannounced schema change upstream.</li><li><strong>Idempotent writes keyed on transaction ID</strong> deliver an effectively exactly-once guarantee into PostgreSQL, even though the underlying delivery is at-least-once.</li><li><strong>Windowing and watermarking</strong> together produce the gold-layer hourly and daily aggregates, while tolerating a bounded amount of network lateness.</li><li><strong>Backpressure controls</strong> on the Spark read keep the pipeline stable during transaction volume spikes rather than letting it fall over.</li></ul><p>None of these mechanisms exists for its own sake — each is a direct answer to something that goes wrong in a naive version of this pipeline. Understanding Kafka deeply isn’t really about memorizing its API; it’s about recognizing which of these failure modes a given design decision is protecting against, and knowing which trade-off is right for the data you’re actually moving.</p><p><em>Written by Vengatesh A</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e1c562fa369" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a Churn Prediction Model on 594K Customers — Here’s What Happened]]></title>
            <link>https://medium.com/@a.vengatesh123/i-built-a-churn-prediction-model-on-594k-customers-heres-what-happened-920b92248b65?source=rss-d30379eaaadc------2</link>
            <guid isPermaLink="false">https://medium.com/p/920b92248b65</guid>
            <category><![CDATA[machine-learning-projects]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[customer-churn-prediction]]></category>
            <dc:creator><![CDATA[VENGATESH A]]></dc:creator>
            <pubDate>Mon, 22 Jun 2026 15:50:35 GMT</pubDate>
            <atom:updated>2026-06-22T15:50:35.942Z</atom:updated>
            <content:encoded><![CDATA[<p>So I picked up this Kaggle Playground competition where the goal was simple: predict whether a telecom customer is going to churn or not. Sounds easy on paper, but with ~594,000 rows and 21 messy columns of demographics, services, and billing info, there was enough here to actually learn something.</p><p>Here’s the full notebook if you want to follow along or just steal the code: 👉 <a href="https://www.kaggle.com/code/vengateshvengat/customer-churn-prediction"><strong>Customer Churn Prediction — Kaggle Notebook</strong></a></p><p>Let me just walk you through what I actually did, step by step, no fluff.</p><h3>The data</h3><p>21 columns — gender, SeniorCitizen, Partner, Dependents, tenure, the usual telecom stuff (PhoneService, InternetService, OnlineSecurity, StreamingTV…), billing details (MonthlyCharges, TotalCharges), and the target — Churn (Yes/No).</p><p>Most of it is categorical text. Which means before any model touches this, I had to clean it up.</p><p>Here’s roughly how the whole thing flows from raw CSV to final submission:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Rei1gSBhDAQhO1iywP1tw.png" /></figure><h3>Step 1 — Fix the target</h3><p>Churn comes in as &quot;Yes&quot;/&quot;No&quot; text. First thing — map it to 1/0:</p><pre>train[&#39;Churn&#39;] = train[&#39;Churn&#39;].map({&#39;Yes&#39;: 1, &#39;No&#39;: 0})</pre><p>Boring but necessary. No model trains on strings.</p><h3>Step 2 — Encode the categorical mess</h3><p>A bunch of columns are strings — Contract, PaymentMethod, InternetService, all the Yes/No/”No internet service” columns. I went with Ordinal Encoding instead of one-hot:</p><pre>from sklearn.preprocessing import OrdinalEncoder</pre><pre>cat_cols = train.select_dtypes(include=[&#39;object&#39;]).columns.drop([&#39;Churn&#39;], errors=&#39;ignore&#39;)</pre><pre>encoder = OrdinalEncoder(handle_unknown=&#39;use_encoded_value&#39;, unknown_value=-1)<br>train[cat_cols] = encoder.fit_transform(train[cat_cols])<br>test[cat_cols] = encoder.transform(test[cat_cols])</pre><p>Why not one-hot? With 594K rows, one-hot would just bloat the feature space for no real gain — LightGBM splits on integer-encoded categories just fine on its own. Also threw in unknown_value=-1 so the pipeline doesn&#39;t crash if test set has some category train never saw.</p><h3>Quick look at the imbalance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*iHNoRXKfQXEUibxNQotZqA.png" /></figure><p>Before training, I checked how skewed the churn rate actually is:</p><p>About 78% stayed, 22% churned. Not insane, but enough that accuracy as a metric would be useless — a model that always predicts “No churn” would already look ~78% “accurate” while being completely dumb. That’s exactly why ROC AUC was the metric here, not accuracy.</p><h3>Step 3 — Split it properly</h3><pre>from sklearn.model_selection import train_test_split</pre><pre>X_train, X_val, y_train, y_val = train_test_split(<br>    X, y, test_size=0.2, stratify=y, random_state=42<br>)</pre><p>stratify=y keeps the churn ratio the same in both train and validation — otherwise random splitting on imbalanced data can quietly mess up your validation numbers.</p><h3>Step 4 — Train LightGBM</h3><p>Went with LightGBM, no overthinking:</p><pre>import lightgbm as lgb</pre><pre>model = lgb.LGBMClassifier(<br>    objective=&#39;binary&#39;,<br>    metric=&#39;auc&#39;,<br>    random_state=42,<br>    n_estimators=500,<br>    learning_rate=0.05<br>)</pre><pre>model.fit(<br>    X_train, y_train,<br>    eval_set=[(X_val, y_val)],<br>    callbacks=[lgb.early_stopping(stopping_rounds=50, verbose=True)]<br>)</pre><p>Trained on 475,355 rows, 19 features. Low learning rate + early stopping so it doesn’t overfit by going crazy with 500 trees.</p><h3>The result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*c_QQxmsjppkj_9qDE4WYGg.png" /></figure><p><strong>0.916 validation ROC AUC.</strong> For a pretty basic pipeline with zero fancy feature engineering, I’ll take it. Means the model correctly ranks a churner above a non-churner about 91.6% of the time.</p><h3>Step 5 — Submission</h3><pre>test_preds = model.predict_proba(X_test)[:, 1]</pre><pre>submission = pd.DataFrame({<br>    &#39;id&#39;: test[&#39;id&#39;],<br>    &#39;Churn&#39;: test_preds<br>})</pre><pre>submission.to_csv(&#39;submission.csv&#39;, index=False)</pre><p>Used predict_proba instead of predict since it&#39;s an AUC competition — probabilities matter more than hard labels here.</p><h3>What I’d try next</h3><ul><li>Feature engineering — something like TotalCharges / tenure to get average monthly spend</li><li>Double-check TotalCharges for blank values on brand-new customers (tenure = 0)</li><li>Maybe stack LightGBM with CatBoost/XGBoost</li><li>Proper 5-fold CV instead of one train/val split</li><li>Optuna for tuning instead of guessing hyperparameters</li></ul><p>That’s it — simple pipeline, decent score, lot of room to push it further. Full code is on Kaggle if you want to fork it and try your own ideas: 👉 <a href="https://www.kaggle.com/code/vengateshvengat/customer-churn-prediction"><strong>https://www.kaggle.com/code/vengateshvengat/customer-churn-prediction</strong></a></p><p>— <strong>Vengatesh A</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=920b92248b65" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>