<?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 Samuel Mugisha D.C on Medium]]></title>
        <description><![CDATA[Stories by Samuel Mugisha D.C on Medium]]></description>
        <link>https://medium.com/@dcgroup205?source=rss-00ebb933bcae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gpyoqMo9rszxFJTDnROGVQ.jpeg</url>
            <title>Stories by Samuel Mugisha D.C on Medium</title>
            <link>https://medium.com/@dcgroup205?source=rss-00ebb933bcae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 13:18:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dcgroup205/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From survey answers to a deployed ML App: Predicting Customer Happiness]]></title>
            <link>https://medium.com/@dcgroup205/from-survey-answers-to-a-deployed-ml-app-predicting-customer-happiness-4e94b4720145?source=rss-00ebb933bcae------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e94b4720145</guid>
            <dc:creator><![CDATA[Samuel Mugisha D.C]]></dc:creator>
            <pubDate>Wed, 25 Feb 2026 08:39:51 GMT</pubDate>
            <atom:updated>2026-02-25T09:45:35.899Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XEccvmSxUW5SM_ujCyLUFg.png" /><figcaption>Customer Happiness Prediction by Samuel Mugisha D.C.</figcaption></figure><p>If you’ve ever shipped a delivery order and wondered, <em>“Will this customer be happy?”</em> — you’ve already met the problem this project tackles.</p><p>In this Apziva AI Residency project, I built a <strong>customer happiness prediction system</strong> for a fictional logistics startup called <strong>ACME</strong>. Using survey responses (rated 1–5), the goal is to predict whether a customer is <strong>Happy (1)</strong> or <strong>Unhappy (0)</strong> — and also figure out <strong>which questions matter most</strong>, so future surveys can be shorter and smarter.</p><p>This article walks you through the problem <strong>step by step</strong>, from data understanding to modeling and finally <strong>deploying a simple web app (Streamlit + Flask) inside Docker</strong>.</p><h3>What you’ll learn</h3><p>By the end, you’ll know how to:</p><ul><li>Frame a survey-based classification problem</li><li>Perform practical EDA and detect weak features</li><li>Train multiple models and avoid overfitting (especially on small datasets)</li><li>Improve results via <strong>feature reduction</strong> + <strong>hyperparameter tuning</strong></li><li>Deploy the final model behind an API and a simple UI</li></ul><h3>1) Understand the business problem</h3><p>ACME is scaling quickly, and they can’t manually read every comment or call every customer. They need a model that can:</p><ol><li>Predict happiness from survey answers</li><li>Identify the most influential survey questions</li></ol><p>The project target was to reach <strong>~73% accuracy</strong> (or deliver a compelling alternative with strong insights).</p><h3>2) Understand the data</h3><p>The dataset has <strong>126 rows</strong> and <strong>7 columns</strong>: one target and six survey questions.</p><ul><li><strong>Target</strong></li><li>Y: 0 (unhappy) / 1 (happy)</li><li><strong>Features</strong> (1–5 scale)</li><li>X1: Delivered on time</li><li>X2: Contents as expected</li><li>X3: Ordered everything needed</li><li>X4: Paid a good price</li><li>X5: Satisfied with courier</li><li>X6: App makes ordering easy</li></ul><p><strong>Tip:</strong> In real life, survey data is often “clean-ish” but still needs careful inspection (duplicates, skews, outliers).</p><h3>3) Load and sanity-check the dataset</h3><p>Start with the basics:</p><ul><li>Shape, data types, basic descriptive stats</li><li>Missing values</li><li>Duplicates</li></ul><p>In this project, the dataset had <strong>no null values</strong> but did contain <strong>duplicate rows</strong> (16 duplicates were identified).</p><p><strong>Why it matters:</strong> duplicates can inflate performance and hide generalization issues — especially with small datasets.</p><h3>4) Do EDA that actually helps modeling</h3><p>EDA isn’t about making pretty charts — it’s about answering:</p><ul><li>Is the target balanced?</li><li>Which features seem related to Y?</li><li>Are there outliers or odd distributions?</li></ul><p>This project used:</p><ul><li>univariate plots (histograms/boxplots)</li><li>correlation heatmaps</li><li>stacked bar and distribution plots to inspect feature vs target relationships</li></ul><h3>Key insight from EDA</h3><p>Some features were only weakly related to happiness (notably X2 and X4 showed very weak correlations in early correlation analysis), while others looked more meaningful.</p><h3>5) Handle outliers (lightly, on purpose)</h3><p>With Likert-scale survey data (1–5), “outliers” are less extreme than in financial data, but they can still distort learning.</p><p>This project used <strong>flooring and capping</strong> via np.clip to limit outlier influence.</p><p><strong>Rule of thumb:</strong> If outliers are likely due to measurement quirks (or duplicates), treat them. If they represent real rare experiences, consider keeping them.</p><h3>6) Split the data for modeling</h3><p>A standard approach:</p><ul><li>Train/Test split: <strong>80/20</strong></li><li>Keep the test set untouched until the end</li></ul><p>This is especially important because with 126 rows, it’s easy to overfit accidentally.</p><h3>7) Train baseline models (don’t skip this)</h3><p>Instead of betting on one algorithm, compare a few:</p><ul><li>Logistic Regression (interpretable)</li><li>Decision Tree</li><li>Random Forest</li><li>SVM</li><li>Naive Bayes</li></ul><p><strong>Why this matters:</strong> different algorithms behave differently on small, low-dimensional data. Baselines help you detect overfitting early.</p><h3>What happened here</h3><p>The tree-based models initially showed <strong>severe overfitting</strong> — great training performance, weak test performance — because the dataset is small.</p><h3>8) Tune models to fight overfitting</h3><p>For the Decision Tree (and later Random Forest), the project used <strong>GridSearchCV</strong> to tune parameters like:</p><ul><li>max_depth</li><li>min_samples_leaf</li><li>criterion</li></ul><p><strong>Takeaway:</strong> tuning isn’t about squeezing extra 1–2% accuracy — it’s about making performance more reliable.</p><h3>9) Feature selection: keep what matters</h3><p>Here’s one of the best parts of this project: it doesn’t just “train a model.” It also asks:</p><blockquote><em>Which survey questions actually drive happiness?</em></blockquote><p>Based on early analysis and feature importance checks, the project dropped <strong>X4 (price)</strong> and <strong>X6 (ease of ordering)</strong> and retrained models using a reduced feature set.</p><p>Reduced features became:</p><ul><li>X1, X2, X3, X5</li></ul><h3>Why feature reduction worked</h3><p>On small datasets, extra features can introduce noise and worsen generalisation. Reducing features can make the model <strong>simpler and more stable</strong>.</p><h3>10) Final model and results</h3><p>The best-performing approach was:</p><p>✅ <strong>Random Forest (Reduced Features)</strong> — meeting the target accuracy.</p><p>Reported metrics:</p><ul><li><strong>Accuracy:</strong> 0.730769</li><li><strong>Recall:</strong> 0.846154</li><li><strong>Precision:</strong> 0.687500</li><li><strong>F1:</strong> 0.758621</li></ul><p>That accuracy meets the project target and the recall suggests the model is good at catching “happy” customers correctly — useful if ACME is trying to understand what drives success.</p><h3>11) Turn the model into a product (deployment)</h3><p>A project feels “real” when someone can use it.</p><p>This repo includes a deployment-ready setup:</p><ul><li><strong>Flask</strong> backend API (backend.py) to serve predictions</li><li><strong>Streamlit</strong> frontend (app.py) for an interactive UI</li><li><strong>Dockerfile + entrypoint.sh</strong> to run both services in one container</li></ul><h3>Architecture (simple + scalable)</h3><ol><li>User enters survey scores in Streamlit</li><li>Streamlit sends request to Flask /predict</li><li>Flask loads the trained model and returns prediction</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ohPj_CbUJX0VfQASjv3IA.png" /></figure><h3>Why this design is good</h3><ul><li>The UI is separated from model serving</li><li>You can swap Streamlit later without changing the model API</li><li>Docker makes it reproducible across machines</li></ul><h3>12) How to reproduce this kind of project (your checklist)</h3><p>If you want to solve similar survey classification problems, follow this practical playbook:</p><ol><li><strong>Frame the objective + metric</strong></li><li><strong>Inspect and clean the data</strong></li><li><strong>EDA to identify likely strong/weak features</strong></li><li><strong>Train multiple baselines</strong></li><li><strong>Tune to reduce overfitting</strong></li><li><strong>Do feature reduction (especially on small datasets)</strong></li><li><strong>Select final model using accuracy + precision/recall/F1</strong></li><li><strong>Package and deploy</strong></li><li><strong>Write clear documentation so others can run it</strong></li></ol><p>This is exactly the flow used in the repo.</p><h3>Closing thoughts</h3><p>This project is a great example of “real-world ML” because it’s not just modeling — it’s decision-making:</p><ul><li>Which questions matter most?</li><li>How do we avoid overfitting on small data?</li><li>How do we turn a notebook into something usable?</li></ul><p>And the final recommendation is actionable: focus operational improvements on <strong>on-time delivery, meeting expectations, enabling full ordering, and courier satisfaction</strong> — the strongest drivers found in the project.</p><p>⭐ The full source code is available here:<br> <a href="https://github.com/samuelmugisha/bSXsGeDhGRcNAdms?utm_source=chatgpt.com">https://github.com/samuelmugisha/bSXsGeDhGRcNAdms</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e94b4720145" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>