<?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 Sarfras on Medium]]></title>
        <description><![CDATA[Stories by Sarfras on Medium]]></description>
        <link>https://medium.com/@sarfrasspc?source=rss-1753880d5870------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QctPl-8FLxeZwjdW</url>
            <title>Stories by Sarfras on Medium</title>
            <link>https://medium.com/@sarfrasspc?source=rss-1753880d5870------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:01:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sarfrasspc/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 Archie: A RAG-Based Chatbot for Architectural Education]]></title>
            <link>https://medium.com/@sarfrasspc/building-archie-a-rag-based-chatbot-for-architectural-education-bec9d650e7f9?source=rss-1753880d5870------2</link>
            <guid isPermaLink="false">https://medium.com/p/bec9d650e7f9</guid>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[groq]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Sarfras]]></dc:creator>
            <pubDate>Fri, 29 Aug 2025 12:53:28 GMT</pubDate>
            <atom:updated>2025-08-29T12:54:52.931Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fq7_E0GX_5Cn7SQvLsWz6A.jpeg" /></figure><p>This article details the development of <strong>Archie</strong>, a specialized Retrieval-Augmented Generation (RAG) chatbot system designed to assist <strong>Bachelor of Architecture (B.Arch)</strong> students with their 5th-semester coursework. The system addresses the challenge of efficiently accessing and querying extensive course materials by combining advanced document processing, semantic search, and large language model capabilities. This article cover the system’s architecture, the technical stack used, and the results of its implementation.</p><h3>Archie’s Architecture: A Technical Deep Dive</h3><p>Archie’s robust and scalable architecture is built upon a modular design, leveraging established AI paradigms for efficient information retrieval and generation. The core components include:</p><h3>1. Document Processing Pipeline</h3><p>This pipeline meticulously extracts and prepares text from architectural PDFs. It utilizes PyMuPDF for robust text extraction, followed by regex-based cleaning to remove noise (page numbers, headers, bibliographies, etc.). Documents are then chunked using RecursiveCharacterTextSplitter (chunk size: 250 characters, overlap: 50 characters) to optimize for retrieval granularity while preserving context.</p><h3>2. Embedding and Vector Storage</h3><p>Cleaned text is transformed into semantic embeddings using HuggingFace’s sentence-transformers/all-MiniLM-L6-v2 model. This CPU-efficient choice provides strong performance and compact 384-dimensional embeddings. These embeddings are stored in Chroma DB, an open-source vector database optimized for efficient similarity searches, configured for k=2 retrieval to balance context richness and relevance.</p><h3>3. Retrieval-Augmented Generation (RAG) Implementation</h3><p>Archie integrates Groq’s Llama 3 70B model (llama3–70b-8192) via API for high-quality, fast inference. Custom prompt engineering instructs the LLM to act as an “Expert Academic Research Assistant,” ensuring accurate, cited, and academically-styled responses. LangSmith integration provides comprehensive conversation tracking and system monitoring for performance analysis and debugging.</p><h3>4. Web Interface</h3><p>The user-friendly web interface is built with FastAPI, providing a clean, responsive, and real-time interaction experience. The frontend, developed with vanilla HTML, CSS, and JavaScript, ensures a lightweight and easily deployable solution.</p><h3>Impact and Benefits</h3><p>Archie’s implementation demonstrates significant practical benefits for architectural education, particularly from a technical and operational standpoint:</p><p><strong>•Enhanced Accessibility &amp; Efficiency</strong>: By providing instant, cited access to course materials, Archie drastically reduces the time students spend on manual document searching. This translates to improved operational efficiency in information retrieval.</p><p><strong>•Scalability &amp; Future-Proofing</strong>: The modular architecture facilitates easy expansion to cover additional semesters and architectural sub-disciplines. Its design also allows for future integration of multi-modal capabilities (e.g., architectural drawings) and advanced RAG techniques, ensuring long-term viability.</p><p><strong>•Performance</strong>: Preliminary assessments show high accuracy and relevance in responses, with an average response time of 2–3 seconds, validating the efficiency of the chosen technical stack and the power of Groq’s Llama 3 70B model.</p><h3>Frontend Implementation: A Lightweight and Responsive Interface</h3><p>Archie’s user interface is a clean, responsive web application built with vanilla HTML, CSS, and JavaScript. This choice prioritizes a lightweight, fast, and easily deployable solution that directly interacts with the FastAPI backend. Key frontend features include:</p><p>•A streamlined chat interface with distinct user and assistant message bubbles.</p><p>•Dynamic input area with support for Enter to send and Shift+Enter for newlines.</p><p>•Visual feedback mechanisms, such as a loading spinner and robust error handling with a retry option.</p><p>•Session management via localStorage for persistent conversation history and a unique sessionId.</p><p>•Accessibility considerations, including proper ARIA attributes and keyboard navigation.</p><p>The index.html file, encapsulating the entire frontend, was generated via an AI assistant, demonstrating an accelerated development workflow. This approach facilitated rapid prototyping and deployment of a functional and user-centric interface.</p><h3>Visualizing Archie: In Action</h3><p>To illustrate Archie’s functionality and user experience, this section provides visual demonstrations of the system in operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HR-b-di2kTNK2ApdA7L9vA.png" /><figcaption>The initial home screen of Archie, welcoming the user and providing a brief overview of its capabilities</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bdsViR6dMa8XyWe5QxaSA.png" /><figcaption>A screenshot of Archie’s clean and responsive chat interface, highlighting the user and assistant bubbles, input field, and new chat button, demonstrating a typical user interaction</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMRxFipAoZcgbooZpMVJCw.png" /><figcaption>A screenshot of the LangSmith dashboard, illustrating the tracing and monitoring capabilities integrated into Archie, showing trace counts and latency metrics</figcaption></figure><h3>Code in Action: Exploring Archie’s Open-Source Foundation</h3><p>For those interested in diving deeper into the technical implementation, Archie is built on a robust and transparent codebase. The core components and their interactions are available for review, fostering collaboration and further development within the AI and education communities.</p><p><strong>Archie Repository</strong>: <a href="https://github.com/sarfraspc/barch-rag-chatbot.git">https://github.com/sarfraspc/barch-rag-chatbot.git</a></p><h3>How to Run Locally</h3><ol><li>Clone the Repository<br>Open your terminal and run:</li></ol><pre>git clone https://github.com/sarfraspc/barch-rag-chatbot.git <br>cd barch-rag-chatbot</pre><p>2. Create and Activate Environment<br>(Using conda or your preferred environment manager)</p><pre>conda create -n chatbot python=3.9 <br>conda activate chatbot <br>pip install -r requirements.txt</pre><p>3. Train / Build the Vector Database<br>This step processes PDFs, creates embeddings, and builds the vectorstore:</p><pre>python -m scripts.train</pre><p>4. Start the Backend Server<br>Run FastAPI with Uvicorn from the project root:</p><pre>uvicorn app.app:app --reload</pre><p>5. Open the Chat Interface in Browser<br>Visit <a href="http://localhost:8000/">http://localhost:8000</a> in your browser to access the chat UI.</p><h3>Enabling CORS in FastAPI</h3><p>If you encounter CORS (Cross-Origin Resource Sharing) errors when the frontend tries to communicate with the backend, you might need to add CORS middleware to your FastAPI application (app/app.py). Add the following snippet to your app.py:</p><pre>from fastapi.middleware.cors import CORSMiddleware<br><br># ... (your existing app = FastAPI(...) line)<br><br>app.add_middleware(<br>    CORSMiddleware,<br>    allow_origins=[&quot;http://localhost:8000&quot;, &quot;http://127.0.0.1:8000&quot;, &quot;*&quot;], # Adjust origins as needed<br>    allow_credentials=True,<br>    allow_methods=[&quot;*&quot;],<br>    allow_headers=[&quot;*&quot;],<br>)</pre><p>This configuration allows requests from <a href="http://localhost:8000/">http://localhost:8000</a> and <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000</a> to access your FastAPI backend. The “*” allows all origins, which is convenient for local development but should be restricted in production environments.</p><h3>Conclusion: Empowering the Next Generation of Architects</h3><p>Archie represents a significant step forward in leveraging AI to enhance educational outcomes, particularly in specialized fields like architecture. By addressing the fundamental challenge of information overload and inefficient access to academic materials, Archie empowers Bachelor of Architecture students to engage more deeply with their coursework, fostering a richer and more effective learning experience.</p><p>The successful implementation of this RAG-based chatbot demonstrates the immense potential of intelligent systems to revolutionize traditional educational paradigms. As AI continues to evolve, tools like Archie will become indispensable, not only in architectural education but across various disciplines, paving the way for a future where learning is more accessible, efficient, and profoundly impactful. We invite educators, students, and technologists to explore Archie and join us in shaping the future of academic research and learning.</p><h3>Core Architecture</h3><p>•<strong>Modular RAG Pipeline</strong>: A complete document processing system from PDF ingestion to intelligent querying.</p><p>•<strong>Vector Database</strong>: Persistent storage using Chroma DB for efficient similarity search.</p><p>•<strong>LLM Integration</strong>: Connected Groq’s Llama 3 70B model for high-quality response generation.</p><p>•<strong>Web Interface</strong>: Clean, responsive chat interface for easy student interaction.</p><p>•<strong>Monitoring System</strong>: Integrated LangSmith tracing for conversation tracking and system monitoring.</p><h3>Technical Stack Used</h3><p>•<strong>Document Processing</strong>: PyMuPDF for PDF text extraction, custom cleaning and chunking.</p><p>•<strong>Embeddings</strong>: HuggingFace’s MiniLM for CPU-based semantic embeddings.</p><p>•<strong>Vector Storage</strong>: Chroma DB with persistence for fast retrieval.</p><p>•<strong>Language Model</strong>: Groq API with Llama 3 70B (llama3–70b-8192) for response generation.</p><p>•<strong>Backend</strong>: FastAPI for REST API and static file serving.</p><p>•<strong>Frontend</strong>: Vanilla HTML/CSS/JavaScript for chat interface.</p><p>•<strong>Monitoring</strong>: LangSmith integration for conversation and chain tracing.</p><h3>System Architecture</h3><pre>b-arch-chatbot/<br>├── src/                   # Core processing modules<br>│   ├── loader.py          # PDF document loading<br>│   ├── cleaner.py         # Text preprocessing and cleaning<br>│   ├── splitter.py        # Document chunking with overlap<br>│   ├── embeddings.py      # Semantic embedding generation<br>│   ├── vectorstore.py     # Vector database operations<br>│   └── qa.py              # QA chain with prompt engineering<br>├── app/                   # Web application<br>│   ├── template/<br>│   │   └── index.html     # Student chat interface<br>│   ├── support.py         # Application helper functions<br>│   └── app.py             # FastAPI server with endpoints<br>├── scripts/<br>│   └── train.py           # Training pipeline orchestration<br>├── data/                  # Course PDF materials<br>├── chroma_db/             # Persistent vector database<br>└── requirements.txt       # Project dependencies</pre><h3>Future Enhancements: The Road Ahead for Archie</h3><p>Archie is continuously evolving, with several exciting enhancements planned to further enrich the architectural learning experience:</p><p>•<strong>Multi-semester Support</strong>: Expanding Archie’s knowledge base to cover all Bachelor of Architecture semesters, providing comprehensive support throughout the entire program.</p><p>•<strong>Visual Content Integration</strong>: Adding support for architectural diagrams, drawings, and other visual elements, allowing students to query and understand visual information crucial to their field.</p><p>•<strong>Collaboration Features</strong>: Implementing features that enable student discussion, shared notes, and collaborative learning within the Archie platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kRThWy3FLNsiJs4s5pdUyQ.png" /><figcaption>A detailed view of LangSmith tracing, showing individual calls and their latencies within Archie’s RAG chain, crucial for performance analysis and debugging</figcaption></figure><blockquote>Thanks for reading! Feel free to connect with me on <a href="https://www.linkedin.com/in/muhammedsarfras"><strong>LinkedIn</strong> </a>for any questions, and find the code for this project on my <a href="https://github.com/sarfraspc/barch-rag-chatbot.git"><strong>GitHub repository</strong></a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bec9d650e7f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Credit Card Customer Segmentation Using Clustering]]></title>
            <link>https://medium.com/@sarfrasspc/credit-card-customer-segmentation-using-clustering-13fad741d55d?source=rss-1753880d5870------2</link>
            <guid isPermaLink="false">https://medium.com/p/13fad741d55d</guid>
            <category><![CDATA[dbscan]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[k-means]]></category>
            <category><![CDATA[clustering]]></category>
            <dc:creator><![CDATA[Sarfras]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 12:28:21 GMT</pubDate>
            <atom:updated>2025-08-04T12:28:21.595Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Segmentation" src="https://cdn-images-1.medium.com/max/1024/1*bDi_dfMd7JBqBDsCmwO8rQ.png" /></figure><h3>Abstract</h3><p>This research paper presents a comprehensive analysis of credit card customer segmentation using unsupervised machine learning techniques, specifically focusing on clustering algorithms. Leveraging a dataset containing various credit card usage behaviors and payment patterns, this study aims to identify distinct customer segments to provide actionable insights for targeted marketing strategies, credit risk management, and customer retention campaigns. The methodology involves data preprocessing, dimensionality reduction using Principal Component Analysis (PCA), and clustering with K-Means. An attempt was also made to use DBSCAN, but K-Means proved more effective in yielding interpretable and actionable segments. The findings reveal four unique customer segments: Loyal Spenders, Low-Engaged Users, Installment Spenders, and Cash Advance Seekers, each characterized by specific behavioral traits. These insights can significantly enhance business decision-making by enabling more personalized customer engagement and risk assessment.</p><p>You can find the project at my github:</p><p><a href="https://github.com/sarfraspc/Credit-Card-Customer-Clustering.git">https://github.com/sarfraspc/Credit-Card-Customer-Clustering.git</a></p><h3>1. Introduction</h3><p>In today’s highly competitive financial landscape, understanding customer behavior is paramount for credit card companies to maintain a competitive edge and foster sustainable growth. Customer segmentation, the process of dividing a broad customer base into distinct groups based on shared characteristics, is a powerful analytical tool that enables businesses to tailor their strategies to the specific needs and preferences of different customer cohorts. This approach moves beyond a one-size-fits-all model, allowing for more efficient resource allocation, improved customer satisfaction, and enhanced profitability.</p><p>Traditional customer segmentation often relies on demographic information or simple transactional data. However, with the proliferation of digital transactions and advanced data collection capabilities, there is an increasing opportunity to leverage more sophisticated analytical techniques to uncover deeper, more nuanced patterns in customer behavior. Unsupervised machine learning algorithms, particularly clustering methods, are well-suited for this purpose as they can identify inherent groupings within complex datasets without prior knowledge of the group structures.</p><p>This paper details a project that applies clustering techniques to a real-world credit card usage dataset. The primary objective is to segment credit card customers based on their spending habits, payment frequencies, cash advance usage, and other relevant financial metrics. By identifying these segments, credit card companies can develop highly targeted interventions, such as personalized product offerings, customized marketing campaigns, and proactive risk management strategies. The project explores the application of Principal Component Analysis (PCA) for dimensionality reduction, followed by K-Means clustering for segment identification. The effectiveness and interpretability of the resulting clusters are critically evaluated, and practical business implications are derived. This research contributes to the growing body of literature on data-driven customer relationship management (CRM) in the financial sector, offering a practical framework for implementing advanced analytical solutions.</p><h3>2. Methodology</h3><p>This section outlines the systematic approach undertaken to perform credit card customer segmentation. The methodology encompasses data acquisition, preprocessing, dimensionality reduction, and the application of clustering algorithms.</p><h3>2.1. Data Acquisition and Description</h3><p>The dataset utilized for this study is CC GENERAL.csv, obtained from the user’s repository. It contains 8950 rows and 18 features, each representing a distinct aspect of credit card usage and customer behavior over a period of 12 months. Key features include:</p><p>● <strong>BALANCE</strong>: Monthly average balance amount.</p><p>● <strong>BALANCE_FREQUENCY</strong>: How frequently the balance is updated.</p><p>● <strong>PURCHASES</strong>: Total amount of purchases made.</p><p>● <strong>ONEOFF_PURCHASES</strong>: Total amount of one-off purchases.</p><p>● <strong>INSTALLMENTS_PURCHASES</strong>: Total amount of installment purchases.</p><p>● <strong>CASH_ADVANCE</strong>: Amount of cash advanced by the user.</p><p>● <strong>PURCHASES_FREQUENCY</strong>: How frequently purchases are being made.</p><p>● <strong>ONEOFF_PURCHASES_FREQUENCY</strong>: How frequently one-off purchases are made.</p><p>● <strong>PURCHASES_INSTALLMENTS_FREQUENCY</strong>: How frequently installment purchases are made.</p><p>● <strong>CASH_ADVANCE_FREQUENCY</strong>: How frequently cash advances are being taken.</p><p>● <strong>CASH_ADVANCE_TRX</strong>: Number of cash advance transactions.</p><p>● <strong>PURCHASES_TRX</strong>: Number of purchase transactions.</p><p>● <strong>CREDIT_LIMIT</strong>: Credit limit of the user.</p><p>● <strong>PAYMENTS</strong>: Amount of payments made by the user.</p><p>● <strong>MINIMUM_PAYMENTS</strong>: Minimum amount of payments due.</p><p>● <strong>PRC_FULL_PAYMENT</strong>: Percentage of full payment paid by the user.</p><p>● <strong>TENURE</strong>: Tenure of credit card service for the user.</p><h3>2.2. Data Preprocessing</h3><p>Before applying clustering algorithms, the raw data underwent several preprocessing steps to ensure data quality and suitability for analysis:</p><ol><li><strong>Handling Missing Values</strong>: The dataset contained missing values, particularly in the MINIMUM_PAYMENTS and CREDIT_LIMIT columns. Missing values in MINIMUM_PAYMENTS were imputed using the median of the column, as its distribution was observed to be skewed. For other numerical columns with missing values, the mean imputation strategy was applied. The CUST_ID column was dropped as it serves as a unique identifier and does not contribute to the clustering process.</li><li><strong>Feature Scaling</strong>: To prevent features with larger numerical ranges from dominating the clustering process, all numerical features were scaled using StandardScaler. This transformation standardizes features by removing the mean and scaling to unit variance, ensuring that each feature contributes proportionally to the distance calculations in clustering algorithms.</li></ol><h3>2.2.1. Correlation Heatmap</h3><p>To understand the relationships between different features and identify potential multicollinearity, a correlation heatmap was generated. This visualization helps in assessing the linear relationships between variables after initial data preprocessing and before dimensionality reduction.</p><figure><img alt="Correlation Heatmap" src="https://cdn-images-1.medium.com/max/934/1*6HtWwXpZfPoa9B0nh5uHvw.png" /></figure><h3>2.3. Dimensionality Reduction: Principal Component Analysis (PCA)</h3><p>Given the relatively high dimensionality of the dataset (17 features after CUST_ID removal), Principal Component Analysis (PCA) was employed for dimensionality reduction. PCA is a linear dimensionality reduction technique that transforms the data into a new coordinate system such that the greatest variance by any projection of the data lies on the first coordinate (called the first principal component), the second greatest variance on the second coordinate, and so on. For this project, PCA was used to reduce the data to two principal components. This reduction facilitates visualization of the clusters in a 2D space and can also improve the efficiency and performance of clustering algorithms by removing noise and multicollinearity.</p><h3>2.4. Clustering Algorithms</h3><p>Two distinct clustering algorithms were explored in this project:</p><h4>2.4.1. K-Means Clustering</h4><p>K-Means is a centroid-based, unsupervised learning algorithm that partitions n observations into k clusters, where each observation belongs to the cluster with the nearest mean (centroid). The algorithm iteratively assigns data points to clusters and updates the cluster centroids until convergence. To determine the optimal number of clusters (k), the silhouette score was calculated for a range of k values (2 to 10). Although higher silhouette scores were observed for fewer clusters (e.g., 2 or 3), k=4 was ultimately chosen for K-Means. This decision was driven by the objective of deriving more granular and actionable business insights, even if it meant a slightly lower silhouette score compared to a simpler two or three-cluster solution. The K-Means model was then trained with n_clusters=4 on the PCA-transformed data.</p><h3>2.4.1.1. Silhouette Score Analysis</h3><p>To determine the optimal number of clusters for K-Means, the silhouette score was computed for various values of K. The silhouette score measures how similar an object is to its own cluster (cohesion) compared to other clusters (separation). A higher silhouette score indicates better-defined clusters.</p><figure><img alt="Silhouette Score Analysis" src="https://cdn-images-1.medium.com/max/816/1*ttU9RpYMsRGDoW8DtUFbdQ.png" /></figure><h4>2.4.2. DBSCAN Clustering</h4><p>DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a density-based clustering algorithm that groups together data points that are closely packed together, marking as outliers those points that lie alone in low-density regions. Unlike K-Means, DBSCAN does not require the number of clusters to be specified beforehand and can discover clusters of arbitrary shapes. The key parameters for DBSCAN are eps (the maximum distance between two samples for one to be considered as in the neighborhood of the other) and min_samples (the number of samples in a neighborhood for a point to be considered as a core point). A knee plot was used to estimate the optimal eps value. Despite its theoretical advantages for certain data distributions, DBSCAN did not yield meaningful or interpretable clusters for this dataset, with many points being classified as noise or forming very few, large, and uninformative clusters. Consequently, the insights derived from DBSCAN were not considered suitable for business strategy planning, and the focus remained on the K-Means results.</p><h3>3. Results and Findings</h3><p>This section presents the outcomes of the clustering analysis, focusing on the K-Means algorithm’s ability to segment credit card customers and the characteristics of each identified cluster.</p><h3>3.1. K-Means Clustering Results</h3><p>After applying PCA to reduce the dimensionality of the dataset to two principal components, K-Means clustering was performed. The silhouette score analysis was conducted to evaluate the optimal number of clusters. While 2 or 3 clusters showed slightly higher silhouette scores, a decision was made to proceed with <strong>4 clusters</strong> (k=4). This choice was primarily driven by the desire to achieve more granular and actionable business insights, allowing for a more nuanced understanding of customer behavior patterns. The K-Means model successfully partitioned the credit card customers into four distinct groups.</p><h3>3.2. Cluster Characteristics and Interpretation</h3><p>The four identified customer segments, based on their spending and payment behaviors, are:</p><h4>Cluster 0 — Loyal Spenders</h4><p>● <strong>Characteristics</strong>: This segment is defined by high purchase activity, including both one-off and installment purchases, and a strong tendency towards making full payments. They maintain a moderate balance and have a high credit limit. Their consistent engagement and responsible payment behavior make them highly valuable customers.</p><p>● <strong>Key Metrics (Average)</strong>:</p><p>● Balance: ~3102</p><p>● Credit Limit: ~9512</p><p>● High Purchases and Full Payments</p><h4>Cluster 1 — Low-Engaged Users</h4><p>● <strong>Characteristics</strong>: This segment exhibits very low purchase activity and frequency, indicating minimal engagement with their credit cards for transactions. They tend to carry a high balance relative to their low activity, suggesting they might be utilizing their credit line without active spending. Their low engagement makes them a potential target for reactivation efforts.</p><p>● <strong>Key Metrics (Average)</strong>:</p><p>● Balance: ~4764</p><p>● Credit Limit: ~3120</p><p>● Very Low Purchase Activity and Frequency</p><h4>Cluster 2 — Installment Spenders</h4><p>● <strong>Characteristics</strong>: Customers in this cluster show a higher propensity for installment purchases over one-off transactions. They demonstrate consistent purchasing habits, indicating a preference for structured repayment plans. They carry a moderate balance and have a reasonable credit limit.</p><p>● <strong>Key Metrics (Average)</strong>:</p><p>● Balance: ~4571</p><p>● Credit Limit: ~4233</p><p>● Higher Usage of Installment Purchases</p><h4>Cluster 3 — Cash Advance Seekers</h4><p>● <strong>Characteristics</strong>: This segment is characterized by very high usage of cash advances and a low purchase frequency. They often have a low percentage of full payments, suggesting financial strain or a reliance on cash advances for liquidity. They typically have a moderate balance and a relatively high credit limit, which they utilize for cash withdrawals rather than purchases.</p><p>● <strong>Key Metrics (Average)</strong>:</p><p>● Balance: ~864</p><p>● Credit Limit: ~7480</p><p>● Very High Cash Advance Usage</p><h3>3.2.1. Cluster-wise Feature Comparison</h3><p>To further understand the characteristics of each cluster, a bar plot comparing the average values of key financial features (Balance, Purchases, Cash Advance, and Credit Limit) across the identified clusters was generated. This visualization provides a clear overview of the distinguishing attributes of each segment.</p><figure><img alt="Cluster-wise Feature Comparison" src="https://cdn-images-1.medium.com/max/975/1*0u11bQwOTtKMYtcQcmIJvg.png" /></figure><h3>3.2.2. Customer Count per Cluster</h3><p>Understanding the distribution of customers across the identified segments is crucial for resource allocation and strategic planning. A bar plot showing the number of customers in each cluster provides insights into the size and relative importance of each segment.</p><figure><img alt="Customer Count per Cluster" src="https://cdn-images-1.medium.com/max/975/1*nOlaPABQOcTUp5YhzYjDAA.png" /></figure><h3>3.3. Visual Representation of Clusters</h3><p>The PCA-reduced 2D scatter plot visually confirms the separation of these four customer segments, illustrating how K-Means effectively grouped customers with similar behavioral patterns. While some overlap exists, the distinct centroids and general distribution of points within each cluster support the interpretability of the segmentation.</p><figure><img alt="Visual Representation of Clusters" src="https://cdn-images-1.medium.com/max/902/1*hk1BoslQWo7BURG6CbxDpQ.png" /></figure><h3>3.4. DBSCAN Evaluation</h3><p>DBSCAN was also explored as an alternative clustering method. However, the results from DBSCAN were not considered meaningful for business interpretation. The algorithm tended to classify a significant number of data points as noise and did not form clearly defined or interpretable clusters that could be readily translated into actionable business strategies. This outcome reinforced the decision to focus on the K-Means clustering results for deriving practical insights.</p><h3>4. Discussion and Future Work</h3><h3>4.1. Business Implications and Strategic Recommendations</h3><p>The customer segmentation derived from this study offers significant value for credit card companies seeking to optimize their business strategies. By understanding the distinct behaviors and needs of each segment, companies can implement highly targeted and effective interventions:</p><p>● <strong>Cluster 0 — Loyal Spenders</strong>: These customers are highly engaged and financially responsible. Strategies for this segment should focus on <strong>retention and reward programs</strong>. This includes offering exclusive benefits, higher-tier loyalty points, premium services, and personalized offers that reinforce their positive spending and payment habits. The goal is to deepen their loyalty and encourage continued high-value engagement.</p><p>● <strong>Cluster 1 — Low-Engaged Users</strong>: This segment represents an opportunity for <strong>reactivation and increased engagement</strong>. Companies should investigate the reasons for their low activity, which could range from holding multiple cards to dissatisfaction. Strategies might include targeted reactivation campaigns with attractive introductory offers, personalized communication highlighting underutilized card benefits, or even financial advisory services to help them manage their balances more effectively and encourage active usage.</p><p>● <strong>Cluster 2 — Installment Spenders</strong>: These customers prefer structured payment options. Strategies should focus on <strong>promoting EMI (Equated Monthly Installment) offers and flexible repayment plans</strong>. This segment is receptive to products that allow them to manage larger purchases over time. Tailored marketing for installment-based products, clear communication about repayment terms, and seamless integration of installment options at the point of sale can drive further engagement.</p><p>● <strong>Cluster 3 — Cash Advance Seekers</strong>: This segment poses a higher credit risk due to their reliance on cash advances and lower full payment ratios. Strategies for this group should prioritize <strong>credit risk assessment and education on alternative financial solutions</strong>. Companies might consider offering personal loan alternatives at more favorable rates than cash advances, providing financial literacy resources, or implementing stricter controls on cash advance limits. The aim is to mitigate risk while guiding these customers towards healthier financial behaviors.</p><p>Overall, this segmentation enables a shift from mass marketing to a <strong>precision marketing approach</strong>, leading to improved customer satisfaction, reduced churn, and enhanced profitability through optimized resource allocation.</p><h3>4.2. Limitations and Future Work</h3><p>While this study provides valuable insights, it is subject to certain limitations that also open avenues for future research:</p><p>● <strong>Data Scope</strong>: The analysis was based on a single dataset. Future work could involve integrating additional data sources, such as demographic information, external credit scores, or online browsing behavior, to enrich the customer profiles and potentially uncover more granular segments.</p><p>● <strong>Clustering Algorithm Selection</strong>: Although K-Means proved effective, other advanced clustering techniques (e.g., hierarchical clustering, Gaussian Mixture Models, or self-organizing maps) could be explored to compare their performance and interpretability. Further fine-tuning of DBSCAN parameters or exploring other density-based methods might also yield better results for outlier detection.</p><p>● <strong>Dynamic Segmentation</strong>: Customer behavior is not static. Future research could explore dynamic segmentation models that track changes in customer behavior over time, allowing for real-time adjustments to marketing and risk management strategies. This could involve time-series clustering or incorporating supervised learning models for churn prediction, as suggested in the original project’s future work.</p><p>● <strong>Deployment and Monitoring</strong>: The current project focuses on analysis. A practical extension would involve deploying the segmentation model into a production environment, building interactive dashboards (e.g., using Plotly/Dash) for business users, and establishing a robust monitoring system to track segment performance and model drift.</p><p>● <strong>Causal Inference</strong>: This study identifies correlations and groupings. Future research could delve into causal inference to understand <em>why</em> certain behaviors lead to specific segment memberships, which could inform even more proactive and preventative strategies.</p><h3>5. Conclusion</h3><p>This research successfully demonstrated the application of unsupervised machine learning, specifically K-Means clustering combined with Principal Component Analysis, to segment credit card customers based on their behavioral data. By identifying four distinct customer segments — Loyal Spenders, Low-Engaged Users, Installment Spenders, and Cash Advance Seekers — this study provides a robust framework for credit card companies to move beyond generic marketing and risk management strategies. The detailed characterization of each segment offers actionable insights, enabling the development of personalized product offerings, targeted marketing campaigns, and more effective risk mitigation strategies. While the project successfully achieved its primary objective, the identified limitations and proposed future work highlight the continuous evolution of customer analytics and the potential for even more sophisticated and dynamic segmentation approaches. Ultimately, this research underscores the significant value of data-driven insights in fostering stronger customer relationships and driving sustainable growth in the competitive financial services industry.</p><p><em>If you’d like,</em><a href="https://www.linkedin.com/in/muhammedsarfras"><em> </em><strong><em>follow</em></strong><em> </em><strong><em>me on Linkedin</em></strong><em>!</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13fad741d55d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>