<?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 Tanvi Moghe on Medium]]></title>
        <description><![CDATA[Stories by Tanvi Moghe on Medium]]></description>
        <link>https://medium.com/@tanvimoghe1?source=rss-1b7fb701ebc4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*E8ISYgQ9tiXamEa7</url>
            <title>Stories by Tanvi Moghe on Medium</title>
            <link>https://medium.com/@tanvimoghe1?source=rss-1b7fb701ebc4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:04:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanvimoghe1/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[How I Handle Imbalanced Data in Real Life (A Practical Guide)]]></title>
            <link>https://medium.com/@tanvimoghe1/how-i-handle-imbalanced-data-in-real-life-a-practical-guide-e92dd680c0d6?source=rss-1b7fb701ebc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e92dd680c0d6</guid>
            <category><![CDATA[handling-imbalanced-data]]></category>
            <dc:creator><![CDATA[Tanvi Moghe]]></dc:creator>
            <pubDate>Tue, 25 Nov 2025 08:58:01 GMT</pubDate>
            <atom:updated>2025-11-25T09:16:06.255Z</atom:updated>
            <content:encoded><![CDATA[<p>When I started building a <strong>Logistic Regression model</strong> for predicting whether customers would <em>accept</em> a credit card offer, I ran into a challenge that almost every real-world dataset suffers from — <strong>imbalanced data</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*juffvdzmBX3wqrrvIeBcng.png" /><figcaption>Canva</figcaption></figure><ul><li>In my dataset:</li><li><strong>Non-Accepted (0)</strong> → 16,977 rows</li><li><strong>Accepted (1)</strong> → 1,023 rows</li></ul><p>This means only <strong>6%</strong> of customers actually accepted the offer.</p><h3>The first model I built gave me:</h3><ul><li><strong>Accuracy:</strong> ~58%</li><li><strong>Precision:</strong> ~9%</li><li><strong>Recall:</strong> ~67%</li></ul><p>Clearly — accuracy was useless, and the model was heavily biased towards predicting “Not Accepted” for almost everyone.</p><p>That’s when I learned the MOST important skill in applied machine learning:<br> 👉 <strong>Handling imbalanced data intelligently.</strong></p><p>In this blog, I’ll share exactly how I handled imbalance in my <strong>credit card offer acceptance project</strong>, step-by-step, with the practical mistakes I made and how I fixed them.</p><h3>📌 Why Imbalanced Data Matters in Offer Acceptance Prediction</h3><p>Imbalanced data tricks the model into learning:</p><blockquote><em>“Most customers never accept the offer — so I will always predict 0.”</em></blockquote><p>This increases <strong>accuracy</strong> but destroys <strong>precision</strong> and <strong>recall</strong> for the important class:<br> <strong>accepted = 1</strong></p><p>And that’s the class the business actually cares about:</p><ul><li>Which customers are likely to accept the offer?</li><li>Who should receive follow-up calls?</li><li>Where should marketing budget go?</li></ul><p>So fixing imbalance isn’t just ML — it’s business strategy.</p><h3>🧠 Step 1: Detecting the Imbalance Quickly</h3><p>This was my first step:</p><pre>df[&#39;Offer Accepted&#39;].value_counts()</pre><p>Output:</p><pre>0    16977<br>1     1023</pre><p>This confirmed it: severe imbalance.</p><p>Anything under <strong>15%</strong> minority class → requires balancing.<br> My dataset had <strong>just 6%</strong> → definitely needs balancing.</p><h3>🧹 Step 2: Build a Baseline Logistic Regression (Before Fixing Anything)</h3><p>Before balancing, I trained a simple logistic regression model:</p><pre>from sklearn.linear_model import LogisticRegression<br>lr = LogisticRegression()<br>lr.fit(X_train_scaled, y_train)</pre><p>The results were typical:</p><ul><li>High accuracy</li><li>Low precision</li><li>Decent recall</li></ul><p>This baseline helped me understand the dataset weaknesses before applying balancing.</p><h3>⚖️ Step 3: Add Class Weights (My First Fix)</h3><p>Instead of duplicating or synthesizing data, I changed the importance of classes:</p><pre>lr = LogisticRegression(class_weight=&#39;balanced&#39;)</pre><p>This tells the model:</p><blockquote><em>“Pay more attention to customers who accepted the offer.”</em></blockquote><p>This alone improved:</p><ul><li>Recall</li><li>ROC AUC</li><li>F1 score</li></ul><p>And the model didn’t overfit.</p><h3>🧬 Step 4: Apply SMOTE — But Only on Training Data</h3><p>Next, I tried <strong>SMOTE</strong> (Synthetic Minority Oversampling Technique).</p><p>Important:<br> ❌ Don’t apply SMOTE before scaling<br> ❌ Don’t apply SMOTE to the test data<br> ✔️ Apply only to the <strong>training split</strong></p><p>Correct pipeline:</p><pre>X_train, X_test, y_train, y_test = train_test_split(...)</pre><pre>scaler = StandardScaler()<br>X_train_scaled = scaler.fit_transform(X_train)<br>X_test_scaled = scaler.transform(X_test)</pre><pre>smote = SMOTE(random_state=42)<br>X_train_res, y_train_res = smote.fit_resample(X_train_scaled, y_train)</pre><p>Now the dataset became:</p><pre>Before SMOTE:<br>0 → 16977<br>1 → 1023</pre><pre>After SMOTE:<br>0 → 13590<br>1 → 13590</pre><p>Perfectly balanced.</p><p>My recall shot up, but precision was still low — common with SMOTE because synthetic samples can blur class boundaries.</p><h3>🎚️ Step 5: Tune the Threshold (The Real Game-Changer)</h3><p>Logistic regression predicts probabilities, not classes.</p><p>Instead of using default 0.5 threshold:</p><pre>y_prob = lr.predict_proba(X_test_scaled)[:,1]<br>y_pred = (y_prob &gt; 0.30).astype(int)</pre><p>This boosted my recall significantly for class 1 (Offer Accepted).</p><p>I tested several thresholds (0.20 to 0.50) and chose the best based on:</p><ul><li>F1 score</li><li>Precision-Recall tradeoff</li><li>Business use case</li></ul><p>In marketing, <strong>catching customers who <em>might</em> accept is more valuable</strong> — so I optimized for recall.</p><h3>Step 6: Evaluate with Useful Metrics (Not Accuracy)</h3><p>The most useful metrics in this project were:</p><h3>✔️ Precision</h3><p>How many predicted “accepted” were actually accepted?</p><h3>✔️ Recall</h3><p>How many accepted customers did the model catch?</p><h3>✔️ F1-score</h3><p>Balanced precision + recall.</p><h3>✔️ Confusion Matrix</h3><p>Shows true positives, false positives, false negatives.</p><p>Example from my project:</p><pre>[[1663 1725]<br> [  51  161]]</pre><p>This told me:</p><ul><li>False positives were high (but acceptable for marketing)</li><li>False negatives were low (good!)</li></ul><p>Which means:</p><p>👉 The model was good at catching potential customers<br> 👉 A few extra marketing calls were acceptable</p><p>This matched business goals — so this model was useful.</p><h3>📊 Final Results (After Fixing Imbalance)</h3><p>After SMOTE + threshold tuning:</p><ul><li>Accuracy: <strong>60.02%</strong></li><li>Precision: <strong>9.07%</strong></li><li>Recall: <strong>63.84%</strong></li><li>Balanced dataset</li><li>Better ability to predict minority class</li><li>High recall (perfect for offers/marketing)</li></ul><p>Were the results perfect?<br> No.</p><p>Were they actually <strong>useful</strong> for real business decisions?<br> <strong>Absolutely yes.</strong></p><h3>💡 What Actually Worked Best in My Offer Acceptance Project</h3><p>If I had to pick a winning strategy:</p><p>⭐ Class Weights + Threshold Tuning</p><p>This combination gave:</p><ul><li>Stable model</li><li>Less overfitting</li><li>Better minority prediction</li><li>Good balance of precision &amp; recall</li></ul><p>SMOTE helped too, but only after scaling and only on training data.</p><h3>🚀 Final Thoughts</h3><p>Working with imbalanced data in real marketing datasets taught me one lesson:</p><p>👉 <strong>Balancing the data is not just a technical step — it’s about aligning the model with business goals.</strong></p><p>In a credit card offer acceptance problem:</p><ul><li>Recall matters more</li><li>False positives are acceptable</li><li>Missing a potential customer is costly</li></ul><p>Once I understood this, handling imbalance became clearer and more effective.</p><p>If you’re working on logistic regression or marketing analytics datasets, imbalance isn’t a problem — it’s a feature of the real world.</p><p>This project was completed as part of my academic work in the field of Data Science and Analytics. I would like to acknowledge the guidance and support provided by <a href="https://imarticus.org/postgraduate-program-in-data-science-analytics/"><strong>ImarticusLearning</strong></a>, which has been instrumental in helping me understand and apply practical techniques such as handling imbalanced data using Logistic Regression and SMOTE. This experience has strengthened my skills in data preprocessing, model evaluation, and real-world machine learning applications, and I am grateful for the resources and learning environment.</p><p>Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e92dd680c0d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power of Data: How Analytics is Shaping Our World”]]></title>
            <link>https://medium.com/@tanvimoghe1/analytics-use-cases-in-different-industries-886c747bbcd2?source=rss-1b7fb701ebc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/886c747bbcd2</guid>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Tanvi Moghe]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 17:16:09 GMT</pubDate>
            <atom:updated>2025-07-23T14:16:54.478Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Have you ever wondered why data analytics is so important in every industry?</strong></h3><p>Because every industry generates a large amount of data daily. But for that data, proper analysis is very important. Without analysis data is just a noise. Le’ts see how data analytics apply to different industries to solve real world challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_rzVyY3dlwAGZ2KCUJnx6A.png" /><figcaption>made in canva</figcaption></figure><p><strong>What is Data?</strong></p><p>Data means it is a raw material of analytics. Without data there is no analytics”. Data comes in 3 different types that are -</p><p>Structured(Tables, spreadsheets), Unstructured(text, images, videos) &amp; Semi-Structured(json, xml).</p><blockquote><strong><em>Lets pretend you own a ice-cream parlour! &amp;…You selling</em></strong> : Chocolate Flavour, Vanila Flavour, Strawberry Flavour, Pineapple Flavour.</blockquote><blockquote><strong>Everyday you take a note of </strong>:</blockquote><p>How many of each ice cream you sold? <br>At what time people buying the most? <br>If its a sunny or rainy day.</p><blockquote><strong><em>Thats called Collection of Data.</em></strong></blockquote><blockquote>Now comes to the technical part, After one month you looked at all you notes(data) using the computer. &amp; it tells you:</blockquote><p>Ice creams sell the most in sunny days.<br>Strawberry flavour sells best in evening.<br>Pineapple is&#39;nt selling much at all.</p><blockquote><strong><em>It means you are using computer to analyze the data, that’s called Data Analytics.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*YDcPQIXeZoxXGIdjpTMPtg.png" /><figcaption>made in powerpoint</figcaption></figure><h4><strong>There are 4 main types of data analytics :</strong></h4><blockquote><strong>Descriptive Analytics — </strong>“What happened?”</blockquote><blockquote><strong>Diagnostic Analytics</strong> — “Why did it happen?”</blockquote><blockquote><strong>Predictive Analytics</strong> — “What will happen?”</blockquote><blockquote><strong>Prescriptive Analytics</strong> — “What should we do?”</blockquote><h4><strong>Tools &amp; Technologies :</strong></h4><blockquote><strong>Languages: </strong>Python, R, SQL</blockquote><blockquote><strong>Libraries: </strong>Pandas, NumPy, Matplotlib</blockquote><blockquote><strong>Platforms: </strong>Tableau, Power BI, Google Data Studio</blockquote><h3>How does it work technically?</h3><p>You have to use <strong>Spreadsheets</strong> like Excel. A simple <strong>program</strong> written in a computer language (like Python) to read the numbers and make graphs.</p><pre>Day        | Weather | Time      | Chocolate | Vanilla | Strawberry | Pineapple<br>-------------------------------------------------------------------------------<br>2025-07-01 | Sunny   | Morning   | 10        | 8       | 5          | 3<br>2025-07-01 | Sunny   | Evening   | 15        | 12      | 20         | 4<br>2025-07-02 | Rainy   | Morning   | 6         | 5       | 2          | 1<br>2025-07-02 | Rainy   | Evening   | 8         | 7       | 4          | 2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*hbX29wAlAtSJrqiardfkfw.png" /></figure><h4>Now we will see how data analytics works in industries?</h4><h3><strong>Healthcare</strong></h3><p>Data analytics is becoming more commonly used in pharma and healthcare. Advanced cloud technologies and big data have applications for improving customer satisfaction and medical services. New products like remote-patient monitoring devices and wearable trackers are two products that were created to monitor patient data. Advances in data analytics also offer healthcare providers a more comprehensive understanding of their patients.</p><h3>Government</h3><p>Data analytics is playing an increasing role in the function of government institutions. The government performs various kinds of analysis such as health research, financial market analysis, environmental protection research, fraud detection, and energy exploration. It relies on big data to offer better services and increase overall satisfaction across fields of public service. For example, the FDA applies data science and analytics techniques to find and study food-related illnesses and diseases.</p><h3>Retail</h3><p>The retail industry revolves around creating a positive customer experience and profitable margins. Both providers and stores use data to learn more about what products are selling, when they’re selling, and how they’re selling. The analytics process allows them to measure variables pertaining to inventory volumes, consumer demand, sales, and the supply chain. Many retailers are turning to data analytics to anticipate what customers want so they can be the first to offer these products and services. The more those in retail know about how to use the insights big data provides, the better they’ll be able to compete with others in the market and stay on top.</p><h3>Manufacturing</h3><p>All types of manufacturing industries such as gas, oil, minerals, and metals, continue to create a large volume of data. Not only is there a large amount of data being generated from these industries, but much of it is hard to handle due to its complexity. This means it’s vital for data analytics. This is why those who work in the manufacturing industry are digitizing and investing significant sums in predictive analytics tools.Organizations find value in all kinds of data such as graphical information, temporal data, IoT records, text, and graphics. The data that is gathered allows manufacturers to know how much production they will need to meet market demand, which can help the business perform better as a whole.</p><h3>Banking</h3><p>The biggest banks and financial markets rely on cutting-edge data tools and software like Microsoft Power BI and Splunk to perform tasks like staying current on trade analytics in high-frequency trading, predictive analytics, sentiment measurement, and pre-trade decision-support analytics.</p><p>Stock exchanges, for example, use natural language processors and network analytics to monitor any illegal trade practices in the stock market to help stop them. Investment banks use risk models to reduce a portfolio’s risk and help it perform better. These models are used across fields so that financial institutions can articulate how risky an investment is, what is likely to transpire, and the costs associated with mitigating risk factors. Financial institutions also perform data analysis to evaluate the risk of loans they offer customers.</p><p><strong><em>For the explanation of data analytics in detail, you can prefer this video for better &amp; deep understanding :</em></strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FyZvFH7B6gKI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DyZvFH7B6gKI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FyZvFH7B6gKI%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c11740eeac101a0ec6cd4ef55929805/href">https://medium.com/media/1c11740eeac101a0ec6cd4ef55929805/href</a></iframe><h4>There are some skills that every analyst should required which are :</h4><p>Critical Thinking, Data Visualization, Statistical analysis, Curosity &amp; Continous learning.</p><h4>What is the future scope of data analytics in India?</h4><p>The future of data analytics in India is promising, with its pivotal role in driving business success and innovation across various sectors. As we embrace advancements in artificial intelligence and machine learning, the scope of data analytics will continue to expand. The future scope of data science highlights significant opportunities for professionals and aspirants to thrive in this dynamic field. Data analytics promises enhanced decision-making, efficiency, and customer experiences. This field will drive economic growth and technological progress. Ultimately, understanding the scope of data analytics will be essential for organisations and professionals aiming to leverage data for a competitive edge.</p><blockquote>“Without data, you’re just another person with an opinion.” — W. Edwards Deming</blockquote><p><em>Okay, Thank you for reading this blog!</em></p><p><em>As you join this blogathon journey, take one small dataset, ask one meaningful question, and turn it into a story worth sharing.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=886c747bbcd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>