<?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 Anand Singh on Medium]]></title>
        <description><![CDATA[Stories by Anand Singh on Medium]]></description>
        <link>https://medium.com/@singh.anand?source=rss-38a4e65cb961------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LmW_3jLIyGeavECl.jpg</url>
            <title>Stories by Anand Singh on Medium</title>
            <link>https://medium.com/@singh.anand?source=rss-38a4e65cb961------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:29:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@singh.anand/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[RFM Analysis: An Effective Customer Segmentation technique using Python]]></title>
            <link>https://medium.com/capillary-data-science/rfm-analysis-an-effective-customer-segmentation-technique-using-python-58804480d232?source=rss-38a4e65cb961------2</link>
            <guid isPermaLink="false">https://medium.com/p/58804480d232</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[rfm-analysis]]></category>
            <dc:creator><![CDATA[Anand Singh]]></dc:creator>
            <pubDate>Thu, 28 May 2020 12:46:13 GMT</pubDate>
            <atom:updated>2020-05-28T12:46:13.790Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQLOdau5-Jv4qGS1R3AiAA.png" /></figure><h4>RFM analysis enables personalized marketing, increases engagement, and allows you to create specific, relevant offers to the right groups of customers.</h4><p>This post explores the benefits of RFM analysis, shares step by step instructions on how to perform RFM analysis in Python, and finally showcases the created RFM customer segments to maximize ROI.</p><h4>What is RFM Analysis?</h4><p>RFM analysis is a data-driven customer behavior segmentation technique where RFM stands for recency, frequency, and monetary value.</p><p>The idea is to segment customers based on when their last purchase was(Recency), how often they’ve purchased in the past(Frequency), and how much they spent(Monetary). All three of these measures have proven to be effective predictors of a customer’s willingness to engage in marketing messages and offers.</p><h4>How to do a RFM Analysis in Python?</h4><p>We will follow 5 steps to do RFM analysis, which will be explained in subsequent steps taking the data from an apparel retail store.</p><p>Importing useful Python libraries:</p><pre>import numpy as np<br>import pandas as pd<br>import datetime as dt<br>from datetime import datetime<br>import datetime as dt<br>from datetime import datetime<br>%matplotlib inline<br>import matplotlib.pyplot as plt<br>import matplotlib.ticker as mticker<br>import seaborn as sns<br>import squarify<br>from sklearn.cluster import KMeans</pre><h4>Step 1: Data Import</h4><pre>rfm_single_view=pd.read_csv(&#39;RFM Data.csv&#39;)<br>rfm_single_view.head()</pre><p>The sample records of the imported data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*UuJFKzoxpA1GQ3DmxJ2p9w.png" /></figure><h4>Step 2: Data Preprocessing</h4><p>It includes two steps:</p><p>I- <strong>Dropping records with empty values</strong></p><pre>rfm_single_view.dropna(axis=0,inplace=True)</pre><p>II- <strong>Removing Top 1% record for analysis </strong>(as they might skew the analysis), these customers can be studied separately, if they are outliers or genuine bulk buyers.</p><pre><em>#Creating Individual tables of RFM after removing top 1%</em></pre><pre>recency_cleaned = rfm_single_view[rfm_single_view[&#39;Recency&#39;]&lt;rfm_single_view[&#39;Recency&#39;].quantile(0.99)]<br>frequency_cleaned = rfm_single_view[rfm_single_view[&#39;Visits&#39;]&lt;rfm_single_view[&#39;Visits&#39;].quantile(0.99)]<br>monetary_cleaned = rfm_single_view[rfm_single_view[&#39;Spend Per Visit&#39;]&lt;rfm_single_view[&#39;Spend Per Visit&#39;].quantile(0.99)]</pre><pre><em>#Merging three dataframes to create rfm table</em></pre><pre>rfm_table=pd.merge(pd.merge(recency_cleaned[[&#39;Cap User ID&#39;,&#39;Recency&#39;,&#39;Visits&#39;,&#39;Spend Per Visit&#39;]],frequency_cleaned[[&#39;Cap User ID&#39;]],on=&#39;Cap User ID&#39;),monetary_cleaned[[&#39;Cap User ID&#39;]],on=&#39;Cap User ID&#39;)</pre><p>The sample records of the data after preprocessing, Visits become Frequency whereas spend per visit has been taken as the Monetary field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*i8uKAyvZCB_V4fssVrjZ2w.png" /></figure><h4>Step 3: Deciding RFM Clusters</h4><p>First, we decide on the optimum no of clusters. Here, we get 3 as optimum no of clusters which means there will be three cuts for recency, frequency, and monetary each. This is done using the K-means clustering algorithm.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8aff36792a0a6aa3b8c24ca338e179b5/href">https://medium.com/media/8aff36792a0a6aa3b8c24ca338e179b5/href</a></iframe><p><strong>Data visualizations after deciding RFM clusters</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDTnv7xd4oX_tKHRjLZO6g.png" /><figcaption><strong>Distribution of RFM with Customer counts</strong></figcaption></figure><h4>Step 4: Finding a Combined RFM Score</h4><p>Now the individual RFM scores ranging from 0 to 2 as we decided on 3 clusters are summed up to get a combined RFM score against each customer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*lD4fSGyR5t-N-_t78bMobQ.png" /><figcaption><strong>The sample records of the data after combined RFM Score</strong></figcaption></figure><h4>Step 5: Generating Unique Customer Segments based on RFM Score</h4><pre>1.Core - Your Best Customers</pre><pre>RFM Score: 222</pre><pre>Who They Are: Highly engaged customers who have bought the most recent, the most often, and generated the most revenue.</pre><pre>2.Loyal - Your Most Loyal Customers</pre><pre>RFM Score: X2X</pre><pre>Who They Are: Customers who buy the most often from your store.</pre><pre>3.Whales - Your Highest Paying Customers</pre><pre>RFM Score: XX2</pre><pre>Who They Are: Customers who have generated the most revenue for your store.</pre><pre>4.Rookies - Your Newest Customers</pre><pre>RFM Score: 20X</pre><pre>Who They Are: First time buyers on your site.</pre><pre>5.Slipping - Once Loyal, Now Gone</pre><pre>RFM Score: 00X</pre><pre>Who They Are: Great past customers who haven&#39;t bought in awhile.</pre><pre>6.Regular - The customers having common behaviour across these metrics.</pre><pre>RFM Score: Remaining Scores</pre><pre>Who They Are: Customer who have average metrics across each RFM scores.</pre><p>Snapshot of some of the KPI’s against each customer segment clearly shows the best groups are the<strong> Core and Loyal customer segments.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*s_BXtbkMN3x4-O38Vzrsnw.png" /></figure><p>Let’s create a nice visualization for our data.</p><pre>#Create our RFM Segment plot and resize it.<br>fig = plt.gcf()<br>ax = fig.add_subplot()<br>fig.set_size_inches(12, 8)<br>squarify.plot(sizes=rfm_single_view_after_tags_v1[&#39;CustomerCount&#39;], <br>              label=[&#39;Core&#39;,<br>                     &#39;Loyal&#39;,<br>                     &#39;Regular&#39;,<br>                     &#39;Rookies&#39;,<br>                     &#39;Slipping&#39;, <br>                     &#39;Whales&#39;], alpha=0.8 )<br>plt.title(&quot;RFM Segments&quot;,fontsize=18,fontweight=&quot;bold&quot;)<br>plt.axis(&#39;off&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*4c1s1NOVpakh7OWZyLJAWA.png" /><figcaption>TreeMap visualization of RFM Customer Segments</figcaption></figure><h4>Conclusion</h4><p>RFM technique is a proven marketing model that helps retailers and e-commerce businesses maximize the return on their marketing investments.</p><p>The above-generated RFM customer segments can be easily used to identify high ROI segments and engage them with personalized offers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58804480d232" width="1" height="1" alt=""><hr><p><a href="https://medium.com/capillary-data-science/rfm-analysis-an-effective-customer-segmentation-technique-using-python-58804480d232">RFM Analysis: An Effective Customer Segmentation technique using Python</a> was originally published in <a href="https://medium.com/capillary-data-science">Capillary Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Shopping Mission:An Effectual method for FMCGs to solve their operational challenges]]></title>
            <link>https://medium.com/capillary-data-science/understanding-shopping-mission-an-effectual-method-for-fmcgs-to-solve-their-operational-challenges-472e5867982b?source=rss-38a4e65cb961------2</link>
            <guid isPermaLink="false">https://medium.com/p/472e5867982b</guid>
            <category><![CDATA[grocery-shopping]]></category>
            <category><![CDATA[predictive-modeling]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[hypermarket]]></category>
            <category><![CDATA[fmcg]]></category>
            <dc:creator><![CDATA[Anand Singh]]></dc:creator>
            <pubDate>Wed, 12 Feb 2020 08:04:28 GMT</pubDate>
            <atom:updated>2020-02-12T08:04:28.594Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Shopping Journey:An Effectual method for FMCGs to solve their operational challenges</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FUAFPWwN89MzMLfP7Ctg6w.jpeg" /></figure><p>Every customer enters a store with a goal or mission in mind. They visit stores to satisfy multiple need states, such as getting a bottle of milk and a box of cereals for their daily breakfast or purchasing ingredients for a healthy lunch meal the same day or to stock up their monthly groceries.</p><p>This difference in customer shopping behavior can be studied by shopping mission analysis which enables innovative methods to be implemented to communicate with the shopper and influence purchase decisions prior to their next visit.</p><p><strong>Objective:</strong> To understand the shopping journey of customer to drive new marketing and operational opportunities for a leading retail chain of hypermarkets and grocery stores.</p><p><strong>Approach: </strong>Shopping Journey is classified based on two qualitative inputs: Basket mission and Dominant department in a basket.</p><p><strong>Basket mission</strong> refers to the study of significant purpose for which the customer visited the store, for eg: some may be daily shoppers who purchase few items for their daily needs,some might come only for grocery shopping or to stock up their monthly groceries.</p><p><strong>Dominant department: </strong>The products in a departmental store are categorized and placed as per their department names like Food&amp;Groceries, Meat, Beverages etc. In a transaction,if majority of the products belong from a particular dept then that it can be ascertain that the customer came to purchase majorly from that dept.</p><p><strong>Steps involved in this study:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*rbA3cvMrEfQu4OtvTerqlw.png" /></figure><p><strong>Findings:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*vcId7bq69dIg0H-a1DHWWA.png" /></figure><p><strong>Conclusions: </strong>Investigating the popular basket missions and dominant department for a customer, Category Managers and Retail owners can easily make better in-store strategic and operational decisions.</p><p><strong>What next?</strong></p><p>The steps are to build a predictive model based on the findings of shopping journey analysis.The products which a customer is going to purchase in his next visit can be predicted from the model. These details can be easily used for personalized campaigns to enhance the customer experience as well as to up sell and cross sell the products.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=472e5867982b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/capillary-data-science/understanding-shopping-mission-an-effectual-method-for-fmcgs-to-solve-their-operational-challenges-472e5867982b">Understanding Shopping Mission:An Effectual method for FMCGs to solve their operational challenges</a> was originally published in <a href="https://medium.com/capillary-data-science">Capillary Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Market Basket Analysis:Best associated games using Apriori algorithm]]></title>
            <link>https://medium.com/capillary-data-science/market-basket-analysis-best-associated-games-using-apriori-algorithm-20b97cef01a?source=rss-38a4e65cb961------2</link>
            <guid isPermaLink="false">https://medium.com/p/20b97cef01a</guid>
            <category><![CDATA[apriori-algorithm]]></category>
            <category><![CDATA[games-industry]]></category>
            <category><![CDATA[association-rule]]></category>
            <category><![CDATA[recommendation-engine]]></category>
            <category><![CDATA[market-basket-analysis]]></category>
            <dc:creator><![CDATA[Anand Singh]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 06:21:38 GMT</pubDate>
            <atom:updated>2020-01-26T17:14:20.666Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Market Basket Analysis: Finding associated games using </strong>Apriori algorithm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*HorkvFUxcJv9xFMHOGNYpQ.jpeg" /><figcaption><em>Image Credits- Mashable</em></figcaption></figure><p>In a gaming store, if a customer plays a game, what is the probability that he/she will play another game and which are the most frequent sets of games played among the customers?</p><p>This is a common business problem and answers for this can be given by Market basket analysis also referred to as Affinity Analysis. It is one of the fundamental techniques used by large retailers to uncover the association between items. In other words, it allows retailers to identify the relationship between items that are more frequently bought together.</p><p><strong>Objective: </strong>To see which games are frequently played together for leading retail-based games and the entertainment industry.</p><p><strong>Challenges:</strong> Use of Apriori algorithm generates numerous uninteresting item sets which lead to generating various rules which are of completely of no use also in the cases of big data sets computation time might be high.</p><p><strong>Approach: </strong>There are three major components of the Apriori algorithm: Support, Confidence and Lift.</p><p>Support(B) refers to the default popularity of an item and can be calculated by finding the number of transactions containing a particular item divided by the total number of transactions.</p><p>Confidence(A-&gt;B) refers to the likelihood that item B is also bought if item A is bought. It can be calculated by finding the number of transactions where A and B are bought together, divided by the total number of transactions where A is bought.</p><p>Lift(A -&gt; B) refers to the increase in the ratio of sale of B when A is sold.</p><p>For instance, if out of 1000 total transactions,100 transactions contain kids rides(KR), 200 transactions contain attraction games(AG) and 75 transactions where kids rides and attraction games are played together then,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*jiho25n53s8DD-D9GVuAug.png" /><figcaption>Mathematical representation of support, confidence, and lift</figcaption></figure><p>A Lift of 1 means there is no association between products A and B. Lift of greater than 1 means products A and B are more likely to be bought together. Lift of less than 1 refers to the case where two products are unlikely to be bought together.</p><p>In our instance, kids rides and attraction games occur together 3.75 times <em>more</em> than random, so we conclude that there exists a positive relationship between them.</p><p><strong>Implementation in Python</strong></p><p>Apriori class from the apyori library is used for implementation in python. The Apriori class requires some parameter values to work. The first parameter is the list that we want to extract rules from. The second parameter is the min support parameter. This parameter is used to select the items with support values greater than the value specified by the parameter.</p><p>Next, the min confidence parameter filters those rules that have confidence greater than the confidence threshold specified by the parameter. Similarly, the min lift parameter specifies the minimum lift value for the shortlisted rules.</p><p>Finally, the min length parameter specifies the minimum number of items that we want in our rules. The minimum confidence for the rules used was 20% or 0.2. The value for lift as 3 and finally min length as 2 since we want at least two products in our rules.</p><p>The Python code used for market basket analysis is given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e8c747c4754f21e0b365aab2347cf27/href">https://medium.com/media/4e8c747c4754f21e0b365aab2347cf27/href</a></iframe><p><strong>Insights</strong></p><p>More than 1.5K associations of different games with support value&gt;0.2 and lift &gt;3 was obtained. Based on these best-associated products these games can be placed together in the store. We can also make the players of one game the target prospects for another best-associated game or group of games.</p><p><strong>What next?</strong></p><p>The steps are to build a recommendation engine based on the findings of apriori algorithm. Recommendation engines are data filtering tools that make use of algorithms and data to recommend the most relevant items to a particular user which in turn helps in cross-selling and up-selling.</p><p>—By Anand Singh</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20b97cef01a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/capillary-data-science/market-basket-analysis-best-associated-games-using-apriori-algorithm-20b97cef01a">Market Basket Analysis:Best associated games using Apriori algorithm</a> was originally published in <a href="https://medium.com/capillary-data-science">Capillary Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>