<?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 Sadiq Adebimpe on Medium]]></title>
        <description><![CDATA[Stories by Sadiq Adebimpe on Medium]]></description>
        <link>https://medium.com/@sadiqadebimpem?source=rss-1a81550e07fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3n3KViFfKHvBRIxbX2TXgA.jpeg</url>
            <title>Stories by Sadiq Adebimpe on Medium</title>
            <link>https://medium.com/@sadiqadebimpem?source=rss-1a81550e07fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:10:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sadiqadebimpem/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[SECTION 1 — Title How I Built and Deployed a Fraud Detection App with Python and Streamlit]]></title>
            <link>https://medium.com/@sadiqadebimpem/section-1-title-how-i-built-and-deployed-a-fraud-detection-app-with-python-and-streamlit-4971a802fbf3?source=rss-1a81550e07fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4971a802fbf3</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[fraud-detection]]></category>
            <dc:creator><![CDATA[Sadiq Adebimpe]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 11:17:50 GMT</pubDate>
            <atom:updated>2026-04-01T11:17:50.224Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OzbYh9rzyuMZgu10LeCiw.png" /></figure><h3>SECTION 1 — Title <br>How I Built and Deployed a Fraud Detection App with Python and Streamlit</h3><h4>SECTION 2 — Subtitle <br>A beginner’s guide to building, debugging, and deploying a real machine learning app — mistakes included</h4><p>SECTION 3 — Introduction<br>Billions of dollars are lost to financial fraud every year. Banks and fintech companies rely on complex systems to catch suspicious transactions — but what does it actually take to build one from scratch?</p><p>As a data science graduate of TechCrush, I decided to find out. I built and deployed a fully functional Fraud Detection App using Python and Streamlit — from training the machine learning model to making it live on the internet. It wasn&#39;t smooth sailing, but every bug and broken deployment taught me something I couldn&#39;t have learned in a classroom.</p><p>In this article, I&#39;ll walk you through exactly how I built it, the tools I used, the errors that nearly broke me, and what I&#39;d do differently next time.</p><p>🔗 Live App: https://fraud-detection-app-cyuhymbeyxew7jkuji3jd7.streamlit.app/<br>🔗 GitHub: https://github.com/Adebimpe0/Fraud-Detection-App</p><p>SECTION 4 — What the App Does (Make heading H2)<br>What the App Does</p><p>The app predicts in real time whether a financial transaction is fraudulent or legitimate. A user inputs transaction details — such as the transaction value, month, day, account ID, and product category — and the app instantly returns a prediction along with a fraud risk percentage.</p><p>It&#39;s simple, fast, and accessible from any browser. No installation required.</p><h4>SECTION 5 — Tools Used <br>Tools and Technologies Used</h4><p>Python — core programming language<br>Scikit-learn — model training and preprocessing<br>XGBoost — gradient boosting model (tested during training)<br>Pandas &amp; NumPy — data manipulation and feature engineering<br>Matplotlib &amp; Seaborn — data visualization<br>Streamlit — interactive web app framework<br>GitHub — version control<br>Streamlit Cloud — free deployment platform</p><h4>SECTION 6 — Understanding the Data <br>Step 1: Understanding the Data</h4><p>I trained the model on a financial transactions dataset containing 95,662 transactions across 16 columns — including fields like transaction value, product category, channel ID, provider, and timestamps.</p><p>The first thing I noticed was a major class imbalance — only 193 out of 95,662 transactions were fraudulent. That&#39;s about 0.2%. This is a classic imbalanced classification problem, and it directly affected how I evaluated my models later.</p><p>The good news: no missing values and no duplicate rows, so the data was clean from the start.</p><h4>SECTION 7 — Feature Engineering <br>Step 2: Feature Engineering</h4><p>Raw data is rarely model-ready. I engineered three new features to give the model more signal:</p><p>1. Month — extracted from the transaction timestamp<br>2. Day — extracted from the transaction timestamp<br>3. Credit_or_Debit — whether the transaction amount was negative (credit) or positive (debit)</p><p>I also dropped columns that wouldn&#39;t help the model: TransactionId, TransactionStartTime, Amount, and CurrencyCode (every single transaction used UGX — no variance at all).</p><p>This left me with 14 features for training.</p><h4>SECTION 8 — Preprocessing <br>Step 3: Preprocessing</h4><p>Categorical features like ProductCategory, ChannelId, and ProviderId were text-based, so I encoded them using LabelEncoder to convert them into numbers the model could understand.</p><p>I then applied StandardScaler to normalize the full feature set — making sure no single feature dominated just because of its scale.</p><h4>SECTION 9 — Model Training <br>Step 4: Training and Comparing Models</h4><p>I tested three models: Logistic Regression, XGBoost, and Random Forest.</p><p>Because the dataset was so imbalanced, accuracy alone was misleading — a model that predicts &quot;not fraud&quot; for everything would still get 99.8% accuracy. The metric that actually mattered was the F1-score for the fraud class.</p><p>Here&#39;s how they compared:</p><p>🔵 Logistic Regression — Fraud F1: 0.23<br>🔴 XGBoost — Fraud F1: 0.00 (detected zero fraudulent transactions)<br>🟢 Random Forest — Fraud F1: 0.77 ✅ (chosen model)</p><p>XGBoost completely failed to detect any fraud at all. Logistic Regression caught some but poorly. Random Forest was the clear winner.</p><p>I also evaluated it using the ROC-AUC score — which measures how well the model separates the two classes. The Random Forest scored 0.97 out of 1.0, meaning it was excellent at distinguishing fraud from legitimate transactions.</p><p>The most important feature? Transaction Value dominated at 69.2% importance — meaning how much money is involved is the strongest predictor of fraud in this dataset.</p><h4>SECTION 10 — Saving the Model <br>Step 5: Saving the Model</h4><p>After training, I saved the model, encoder, and scaler as .pk files so the app could load them without retraining every time a user opens it.</p><h4>SECTION 11 — Building the App <br>Step 6: Building the Streamlit App</h4><p>With the model saved, I built an interactive web interface using Streamlit. The app loads the saved files on startup, accepts user input through a sidebar, preprocesses it through the same pipeline used during training, and returns a prediction with a risk percentage.</p><p>The sidebar layout kept the interface clean and easy to use, even on mobile.</p><h4>SECTION 12 — Deployment <br>Step 7: Deployment on Streamlit Cloud</h4><p>The steps were simple:<br>1. Push all project files to a GitHub repository<br>2. Log in to Streamlit Cloud<br>3. Connect the GitHub repository and specify the main app file<br>4. Click Deploy</p><p>Streamlit Cloud reads a requirements.txt file, installs dependencies automatically, and hosts the app on a public URL — free, no server setup required.</p><h4>SECTION 13 — Challenges <br>Challenges I Faced (The Real Learning Curve)</h4><p>Training the model took hours. The deployment issues took days.</p><p>1. Python version incompatibility<br>I was running Python 3.13 locally, which was too new for some packages. Libraries like XGBoost hadn&#39;t released compatible versions yet, causing installation failures on Streamlit Cloud. Fix: add a runtime.txt file specifying Python 3.10.</p><p>2. File naming errors<br>I spent over an hour on a FileNotFoundError caused by a typo — my code looked for fraud_encoder.pk but I had saved it as fraud_enconder.pk (an extra &#39;n&#39;). On Windows this doesn&#39;t matter. On Linux (which Streamlit Cloud runs on), it breaks everything.</p><p>3. Unsaved files in VS Code<br>More than once I pushed code to GitHub only to find the old version was still running. I had missed VS Code&#39;s unsaved file indicator. I now use Auto Save and always verify changes are committed before deploying.</p><p>4. Local vs. cloud file paths<br>File paths that work locally don&#39;t always work on the cloud. The fix was to use os.path to build absolute paths relative to the script file rather than assuming the working directory.</p><h4>SECTION 14 — What I Learned <br>What I Learned</h4><p>The F1-score matters more than accuracy for imbalanced data. XGBoost looked fine at 99.59% accuracy — but it predicted zero fraudulent transactions correctly. Accuracy can lie. Always check the metrics that matter for your specific problem.</p><p>Transaction value is king. One feature — Value — accounted for 69% of the model&#39;s decisions. Sometimes one feature carries most of the signal.</p><p>Deployment is where real data science begins. Notebooks are comfortable. Production is where things break — and where you truly learn how ML systems work.</p><p>Small habits save hours. Consistent filenames, Auto Save, pinning package versions — these feel minor until one of them costs you an afternoon.</p><h4>SECTION 15 — Conclusion<br>Conclusion</h4><p>Building this fraud detection app end-to-end was one of the most valuable things I&#39;ve done as a data science student. It pushed me beyond notebooks and tutorials into real problem-solving — and I came out the other side a more confident developer.</p><p>If you&#39;re learning data science, don&#39;t wait until you feel &quot;ready&quot; to build and deploy a project. You&#39;ll learn more from one broken deployment than from ten completed courses.</p><p>🔗 Try the live app: /<a href="https://fraud-detection-app-cyuhymbeyxew7jkuji3jd7.streamlit.app/">https://fraud-detection-app-cyuhymbeyxew7jkuji3jd7.streamlit.app/</a><br>🔗 View the source code:</p><p><a href="https://github.com/Adebimpe0/Fraud-Detection-App">https://github.com/Adebimpe0/Fraud-Detection-App</a></p><p>What project are you currently working on? Drop a comment — I&#39;d love to hear about it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4971a802fbf3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>