<?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 Moriom Khan Mokka on Medium]]></title>
        <description><![CDATA[Stories by Moriom Khan Mokka on Medium]]></description>
        <link>https://medium.com/@22234103145?source=rss-43497248eb66------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GcptV2KZ-bGMeYe8</url>
            <title>Stories by Moriom Khan Mokka on Medium</title>
            <link>https://medium.com/@22234103145?source=rss-43497248eb66------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 14:47:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@22234103145/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[ Building a Credit Card Fraud Detection System Using Random Forest + SMOTE]]></title>
            <link>https://medium.com/@22234103145/building-a-credit-card-fraud-detection-system-using-random-forest-smote-3880b29a3e9c?source=rss-43497248eb66------2</link>
            <guid isPermaLink="false">https://medium.com/p/3880b29a3e9c</guid>
            <dc:creator><![CDATA[Moriom Khan Mokka]]></dc:creator>
            <pubDate>Sun, 23 Nov 2025 06:47:54 GMT</pubDate>
            <atom:updated>2025-11-23T06:47:54.775Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From Data Preprocessing to Real-Time Prediction in Python</em></p><p>Credit card fraud has become increasingly sophisticated, making machine-learning-based detection systems a critical defense layer for financial institutions. In this article, we’ll walk through building a <strong>complete fraud detection pipeline</strong> — from loading data and preprocessing to handling imbalance, training a robust Random Forest model, and finally making <strong>real-time predictions from user input</strong>.</p><p>This entire workflow was implemented in Google Colab using the popular <strong>creditcard.csv</strong> dataset.</p><h3>⭐ 1. Mounting Google Drive and Importing Dependencies</h3><p>We start by mounting Google Drive so the dataset and trained models can be loaded/saved easily:</p><pre>from google.colab import drive<br>drive.mount(&#39;/content/drive&#39;)</pre><p>Next, we import essential libraries:</p><ul><li><strong>Pandas</strong> for data loading</li><li><strong>Scikit-learn</strong> for model building</li><li><strong>SMOTE</strong> from imbalanced-learn to balance classes</li><li><strong>Joblib</strong> to save the trained model</li></ul><pre>import pandas as pd<br>from sklearn.model_selection import train_test_split<br>from sklearn.preprocessing import StandardScaler<br>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.metrics import classification_report, confusion_matrix<br>from imblearn.over_sampling import SMOTE<br>import joblib</pre><h3>📥 2. Loading the Fraud Dataset</h3><pre>data = pd.read_csv(&quot;/content/drive/MyDrive/Credit Card Fraud Detection1/creditcard.csv&quot;)</pre><p>This dataset contains:</p><ul><li><strong>Time</strong></li><li><strong>Amount</strong></li><li><strong>28 PCA-transformed features (V1–V28)</strong></li><li><strong>Class</strong> → (0 = normal, 1 = fraud)</li></ul><h3>🔎 3. Splitting Features and Target</h3><pre>X = data.drop(&quot;Class&quot;, axis=1).copy()<br>y = data[&quot;Class&quot;]</pre><h3>🧪 4. Train-Test Split (Crucial!)</h3><p>SMOTE <strong>must</strong> be applied only on the training set to avoid data leakage.</p><pre>X_train, X_test, y_train, y_test = train_test_split(<br>    X, y, test_size=0.2, random_state=42, stratify=y<br>)</pre><h3>📊 5. Scaling Only the “Amount” Feature</h3><p>Only the Amount column is scaled because all other features are already PCA-transformed.</p><pre>scaler = StandardScaler()<br>X_train[&quot;Amount&quot;] = scaler.fit_transform(X_train[[&quot;Amount&quot;]])<br>X_test[&quot;Amount&quot;] = scaler.transform(X_test[[&quot;Amount&quot;]])</pre><h3>⚖️ 6. Handling Class Imbalance Using SMOTE</h3><p>This dataset is extremely imbalanced (fraud ≈ 0.17%).<br> SMOTE synthetically oversamples the minority class:</p><pre>sm = SMOTE(random_state=42)<br>X_train_resampled, y_train_resampled = sm.fit_resample(X_train, y_train)</pre><p>Before oversampling:</p><pre>0 → 227,451  <br>1 → 394</pre><p>After SMOTE:</p><pre>0 → 227,451  <br>1 → 227,451</pre><p>Balanced!</p><h3>🌳 7. Training a Random Forest Classifier</h3><pre>model = RandomForestClassifier(<br>    n_estimators=300,<br>    max_depth=15,<br>    class_weight=&quot;balanced&quot;,<br>    random_state=42<br>)</pre><pre>model.fit(X_train_resampled, y_train_resampled)</pre><p>Why Random Forest?</p><ul><li>Handles high-dimensional data</li><li>Resistant to overfitting</li><li>Works well with imbalanced classes</li></ul><h3>📝 8. Evaluating on Real Test Data</h3><pre>y_pred = model.predict(X_test)</pre><pre>print(classification_report(y_test, y_pred))<br>print(confusion_matrix(y_test, y_pred))</pre><p><strong>Test Results Summary:</strong></p><ul><li><strong>Recall on Fraud</strong> = 0.87</li><li><strong>Precision on Fraud</strong> = 0.69</li><li>Very strong performance overall.</li></ul><p>Confusion Matrix:</p><pre>[[56825    39]<br> [   13    85]]</pre><h3>💾 9. Saving the Model, Scaler &amp; Column Order</h3><p>These are crucial for making consistent predictions later.</p><pre>joblib.dump(model, &quot;fraud_model.pkl&quot;)<br>joblib.dump(scaler, &quot;scaler.pkl&quot;)<br>joblib.dump(feature_order, &quot;feature_order.pkl&quot;)</pre><h3>🚀 PART 2 — Making Real-Time Predictions with User Input</h3><p>Once the model is trained, we create a <strong>simple prediction system</strong> that allows a user to enter a full transaction row manually.</p><h3>📥 Loading the Saved Model</h3><pre>model = joblib.load(&quot;fraud_model.pkl&quot;)<br>scaler = joblib.load(&quot;scaler.pkl&quot;)<br>feature_order = joblib.load(&quot;feature_order.pkl&quot;)</pre><h3>🧑‍💻 Accepting User Input</h3><p>The user enters <strong>31 comma-separated values</strong>:</p><pre>values = list(map(float, user_input.split(&quot;,&quot;)))</pre><p>We assign these to the correct columns:</p><pre>columns = [&#39;Time&#39;, &#39;Amount&#39;,&#39;V1&#39;,&#39;V2&#39;,&#39;V3&#39;,&#39;V4&#39;,&#39;V5&#39;,&#39;V6&#39;,&#39;V7&#39;,&#39;V8&#39;,&#39;V9&#39;,&#39;V10&#39;,&#39;V11&#39;,<br>           &#39;V12&#39;,&#39;V13&#39;,&#39;V14&#39;,&#39;V15&#39;,&#39;V16&#39;,&#39;V17&#39;,&#39;V18&#39;,&#39;V19&#39;,&#39;V20&#39;,&#39;V21&#39;,&#39;V22&#39;,&#39;V23&#39;,&#39;V24&#39;,<br>           &#39;V25&#39;,&#39;V26&#39;,&#39;V27&#39;,&#39;V28&#39;]</pre><h3>🔄 Preprocessing Input (Important!)</h3><p>We replicate the exact training process:</p><ul><li>Scale only the Amount</li><li>Reorder columns</li></ul><pre>df[&#39;Amount&#39;] = scaler.transform(df[[&#39;Amount&#39;]])<br>df = df[feature_order]</pre><h3>🧠 Predicting Fraud</h3><pre>prediction = model.predict(df)[0]<br>proba = model.predict_proba(df)[0][1]</pre><h3>🟢 Final Output</h3><p>If prediction is 0:</p><pre>🟢 Normal Transaction. Fraud Probability: 0.1733</pre><p>If prediction is 1:</p><pre>🔴 Fraud Detected! Probability: 0.92</pre><h3>🎯 Final Thoughts</h3><p>You’ve now built:</p><h3>✅ Data preprocessing pipeline</h3><h3>✅ Balanced dataset using SMOTE</h3><h3>✅ Random Forest fraud detection model</h3><h3>✅ Real-time input prediction system</h3><h3>✅ Saved model for deployment</h3><p>This is a fully functional <strong>end-to-end fraud detection system</strong>, suitable for integration with mobile banking apps, internal dashboards, or API-based fraud monitoring tools.</p><p><strong><em>“Medium Blog Assignment Given by: Sudipto Chaki”</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3880b29a3e9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detecting Online Banking Frauds with Data Mining: How Smart Algorithms Keep Your Money Safe]]></title>
            <link>https://medium.com/@22234103145/detecting-online-banking-frauds-with-data-mining-how-smart-algorithms-keep-your-money-safe-4ca6f049c000?source=rss-43497248eb66------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ca6f049c000</guid>
            <dc:creator><![CDATA[Moriom Khan Mokka]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 10:52:04 GMT</pubDate>
            <atom:updated>2025-10-24T10:52:04.794Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In today’s digital world, <strong>online banking</strong> has become an everyday part of life. We transfer money, pay bills, and shop online — all with just a few clicks. But this convenience also attracts cybercriminals who constantly look for ways to exploit financial systems.</p><p>To stay ahead, banks are turning to <strong>data mining</strong> — a powerful technique that digs deep into large volumes of data to uncover hidden patterns and detect suspicious activities before they cause harm.</p><p>Let’s explore how <strong>data mining helps detect and prevent online banking frauds</strong> in the modern financial ecosystem.</p><h3>🧠 What Is Data Mining in Simple Terms?</h3><p>Data mining is the process of discovering meaningful patterns, correlations, and trends within large datasets using machine learning, statistics, and artificial intelligence.</p><p>In the context of <strong>banking</strong>, it means analyzing huge amounts of transaction data to identify:</p><ul><li>What’s normal customer behavior</li><li>What looks unusual or risky</li><li>How to stop fraudulent transactions in real time</li></ul><h3>🚨 Types of Online Banking Frauds</h3><p>Before we understand the role of data mining, let’s look at some common types of online frauds:</p><ol><li><strong>Phishing:</strong> Tricking users into giving away sensitive information.</li><li><strong>Identity Theft:</strong> Using stolen identities to open fake accounts or make transactions.</li><li><strong>Transaction Fraud:</strong> Unauthorized fund transfers or purchases.</li><li><strong>Card Skimming:</strong> Stealing card details via devices or malware.</li><li><strong>Account Takeover:</strong> Gaining access to legitimate accounts by stealing login credentials.</li></ol><p>Each of these frauds leaves behind subtle patterns — <strong>digital fingerprints</strong> — that data mining algorithms can detect.</p><h3>💡 How Data Mining Helps Detect Fraud</h3><h4>1. Behavioral Pattern Analysis</h4><p>Data mining algorithms learn what “normal” looks like for each user — such as usual transaction amounts, frequency, and locations.<br> When something unusual happens (like a midnight transaction from another country), the system flags it instantly.</p><h4>2. Classification Algorithms</h4><p>Techniques like <strong>Decision Trees</strong>, <strong>Random Forest</strong>, and <strong>Support Vector Machines (SVM)</strong> classify transactions as <em>legitimate</em> or <em>fraudulent</em> based on historical data.</p><h4>3. Clustering Methods</h4><p>Unsupervised learning methods like <strong>K-Means</strong> group similar transactions together. If one transaction falls outside the normal cluster, it may indicate potential fraud.</p><h4>4. Anomaly Detection</h4><p>Data mining models detect outliers — transactions that don’t match typical patterns. For example, a sudden transfer of a huge amount from a new device might raise an alert.</p><h4>5. Association Rule Mining</h4><p>This technique uncovers hidden relationships between fraudulent activities.<br> Example: “If multiple failed login attempts are followed by a password reset and an immediate transfer, there’s a 90% chance of fraud.”</p><h3>🏦 Real-World Applications in Banking</h3><p>Banks and financial institutions use these data mining techniques to:</p><ul><li>Monitor millions of transactions in <strong>real time</strong>.</li><li>Identify and block <strong>suspicious accounts or IP addresses</strong>.</li><li>Predict <strong>future fraudulent behavior</strong> using historical data.</li><li>Strengthen <strong>risk management</strong> and compliance.</li></ul><p>Big names like <strong>HSBC</strong>, <strong>J.P. Morgan</strong>, and <strong>ICICI Bank</strong> already use AI-driven data mining systems to safeguard customer funds.</p><h3>🔐 Challenges in Fraud Detection</h3><p>While data mining is powerful, it faces several challenges:</p><ul><li><strong>Evolving Fraud Patterns:</strong> Fraudsters constantly change tactics.</li><li><strong>Data Privacy:</strong> Sensitive banking data must be protected.</li><li><strong>Imbalanced Data:</strong> Fraud cases are rare compared to genuine transactions, making model training harder.</li><li><strong>False Positives:</strong> Sometimes legitimate transactions are flagged as fraud, frustrating customers.</li></ul><p>To address these, banks combine <strong>data mining</strong> with <strong>real-time analytics</strong> and <strong>machine learning feedback loops</strong> that improve accuracy over time.</p><h3>🚀 The Future of Fraud Detection</h3><p>The future of online fraud detection lies in combining <strong>data mining</strong>, <strong>artificial intelligence</strong>, and <strong>deep learning</strong>.<br> Modern systems will be able to:</p><ul><li>Learn from new fraud patterns in real time.</li><li>Understand user behavior across multiple platforms (mobile, web, ATM).</li><li>Predict potential fraud before it even happens.</li></ul><p>With data mining as the foundation, the banking world is moving toward <strong>proactive fraud prevention</strong>, not just detection.</p><h3>🧩 Conclusion</h3><p>Fraud detection is no longer just about catching criminals — it’s about <strong>building trust</strong> in digital finance.</p><p>Through data mining, banks can detect unusual patterns, prevent losses, and protect customers’ money more efficiently than ever before.<br> As cybercriminals get smarter, <strong>data-driven defense</strong> is the key to staying one step ahead.</p><p>In the world of online banking, <strong>data mining is the silent guardian</strong> keeping your transactions safe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ca6f049c000" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>