<?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 Rahul Khandelwal on Medium]]></title>
        <description><![CDATA[Stories by Rahul Khandelwal on Medium]]></description>
        <link>https://medium.com/@rahulkhandelwal?source=rss-42b04d527af5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*apj5s68Utwi7XraApe-CTQ.jpeg</url>
            <title>Stories by Rahul Khandelwal on Medium</title>
            <link>https://medium.com/@rahulkhandelwal?source=rss-42b04d527af5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:33:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rahulkhandelwal/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[Customer Segmentation in Online Retail]]></title>
            <link>https://medium.com/data-science/customer-segmentation-in-online-retail-1fc707a6f9e6?source=rss-42b04d527af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fc707a6f9e6</guid>
            <category><![CDATA[cohort-analysis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[marketing-strategies]]></category>
            <dc:creator><![CDATA[Rahul Khandelwal]]></dc:creator>
            <pubDate>Fri, 01 Jan 2021 18:58:33 GMT</pubDate>
            <atom:updated>2021-01-03T07:14:41.468Z</atom:updated>
            <content:encoded><![CDATA[<h4>A detailed step-by-step explanation on performing Customer Segmentation in Online Retail dataset using python, focussing on cohort analysis, understanding purchase patterns using RFM analysis and clustering.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nTXZlcnSOjmDUHB5" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, I am going to write about how to carry out customer segmentation and other related analysis on online retail data using python.</p><p><em>This is going to get a bit long, so feel free to go through some sections at a time and come back again.</em></p><p>Before going into the definition of customer segmentation, let us take a look at how online retail works and how the associated data would look like. When a person goes into a retail store and purchases a few items, the following basic data points should be generated:</p><ol><li>Customer Name/Customer ID</li><li>Address/Contact number of the customer (Demographic information)</li><li>Invoice number</li><li>Product name and product code</li><li>Quantity</li><li>Unit Price</li><li>Date and time of the transaction</li><li>Coupon Code (if applicable)</li><li>Discount amount (if applicable)</li></ol><p>Now that we have developed a basic idea about how retail data looks like, let us think about how a company should think in order to make effective marketing policies.</p><p>For a small company, the customer base is usually quite small and individually targetable. But, as a business grows in size, it will not be possible for the business to have an intuition about each and every customer. At such a stage, human judgments about which customers to pursue will not work and the business will have to use a data-driven approach to build a proper strategy.</p><p>For a medium to large size retail store, it is also imperative that they invest not only in acquiring new customers but also in customer retention. Many businesses get most of their revenue from their ‘best’ or high-valued customers. Since the resources that a company has, are limited, it is crucial to find these customers and target them. It is equally important to find the customers who are dormant/are at high risk of churning to address their concerns. For this purpose, companies use the technique of customer segmentation.</p><p>One axiom frequently used in business and economics is the Pareto principle. This can be applied to understanding the revenue stream of a company as well.</p><blockquote>As per the <strong>Pareto</strong> <strong>Principle</strong>, 80% of outcomes result from 20% of all the causes of any given event.</blockquote><p>In business terms, we can say that 20% of customers contribute 80% share of the total revenue of a company. That’s why finding this set of people is important. I will explain the importance of customer segmentation in a detailed manner later in this article itself.</p><p>Let us now try to understand what customer segmentation is and why is it such an effective tool for developing an effective strategy. Then, we will work on how to perform segmentation.</p><h3>Understanding Customer Segmentation</h3><p>Customer segmentation is the process of separating customers into groups on the basis of their shared behavior or other attributes. The groups should be homogeneous within themselves and should also be heterogeneous to each other. The overall aim of this process is to identify high-value customer base i.e. customers that have the highest growth potential or are the most profitable.</p><p>Insights from customer segmentation are used to develop tailor-made marketing campaigns and for designing overall marketing strategy and planning.</p><p>A key consideration for a company would be whether or not to segment its customers and how to do the process of segmentation. This would depend upon the company philosophy and the type of product or services it offers. The type of segmentation criterion followed would create a big difference in the way the business operates and formulates its strategy. This is elucidated below.</p><ol><li><strong>Zero segments: </strong><em>&lt;Undifferentiated approach&gt;</em><strong> </strong>This means that the company is treating all of its customers in a similar manner. In other words, there is no differentiated strategy and all of the customer base is being reached out by a single mass marketing campaign.</li><li><strong>One segment: </strong><em>&lt;Focussed approach&gt; </em>This means that the company is targeting a particular group or niche of customers in a tightly defined target market.</li><li><strong>Two or more segments: </strong><em>&lt;Differentiated approach&gt; </em>This means that the company is targeting 2 or more groups within its customer base and is making specific marketing strategies for each segment.</li><li><strong>Thousands of segments: </strong><em>&lt;Hyper segmentation approach&gt; </em>This means that the company is treating each customer as unique and is making a customized offer for each one of them.</li></ol><p>Once the company has identified its customer base and the number of segments it aims to focus upon, it needs to decide the factors on whose basis it will decide to segment its customers.</p><blockquote><em>Factors for segmentation for a business to business marketing company:</em></blockquote><ol><li><em>Industry</em></li><li><em>Number of employees</em></li><li><em>Location</em></li><li><em>Market cap/Company size</em></li><li><em>Age of the company</em></li></ol><blockquote><em>Factors for segmentation for a business to consumer marketing company:</em></blockquote><ol><li><em>Demographic</em>: Age, Gender, Education, Ethnicity, Income, Employment, hobbies, etc.</li><li><em>Recency, Frequency, and Monetary:</em> Time period of the last transaction, the frequency with which the customer transacts, and the total monetary value of trade.</li><li><em>Behavioral:</em> Previous purchasing behavior, brand preferences, life events, etc.</li><li><em>Psychographic</em>: Beliefs, personality, lifestyle, personal interest, motivation, priorities, etc.</li><li><em>Geographical</em>: Country, zip code, climatic conditions, urban/rural areal differentiation, accessibility to markets, etc.</li></ol><h3>Why segment your customers?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bGEGL49OVsK5y8s1" /><figcaption>Photo by <a href="https://unsplash.com/@ivanbajalovic?utm_source=medium&amp;utm_medium=referral">Ivan Bajalovic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Customer segmentation has a lot of potential benefits. It helps a company to develop an effective strategy for targeting its customers. This has a direct impact on the entire product development cycle, the budget management practices, and the plan for delivering targeted promotional content to customers. For example, a company can make a high-end product, a budget product, or a cheap alternative product, depending upon whether the product is intended for its most high yield customers, frequent purchasers or for the low-value customer segment. It may also fine-tune the features of the product for fulfilling the specific needs of its customers.</p><p>Customer segmentation can also help a company to understand how its customers are alike, what is important to them, and what is not. Often such information can be used to develop personalized relevant content for different customer bases. Many studies have found that customers appreciate such individual attention and are more likely to respond and buy the product. They also come to respect the brand and feel connected with it. This is likely to give the company a big advantage over its competitors. In a world where everyone has hundreds of emails, push notifications, messages, and ads dropping into their content stream, no one has time for irrelevant content.</p><p>Finally, this technique can also be used by companies to test the pricing of their different products, improve customer service, and upsell and cross-sell other products or services.</p><h3>How to segment your customers?</h3><p>To start with customer segmentation, a company needs to have a clear vision and a goal in mind. The following steps can be undertaken to find segments in the customer base on a broad level.</p><ol><li><em>Analyze the existing customer pool: </em>Understanding the geographical distribution, customer preferences/beliefs, reviewing website search page analytics, etc.</li><li><em>Develop an understanding of each customer: </em>Mapping each customer to a set of preferences to understand and predict their behavior: the products, services, and content they would be interested in.</li><li><em>Define segment opportunities: </em>Once the segments have been defined, there should a proper business understanding of each segment and its challenges and opportunities. The entire company’s marketing strategy can be branched out to cater to different niches of customers.</li><li><em>Research the segment: </em>After cementing the definition and business relevance of different customer segments, a company needs to understand how to modify its products or services to better cater to them. For example, it may decide to provide higher discounts to some customers compared to others to expand its active customer base.</li><li><em>Tweak strategy:</em> Experiment with new strategies and understand the impact of time and economy on the purchasing behavior of customers in different segments. And then the process should be repeated for refining the strategy as much as possible.</li></ol><h3>Getting started</h3><p>In the following analysis, I am going to use the Online Retail Data Set, which was obtained from the UCI Machine Learning repository. The data contains information about transnational transactions for a UK-based and registered non-store online retail. The link to the data can be found <a href="https://archive.ics.uci.edu/ml/datasets/online+retail">here</a>.</p><h3>Data Snapshot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bO4excsy_BDnsA_jFYAJcQ.png" /><figcaption>Fig: data sample</figcaption></figure><h3>Data Attributes</h3><ol><li><strong>InvoiceNo</strong>: Invoice number. Nominal, a 6-digit integral number uniquely assigned to each transaction. If this code starts with letter ‘c’, it indicates a cancellation.</li><li><strong>StockCode</strong>: Product (item) code. Nominal, a 5-digit integral number uniquely assigned to each distinct product.</li><li><strong>Description</strong>: Product (item) name. Nominal.</li><li><strong>Quantity</strong>: The quantities of each product (item) per transaction. Numeric.</li><li><strong>InvoiceDate</strong>: Invoice Date and time. Numeric, the day and time when each transaction was generated.</li><li><strong>UnitPrice</strong>: Unit price. Numeric, Product price per unit in sterling.</li><li><strong>CustomerID</strong>: Customer number. Nominal, a 5-digit integral number uniquely assigned to each customer.</li><li><strong>Country</strong>: Country name. Nominal, the name of the country where each customer resides.</li></ol><h3>Exploring the data</h3><p>Before diving into insights from the data, duplicate entries were removed from the data. The data contained 5268 duplicate entries (about ~1%).</p><p>Let us now look at the total number of products, transactions, and customers in the data, which correspond to the total unique stock codes, invoice number, and customer IDs present in the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*6chMiu7gWyESlLd80hOP9Q.png" /><figcaption>Fig: number of products, transactions and customers in the data</figcaption></figure><p>Thus, for 4070 products, there are 25900 transactions in the data. This means that each product is likely to have multiple transactions in the data. There are almost as many products as customers in the data as well.</p><p>Since the data, taken from the UCI Machine Learning repository describes the data to based on transactions for a UK-based and registered non-store online retail, let us check the percentage of orders from each country in the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*5e0ooT7Wchpb__Pukqo1zw.png" /><figcaption>Fig: %Orders from each country</figcaption></figure><p>The above graph shows the percentage of orders from the top 10 countries, sorted by the number of orders. This shows that more than 90% of orders are coming from United Kingdom and no other country even makes up 3% of the orders in the data.</p><p>Therefore, for the purpose of this analysis, I will be taking data corresponding to orders from the United Kingdom. This subset will be made in one of the next steps and will be mentioned as required.</p><p>Let us now look at the number of canceled orders in the data. As per the data, if the invoice number code starts with the letter ‘c’, it indicates a canceled order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*DEy_O-tF2WNAwbF5QO6mAg.png" /></figure><p>A flag column was created to indicate whether the order corresponds to a canceled order. All the canceled orders contain negative quantities (since it is a cancellation) and hence were removed from the data.</p><p>Finally, I ran a check to confirm whether there were any orders with negative quantities in the orders that were not canceled. There were 1336 such cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LiXE_SJlbXXTXoiLFasu7A.png" /><figcaption>Fig: checking for orders with negative quantities in the data</figcaption></figure><p>As we can see from the above figure, these cases are the ones where CustomerID values are NaNs. These cases were also removed from the data.</p><p>Now, the data was filtered to contain orders only from the United Kingdom and finally, the structure of the data was checked by calling the .info() method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*5PB9EWzvdRBilkbk-OA0BQ.png" /><figcaption>Fig: .info() method output on the finalized clean data</figcaption></figure><p>There were no nulls in any of the columns in the data, and there were a total of 349227 rows in the data. Let us now check the number of products, transactions, and customers in our cleaned data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*9Vb0TkSuk765j1Xm4TmU7Q.png" /></figure><h3>Understanding Cohort Analysis</h3><p>Let us now try to understand cohort analysis so that we can perform it on our data.</p><p>But, what is a <strong>Cohort</strong>?</p><p>A <em>cohort</em> is a set of users who share similar characteristics over time. Cohort analysis groups the users into mutually exclusive groups and their behavior is measured over time.</p><p>It can provide information about the product and customer lifecycle.</p><p>There are three types of cohort analysis:</p><ol><li><strong>Time cohorts:</strong> It groups customers by their purchase behavior over time.</li><li><strong>Behavior cohorts:</strong> It groups customers by the product or service they signed up for.</li><li><strong>Size cohorts:</strong> Refers to various sizes of customers who purchase the company’s products or services. This categorization can be based on the amount of spending in some period of time.</li></ol><p>Understanding the needs of various cohorts can help a company design custom-made services or products for particular segments.</p><p>In the following analysis, we will create Time cohorts and look at customers who remain active during particular cohorts over a period of time that they transact over.</p><h3>Diving into Cohort Analysis</h3><p>Checking the date range of our data, we find that it ranges from the start date: 2010–12–01 to the end date: 2011–12–09. Next, a column called InvoiceMonth was created to indicate the month of the transaction by taking the first date of the month of InvoiceDate for each transaction. Then, information about the first month of the transaction was extracted, grouped by the CustomerID.</p><pre>def get_month(x):<br>    return dt.datetime(x.year, x.month, 1)</pre><pre>cohort_data[&#39;InvoiceMonth&#39;] = cohort_data[&#39;InvoiceDate&#39;].apply(get_month)<br>grouping = cohort_data.groupby(&#39;CustomerID&#39;)[&#39;InvoiceMonth&#39;]<br>cohort_data[&#39;CohortMonth&#39;] = grouping.transform(&#39;min&#39;)<br>cohort_data.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dnUgvtIQWnLhLfK1CS5Ugg.png" /><figcaption>Fig: creating the InvoiceMonth and CohortMonth column</figcaption></figure><p>Next, we need to find the difference between the InvoiceMonth and the CohortMonth column in terms of the number of months. The following code was used:</p><pre>def get_date_int(df, column):    <br>    year = df[column].dt.year    <br>    month = df[column].dt.month    <br>    day = df[column].dt.day<br>    return year, month, day</pre><pre>invoice_year, invoice_month, _ = get_date_int(cohort_data, &#39;InvoiceMonth&#39;) <br>cohort_year, cohort_month, _ = get_date_int(cohort_data, &#39;CohortMonth&#39;)<br>years_diff = invoice_year - cohort_year<br>months_diff = invoice_month - cohort_month<br>cohort_data[&#39;CohortIndex&#39;] = years_diff * 12 + months_diff<br>cohort_data.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZtksiB3flU3t9eUmUUgyw.png" /><figcaption>Fig: creating the CohortIndex column</figcaption></figure><p>After obtaining the above information, we obtain the cohort analysis matrix by grouping the data by CohortMonth and CohortIndex and aggregating on the CustomerID column by applying the pd.Series.nunique function. Here are the cohort counts obtained:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kEeJuHVu58y-00T81hVTMA.png" /><figcaption>Fig: cohort counts analysis</figcaption></figure><p>What does the above table tell us?</p><p>Consider CohortMonth 2010–12–01: For CohortIndex 0, this tells us that 815 unique customers made transactions during CohortMonth 2010–12–01. For CohortIndex 1, this tells that there are 289 customers out of 815 who made their first transaction during CohortMonth 2010–12–01 and they also made transactions during the next month. That is, they remained active.</p><p>For CohortIndex 2, this tells that there are 263 customers out of 815 who made their first transaction during CohortMonth 2010–12–01 and they also made transactions during the second-next month. And so on for higher CohortIndices.</p><p>Let us now calculate the <em>Retention Rate</em>. It is defined as the percentage of active customers out of total customers. Since the number of active customers in each cohort corresponds to the CohortIndex 0 values, we take the first column of the data as the cohort sizes.</p><pre>cohort_sizes = cohort_counts.iloc[:,0]</pre><pre># Divide all values in the cohort_counts table by cohort_sizes<br>retention = cohort_counts.divide(cohort_sizes, axis=0)</pre><pre># Check the retention table<br>retention.round(3) * 100</pre><pre># Drawing a heatmap<br>plt.figure(figsize=(10, 8))<br>plt.title(&#39;Retention rates&#39;)<br>sns.heatmap(data = retention,annot = True,fmt = &#39;.0%&#39;,vmin = 0.0,vmax = 0.5,cmap = &#39;BuGn&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fi6cEdPf3QOscJffcM-fow.png" /><figcaption>Fig: retention heatmap</figcaption></figure><p>From the above retention rate heatmap, we can see that there is an average retention of ~35% for the CohortMonth 2010–12–01, with the highest retention rate occurring after 11 months (50%). For all the other CohortMonths, the average retention rates are around 18–25%. Only this percentage of users are making transactions again in the given CohortIndex ranges.</p><p>From this analysis, a company can understand and create strategies to increase customer retention by providing more attractive discounts or by doing more effective marketing, etc.</p><h3>RFM Segmentation</h3><p>RFM stands for Recency, Frequency, and Monetary. RFM analysis is a commonly used technique to generate and assign a score to each customer based on how recent their last transaction was (Recency), how many transactions they have made in the last year (Frequency), and what the monetary value of their transaction was (Monetary).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4y5aMagjR5VxDcLR" /><figcaption>Photo by <a href="https://unsplash.com/@austindistel?utm_source=medium&amp;utm_medium=referral">Austin Distel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>RFM analysis helps to answer the following questions: Who was our most recent customer? How many times has he purchased items from our shop? And what is the total value of his trade? All this information can be critical to understanding how good or bad a customer is to the company.</p><p>After getting the RFM values, a common practice is to create ‘quartiles’ on each of the metrics and assigning the required order. For example, suppose that we divide each metric into 4 cuts. For the recency metric, the highest value, 4, will be assigned to the customers with the least recency value (since they are the most recent customers). For the frequency and monetary metric, the highest value, 4, will be assigned to the customers with the Top 25% frequency and monetary values, respectively. After dividing the metrics into quartiles, we can collate the metrics into a single column (like a string of characters {<em>like ‘213’</em>}) to create classes of RFM values for our customers. We can divide the RFM metrics into lesser or more cuts depending on our requirements.</p><p>Let’s get down to RFM analysis on our data now.</p><p>Firstly, we need to create a column to get the monetary value of each transaction. This can be done by multiplying the UnitValue column with the Quantity column. Let’s call this the TotalSum. Calling the .describe() method on this column, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*5HRx5IC_F4zNCdzy9Cju9g.png" /><figcaption>Fig: .describe() method on TotalSum column</figcaption></figure><p>This gives us an idea of how consumer spending is distributed in our data. We can see that the mean value is 20.86 and the standard deviation is 328.40. But the maximum value is 168,469. This is a very large value. Therefore, the TotalSum values in the Top 25% of our data increase very rapidly from 17.85 to 168,469.</p><p>Now, for RFM analysis, we need to define a ‘snapshot date’, which is the day on which we are conducting this analysis. Here, I have taken the snapshot date as the highest date in the data + 1 (The next day after the date till which the data was updated). This is equal to the date 2011–12–10. (YYYY-MM-DD)</p><p>Next, we confine the data to a period of one year to limit the recency value to a maximum of 365 and aggregate the data on a customer level and calculate the RFM metrics for each customer.</p><pre># Aggregate data on a customer level<br>data = data_rfm.groupby([&#39;CustomerID&#39;],as_index=False).agg({<br>&#39;InvoiceDate&#39;: lambda x: (snapshot_date - x.max()).days,<br>&#39;InvoiceNo&#39;: &#39;count&#39;,<br>&#39;TotalSum&#39;: &#39;sum&#39;}).rename(columns = {&#39;InvoiceDate&#39;: &#39;Recency&#39;,                                                                     &#39;InvoiceNo&#39;: &#39;Frequency&#39;,&#39;TotalSum&#39;: &#39;MonetaryValue&#39;})</pre><p>As the next step, we create quartiles on this data as described above and collate these scores into an RFM_Segment column. The RFM_Score is calculated by summing up the RFM quartile metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHjRRlN9yAKu5B-cDiMfuQ.png" /><figcaption>Fig: RFM scores and quartiles.</figcaption></figure><p>We are now in a position to analyze our results. The RFM_Score values will range from 3 (1+1+1) to 12 (4+4+4). So, we can group by the RFM scores and check the mean values of recency, frequency, and monetary corresponding to each score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*p1gdr2OsSJ7nt9hHlBQgTA.png" /><figcaption>Fig: mean values of recency, frequency, and monetary for different RFM score values</figcaption></figure><p>As expected, customers with the lowest RFM scores have the highest recency value and the lowest frequency and monetary value, and the vice-versa is true as well. Finally, we can create segments within this score range of RFM_Score 3–12, by manually creating categories in our data: Customers with an RFM_Score greater than or equal to 9 can be put in the ‘Top’ category. Similarly, customers with an RFM_Score between 5 to 9 can be put in the ‘Middle’ category, and the rest can be put in the ‘Low’ category. Let us call our categories the ‘General_Segment’. Analyzing the mean values of recency, frequency, and monetary, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*O3IKs8KoOvZnzUYHkOxDnA.png" /><figcaption>Fig: mean values of recency, frequency, and monetary for different categories</figcaption></figure><p>Note that we had to create the logic for distributing customers into the ‘Top’, ‘Middle’, and ‘Low’ category manually. In many scenarios, this would be okay. But, if we want to properly find out segments on our RFM values, we can use a clustering algorithm like K-means.</p><p>In the next section, we are going to preprocess the data for K-means clustering.</p><h3>Preprocessing data for K-means clustering</h3><p>K-means is a well-known clustering algorithm that is frequently used for unsupervised learning tasks. I am not going into details regarding how the algorithm works here, as there are plenty of resources online.</p><p>For our purpose, we need to understand that the algorithm makes certain assumptions about the data. Therefore, we need to preprocess the data so that it can meet the key assumptions of the algorithm, which are:</p><ol><li>The variables should be distributed symmetrically</li><li>Variables should have similar average values</li><li>Variables should have similar standard deviation values</li></ol><p>Let us check the first assumption by building histograms of Recency, Frequency, and MonetaryValue variables using the seaborn library:</p><pre># Checking the distribution of Recency, Frequency and MonetaryValue variables.<br>plt.figure(figsize=(12,10))</pre><pre># Plot distribution of var1<br>plt.subplot(3, 1, 1); sns.distplot(data[&#39;Recency&#39;])</pre><pre># Plot distribution of var2<br>plt.subplot(3, 1, 2); sns.distplot(data[&#39;Frequency&#39;])</pre><pre># Plot distribution of var3<br>plt.subplot(3, 1, 3); sns.distplot(data[&#39;MonetaryValue&#39;])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Ewg0Dp8azryi8mjbTaTJA.png" /><figcaption>Fig: distribution of recency, frequency, and monetary value metrics</figcaption></figure><p>From the above figure, all the variables do not have a symmetrical distribution. All of them are skewed to the right. To remove the skewness, we can try the following transformations:</p><p>1. Log transformations<br>2. Box-Cox transformations<br>3. Cube root transformations</p><p>I will use the Log transformation here. Since the log transformation cannot be used for negative values, we need to remove them, if they exist. One common practice one can use here is to add a constant value to get a positive value and this is generally taken as the absolute of the least negative value of the variable to each observation. However, in our data, we do not have any negative values since we are dealing with customer transactions dataset.</p><p>Checking the distribution of the recency, frequency, and monetary variables, we get this by called the .describe() method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*WzvnB4brkyRCJZVVJXXrHg.png" /><figcaption>Fig: .describe() method on RFM metrics</figcaption></figure><p>From the above description, we can see that the minimum MonetaryValue for a particular customerID is 0. This transaction therefore does not make any sense and needs to be removed. Checking the occurrence:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bzl9g2H_vjkalz8BfWCa_A.png" /><figcaption>Fig: The CustomerID with 0 monetary value</figcaption></figure><p>This customer was removed from the data. We also see that we do not get a constant mean and standard deviation values. To check that, we will standardize the data. Applying the log transformation on the data first and passing it through the StandardScaler() method from the sklearn library, we obtained the preprocessed data. Checking the distribution of RFM variables for symmetrical distribution now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oTPhh9F0BIGqylcEAA0NXA.png" /><figcaption>Fig: distribution of recency, frequency, and monetary value metrics on preprocessed data</figcaption></figure><p>As we can see from the above plots, skewness has been removed from the data.</p><h3>Clustering with K-means</h3><p>In this section, we will build multiple clusters upon our normalized RFM data and will try to find out the optimal number of clusters in our data using the elbow method. Attached below is the code for this purpose. For each cluster, I have also extracted information about the average of the intracluster sum of squares through which we can build the elbow plot to find the desired number of clusters in our data.</p><pre>from sklearn.cluster import KMeans</pre><pre>sse = {}</pre><pre># Fit KMeans and calculate SSE for each k<br>for k in range(1, 21):<br>  <br>    # Initialize KMeans with k clusters<br>    kmeans = KMeans(n_clusters=k, random_state=1)<br>    <br>    # Fit KMeans on the normalized dataset<br>    kmeans.fit(data_norm)<br>    <br>    # Assign sum of squared distances to k element of dictionary<br>    sse[k] = kmeans.inertia_</pre><pre># Plotting the elbow plot<br>plt.figure(figsize=(12,8))<br>plt.title(&#39;The Elbow Method&#39;)<br>plt.xlabel(&#39;k&#39;); <br>plt.ylabel(&#39;Sum of squared errors&#39;)<br>sns.pointplot(x=list(sse.keys()), y=list(sse.values()))<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJzjS1HoxtswzY4KZauJ_w.png" /><figcaption>Fig: elbow plot</figcaption></figure><p>One can also use silhouette analysis to find the optimal number of clusters. You can read more about it in my previous article <a href="https://towardsdatascience.com/evaluating-goodness-of-clustering-for-unsupervised-learning-case-ccebcfd1d4f1">here</a>. For the purpose of this analysis, I have only used the elbow plot method.</p><p>From the above plot, we can see that the optimal number of clusters is <strong>3</strong> or <strong>4</strong>.</p><p>Let us now compare the clustering performance. For this purpose, I calculated the mean values of recency, frequency, and monetary metrics to get the following result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVKOdii3GT0sONXZNjjIDg.png" /><figcaption>Fig: comparing cluster performance on our data (between 3 and 4 clusters)</figcaption></figure><p>From the above table, we can compare the distribution of mean values of recency, frequency, and monetary metrics across 3 and 4 cluster data. It seems that we get a more detailed distribution of our customer base using k=4. However, this may not be a very visually appealing method to extract insights.</p><p>Another commonly used method to compare the cluster segments is Snakeplots. They are commonly used in marketing research to understand customer perceptions.</p><p>Let us build a snake plot for our data with 4 clusters below.</p><p>Before building snake plots, we need to melt the data into along format so RFM values and metric names are stored in 1 column each. Link to understanding the pd.melt method: <a href="https://pandas.pydata.org/docs/reference/api/pandas.melt.html">link</a>.</p><pre># Melt the data into along format so RFM values and metric names are stored in 1 column each<br>data_melt = pd.melt(data_norm_k4.reset_index(),<br>                    id_vars=[&#39;CustomerID&#39;, &#39;Cluster&#39;],<br>                    value_vars=[&#39;Recency&#39;, &#39;Frequency&#39;,&#39;MonetaryValue&#39;],<br>                    var_name=&#39;Attribute&#39;,<br>                    value_name=&#39;Value&#39;)</pre><pre># Building the snakeplot<br>plt.title(&#39;Snake plot of standardized variables&#39;)<br>sns.lineplot(x=&quot;Attribute&quot;, y=&quot;Value&quot;, hue=&#39;Cluster&#39;, data=data_melt)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*ppar85dDpvb2GX1cP3qvRw.png" /><figcaption>Fig: Snake plot for data with 4 clusters</figcaption></figure><p>From the above snake plot, we can see the distribution of recency, frequency, and monetary metric values across the four clusters. The four clusters seem to be separate from each other, which indicates a good heterogeneous mix of clusters.</p><p>As the final step in this analysis, we can extract this information now for each customer that can be used to map the customer with thei relative importance by the company:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*Y1YC5QIU8GoiAJbJDet50g.png" /><figcaption>Fig: RFM values for each customer along with the cluster assignment</figcaption></figure><h3>Final Thoughts</h3><p>From the above analysis, we can see that there should be 4 clusters in our data. To understand what these 4 clusters mean in a business scenario, we should look back the table comparing the clustering performance of 3 and 4 clusters for the mean values of recency, frequency, and monetary metric. On this basis, let us label the clusters as ‘New customers’, ‘Lost customers’, ‘Best customers’, and ‘At risk customers’.</p><p>Below is the table giving the RFM interpretation of each segment and the points that a company is recommended to keep in mind while designing the marketing strategy for that segment of customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QcPMMBEl-iAHqQ7UoW4CxQ.png" /><figcaption>Fig: Business interpretation of clusters and recommended action on each segment</figcaption></figure><h3>Further analysis</h3><ul><li>Addition of new variables like Tenure: The number of days since the first transaction by each customer. This will tell us how long each customer has been with the system.</li><li>Conducting deeper segmentation on customers based on their geographical location, and demographic and psychographic factors.</li><li>Incorporating data from Google Analytics account of the business. Google Analytics is a great resource to track many important business metrics such as Customer Life time value, Traffic source/medium, PageViews per visit, Bounce rate of the company’s website, etc.</li></ul><p><em>If you liked the article and found it informative, please share it to spread knowledge :). Thank you!</em></p><p>Link to the Github repository for this project: <a href="https://github.com/rahulkhandelwal396/Customer-Segmentation/blob/main/Customer%20Segmentation.ipynb"><em>link</em></a></p><h4><em>References</em>:</h4><p>[1] <a href="https://www.shopify.in/encyclopedia/customer-segmentation">https://www.shopify.in/encyclopedia/customer-segmentation</a></p><p>[2] <a href="https://learn.datacamp.com/courses/customer-segmentation-in-python">https://learn.datacamp.com/courses/customer-segmentation-in-python</a></p><p>[3] <a href="https://looker.com/blog/creating-actionable-customer-segmentation-models">https://looker.com/blog/creating-actionable-customer-segmentation-models</a></p><p>[4] <a href="https://www.business2community.com/customer-experience/4-types-of-customer-segmentation-all-marketers-should-know-02120397">https://www.business2community.com/customer-experience/4-types-of-customer-segmentation-all-marketers-should-know-02120397</a></p><p>[5] <a href="https://www.intercom.com/blog/customer-segmentation/">https://www.intercom.com/blog/customer-segmentation/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fc707a6f9e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/customer-segmentation-in-online-retail-1fc707a6f9e6">Customer Segmentation in Online Retail</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluating goodness of clustering for unsupervised learning case]]></title>
            <link>https://medium.com/data-science/evaluating-goodness-of-clustering-for-unsupervised-learning-case-ccebcfd1d4f1?source=rss-42b04d527af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccebcfd1d4f1</guid>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[silhouette-score]]></category>
            <category><![CDATA[elbow-method]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Rahul Khandelwal]]></dc:creator>
            <pubDate>Sat, 05 Dec 2020 07:24:42 GMT</pubDate>
            <atom:updated>2023-09-23T03:42:40.906Z</atom:updated>
            <content:encoded><![CDATA[<h3>Evaluating goodness of clustering for unsupervised learning</h3><h4>A detailed explanation of assessing the quality of clustering performance and finding the optimal value of the number of clusters using the K-means algorithm.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yPuX0eFNpgCHrFmg" /><figcaption>Photo by <a href="https://unsplash.com/@franki?utm_source=medium&amp;utm_medium=referral">Franki Chamaki</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Clustering is a commonly used unsupervised machine learning technique that allows us to find patterns within data without having an explicit target variable. In simple terms, grouping unlabelled data is called Clustering. Clustering analysis uses similarity metrics to group data points that are close to each other and separate the ones which are farther apart. It is a widely used technique for market segmentation, pattern recognition, and image processing.</p><p>While there are many metrics, like classification accuracy, which one can use to evaluate a labeled data problem, for a clustering problem we have to understand how well the data is grouped into different clusters by the algorithm. This is different since we do not have the true labels of the data.</p><p>In this article, I am going to apply the K-means clustering algorithm to retail data to separate the data into different clusters. I will also try to assess the performance of the algorithm by inferring the optimal value of the number of clusters from multiple evaluation techniques.</p><h3>The Data</h3><p>The data for this analysis was obtained from the UCI Machine Learning Repository website. It contains data regarding the clients of a wholesale distributor.</p><p>The data for the following analysis can be found <a href="http://archive.ics.uci.edu/ml/datasets/Wholesale+customers">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*R5znY4kgHlKNpqGPfVI1Ow.png" /><figcaption>Fig: Sample Data</figcaption></figure><h3>Fields</h3><ul><li>Channel: Customer’s channel (Hotel/Restaurant/Cafe) or Retail channel. (Nominal)</li><li>Region: Customer’s region. (Nominal)</li><li>Fresh: Annual spending on fresh products in monetary units (m.u.) (Continuous)</li><li>Milk: Annual spending on milk products in monetary units (m.u.) (Continuous)</li><li>Grocery: Annual spending on grocery products in monetary units (m.u.) (Continuous)</li><li>Frozen: Annual spending on frozen products in monetary units (m.u.) (Continuous)</li><li>Detergents_Paper: Annual spending on detergents and paper products in monetary units (m.u.) (Continuous)</li><li>Delicassen: Annual spending on delicatessen products in monetary units (m.u.) (Continuous)</li></ul><h3>Exploring the data</h3><p>Calling the .info() method on the dataframe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*dOZEzYvF_tuem1X2p9AK-g.png" /><figcaption>Fig: .info() method output</figcaption></figure><p>We can see that there are no null values in the data and all the features have datatype int.</p><p>Summary of the numerical columns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-QaxW1TDFCBX5EEo-nkTrQ.png" /><figcaption>Fig: statistical summary of numerical columns</figcaption></figure><p>Correlation plot between these variables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*nEvkysoUx74wFTyYMScGjg.png" /><figcaption>Fig: correlation plot between numerical variables</figcaption></figure><p>The above plot tells us that there is a high correlation between the following pairs of variables:</p><ul><li>Grocery and Detergents_Paper</li><li>Grocery and Milk</li><li>Milk and Detergents_Paper</li></ul><p>For this analysis, since we are only looking at clustering, I will not be removing any of the features here. In most cases, however, one of the above pairs of a variable should be dropped to remove multicollinearity in the data for building ML models on the data.</p><p>From the data, we can see that the categorical columns are [‘Channel’,‘Region’]. Since these variables are nominal, they were converted to indicator variables using pandas.get_dummies method.</p><p>Countplots for the categorical columns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ywXI2vR6prJNrVkBNdlI2A.png" /><figcaption>Fig: countplots of categorical variables</figcaption></figure><p>From the above plot, we can see that there is a fair distribution between these variables.</p><p>Let us now focus on the algorithm and evaluating its performance.</p><h3><strong>K- Means</strong></h3><p>K- means is one of the most popular and the simplest clustering algorithms available today which can be used to solve both supervised and unsupervised machine learning problems.</p><p>In a nutshell, here’s how it works: The algorithm starts with a value of K. It then assigns each point to a cluster closest to it. It then calculates the cluster centroid and then re-assigns each point to the new cluster. The cluster centroids are calculated again and re-assignment happens again. This process is repeated till the error reaches a particular threshold value. There are many online resources one can use to dive deeper into understanding the working of this algorithm.</p><p>Let us now talk about how to evaluate the performance of the algorithm:</p><blockquote>For a supervised learning problem:</blockquote><p>If the target variable is known, the following methods can be used to evaluate the performance of the algorithm:</p><ol><li>Confusion Matrix</li></ol><p>2. Precision</p><p>3. Recall</p><p>4. F1 Score</p><p>5. ROC curve: AUC</p><p>6. Overall accuracy</p><p>To read more about these metrics, refer to the article <a href="https://towardsdatascience.com/evaluation-metrics-for-classification-problems-in-machine-learning-d9f9c7313190">here</a>. This is beyond the scope of this article.</p><blockquote>For an unsupervised learning problem:</blockquote><p>However, if the target variable is not known, we do not know the true labels of the clusters of data. In such a case, whenever an algorithm tries to find clusters within the data, it tries to classify each point to cluster such that each cluster is as homogenous as possible and different clusters are as far as possible from each other. To evaluate the performance of the algorithm in such a case, we make use of these methods:</p><h3><strong>1. Elbow method</strong></h3><p>The Elbow method uses a plot between the average of the sum of the intra-cluster sum of squares of distances between the respective cluster centroids and the cluster points and the number of clusters (or K). To determine the optimal number of clusters, we have to select such a value of K at the ‘elbow’ point or the point after which the error starts decreasing linearly. The curve can either go up or down, but if there is a strong inflection point, it is a good indication that the underlying model fits best at that point with regard to the number of clusters.</p><p>The elbow method does not work well if the data is not very clustered intrinsically.</p><p>By default, the distortion score is computed. Other metrics can also be used, such as <em>silhouette score</em>, which will be discussed below and <em>calinski_harabasz</em><strong> </strong>score. The <em>calinski_harabasz </em>score computes the ratio of dispersion between and within clusters and therefore incorporates information about how far apart the clusters are from each other as well. Higher the score, the better the performance.</p><p>Taking the sum of squared distances as the metric, we get the following elbow plot for our data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*peBzypq9MglVYjRjWT_C_g.png" /><figcaption>Fig: elbow plot (sum_of_squared_distances)</figcaption></figure><p>Here, we cannot see a very distinct elbow point. One might infer the optimal value of K to be 5, 6, or 7.</p><p>Taking calinski_harbasz score as the metric, we get the following elbow plot for our data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*Ldlj9QCEl74Rov3nEwVQVQ.png" /><figcaption>Fig: elbow plot using calinski_harbasz score</figcaption></figure><p>From this plot, we can see that the optimal value of K is 6. The plot is drawn using Yellowbrick’s KElbowVisualizer method.</p><p>While calinski_harbasz score is fast to compute, it is generally higher for convex clusters than other types of clusters such as density clusters.</p><blockquote>Convex and non-convex clusters (Additional info)</blockquote><p>In Euclidean space, an object is convex if, for every pair of points within the object, every point on the straight line segment that joins them is also within the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*3mWj-JF0SkSNg38HR86QUg.png" /><figcaption>Fig: a convex set. <a href="https://en.wikipedia.org/wiki/Convex_set">Source</a></figcaption></figure><blockquote>K-Means clustering performs well only for a convex set of clusters and not for non-convex sets.</blockquote><p>In simple terms, the K-means clustering algorithm performs well when clusters are spherical. If they have a complicated geometrical shape, it does a poor job classifying data points into their respective clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*M9djW8GmjrEmCpE9Y3qXqw.png" /><figcaption>Fig: a non-convex set. <a href="https://en.wikipedia.org/wiki/Convex_set">Source</a></figcaption></figure><h3><strong>2. Silhouette score</strong></h3><p>The silhouette score also tells us how good the clustering algorithm performs. The below formula tells us how to calculate the silhouette score for one data point. The overall silhouette score is calculated by taking the mean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*bbRua0bIXUfALDy9ZWBqYQ.png" /><figcaption>Fig: silhouette score formula (Source: gdcoder.com)</figcaption></figure><p>Breaking this down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*z80NXEGn_XudzyJVTgfaMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*CgQypyEl9GMru_Se-nO7EA.png" /></figure><p><em>b(i)</em> represents the average distance of point i to all the points in the nearest cluster.</p><p><em>a(i)</em> represents the average distance of point i to all the other points in its own cluster.</p><p>The silhouette score varies between +1 and -1, +1 being the best score and -1 being the worst. 0 indicates an overlapping cluster while negative values indicate that the point is assigned to the wrong cluster.</p><p>Silhouette analysis on our data: (The red line marks the silhouette score)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gj4ZFwdb94bXwavGxobPYg.png" /><figcaption>Fig: silhouette plot for n_clusters = 2</figcaption></figure><p>Silhouette plots for n_clusters 3 to 8:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5uQKF4TtR442nuDIHZwVdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IyCVZIsWuQcT2Dn-SspCTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BY9wYY7Wv_JBDQiVTpIqDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rTeyFjV7wAUi370HfwldmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m9F40tPlibqekmEzLF5KBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pbPipwuGafvV8N9Hz63s7A.png" /></figure><p>From all the above plots, we can see that seeing the visualization of clustered data tells us that data is not present in a very clustered manner in the data already, which is making it difficult for the algorithm to select the optimal number of clusters. Perhaps this is why we could not get a clear K value from the dispersion elbow plot.</p><p>To summarize the above plots, this is a plot calculating the silhouette_score for different values of n_clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*va0Ht_tDgQCcKrvb0RFYvA.png" /></figure><p>From this plot, we can see that we get the highest value of the silhouette score is 0.482 for K=6.</p><h3>Summary</h3><p>In the above article, we performed clustering on our data and evaluated the quality of our clustering fit using the elbow method and silhouette analysis. From both the methods, we obtained a value of K=6 as the optimal number of clusters for separating our data. Since the data is not very separable in the feature space, the elbow method utilizing dispersion as the metric did not give a clear inflection point. But, using the calinski_harbasz score and silhouette analysis, we were able to find the optimal value of K.</p><p>Here is the link to the GitHub repository of this project: <a href="https://github.com/rahulkhandelwal396/kmeans-evaluation">link</a>.</p><p>Further reading:</p><ul><li><a href="https://en.wikipedia.org/wiki/Davies%E2%80%93Bouldin_index">Davies-Bouldin Index</a></li><li><a href="https://simple.wikipedia.org/wiki/Dunn_index">Dunn index</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccebcfd1d4f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/evaluating-goodness-of-clustering-for-unsupervised-learning-case-ccebcfd1d4f1">Evaluating goodness of clustering for unsupervised learning case</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Telco Churn Prediction]]></title>
            <link>https://medium.com/swlh/telco-churn-prediction-ad95a3a67454?source=rss-42b04d527af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad95a3a67454</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[knn]]></category>
            <category><![CDATA[churn-prediction]]></category>
            <category><![CDATA[random-forest]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Rahul Khandelwal]]></dc:creator>
            <pubDate>Fri, 20 Nov 2020 14:41:52 GMT</pubDate>
            <atom:updated>2020-11-25T14:40:09.347Z</atom:updated>
            <content:encoded><![CDATA[<h3>Predicting Churn for Telecom Companies</h3><p><em>The Telecommunications industry regularly faces a lot of competition from various service providers, which generally provide services at very similar pricing points and services. In such a competitive stage, it is extremely essential for a telco company to analyze the rate at which their customers stop using their services to be able to understand how to better engage with those customers and understand their grievances.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nu4zIoAtWAE2c1UWWdVKuA.jpeg" /><figcaption>Source: <a href="https://mspark.com/direct-mail-works-for-telecom-providers/">https://mspark.com/direct-mail-works-for-telecom-providers/</a></figcaption></figure><p>Customer churn is a major problem that many companies face today. This affects not only short term but also long term revenues of companies. It is one of the most important metrics about customer retention for a company.</p><p>This project is about predicting whether a customer will change telecommunications provider, something known as “<em>churning</em>”. The dataset was taken from a Kaggle challenge.</p><blockquote>Customer churn is the percentage of customers that stopped using your company’s product or service during a certain time frame.</blockquote><h3>Why Is Customer Churn Rate Important?</h3><p>To learn why this is the case, we need to understand that it costs more to acquire new customers than it does to retain existing customers.</p><p>CAC is defined as the net cost of sales and marketing required to aquire a new customer. Regardless of the efforts a company puts in terms of effectiveness of it’s marketing campaign or providing more and more services to it’s customers at a cheap cost, there would be some customers who would inevitably tend to churn out of their system. There can be several reasons for this, like, a customer may tend to sway towards a competitor offering similar services at a lower cost or they may be providing tailor-made plans to customer which would be better suited to their needs.</p><p>For acquiring every new customer, the cost associated with this (CAC) tends to be far more than that associated with keeping a customer into the system of a company. Moreover, by keeping overall customer management costs low, a company can focus it’s time and effort into improving the features of their product and the quality of their services, which will ultimately improve the health of the company financially.</p><p><em>File descriptions</em></p><ul><li>train.csv — the training set — Contains 4250 lines with 20 columns. 3652 samples (85.93%) belong to class churn=no and 598 samples (14.07%) belong to class churn=yes</li><li>test.csv — the test set — Contains 750 lines with 20 columns: the index of each sample and the 19 features (missing the target variable “churn”).</li></ul><h3>Data Sample</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a6ZXCWD6Afkx0_hYrrJb7g.png" /><figcaption>Fig: Sample Data</figcaption></figure><h3>Data fields</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azJZu32k19C5qb5Fv1GQpA.png" /><figcaption>Fig: Table describing all the columns in the data</figcaption></figure><h3>Project Flow</h3><ol><li>Importing and investigating the data</li><li>Data Pre-processing and EDA</li><li>Train-Test Split</li><li>Random Forest Model</li><li>Logistic Regression Model</li><li>K-Nearest Neighbors Model</li><li>Model Comparison</li><li>Results</li></ol><h3>1. Importing and investigating the data</h3><p>After importing both the training and testing data, we check information about the train set by calling the .info() method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BOL-Y0L4zCuh1ejV.png" /><figcaption>Fig: Data description</figcaption></figure><p>As we can see, the data does not contain any null values. There are two types of numerical data in the dataframe — int64 and float64. The categorical data is mentioned against object datatype.</p><h3>2. Data Pre-processing and EDA</h3><p>Checking the distribution of the target variable first:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/0*-fjbTUrsXgZkXa_c.png" /><figcaption>Fig: Distribution of target variable</figcaption></figure><p>Almost ~86% cases belong to churn=0 case while ~14% cases belong to churn=1 case.</p><ul><li>Categorical columns:</li></ul><p>Used select_dtypes method to take up columns with datatype = object.</p><p>[‘state’, ‘area_code’, ‘international_plan’, ‘voice_mail_plan’]</p><blockquote>EDA on categorical variables</blockquote><p>Countplots were built using seaborn’s countplot method to understand distribution of categorical variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oz-OTQrsV5kbsx73EOKkRw.png" /><figcaption>Fig: countplot for categorical variables</figcaption></figure><p>Let’s find out the correlation between categorical variables and the target variable ‘churn’. Skipping the state variable bacause it contains too many states as visible above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*T-Poc5fxOwL4I8lIAy0lwg.png" /><figcaption>Fig: correlation plot for categorical variables</figcaption></figure><p>As we can see from the above plot, variables <em>international_plan</em> and <em>voice_mail_plan</em> show a high correlation with the target variable.</p><p>Preprocessing on categorical columns -&gt; One Hot Encoding</p><pre><em># Defining the categorical columns:</em><br><br>categoricalColumns = [&#39;state&#39;,&#39;area_code&#39;,&#39;international_plan&#39;,&#39;voice_mail_plan&#39;]<br>categorical_ix = df_train.select_dtypes(include=[&#39;object&#39;, &#39;bool&#39;]).columns<br><br>print(&quot;Categorical columns:&quot;)<br>print(categoricalColumns)<br><br>onehotCategorical = preprocessing.OneHotEncoder(handle_unknown = &#39;ignore&#39;,categories=&#39;auto&#39;,sparse = <strong>False</strong>)<br><br>categorical_transformer = Pipeline(steps = [(&#39;onehot&#39;, onehotCategorical)])</pre><ul><li>Numerical columns:</li></ul><p>Used select_dtypes method to take up columns with datatype = int64|float64.</p><p>[‘account_length’, ‘number_vmail_messages’, ‘total_day_minutes’, ‘total_day_calls’, ‘total_day_charge’, ‘total_eve_minutes’, ‘total_eve_calls’, ‘total_eve_charge’, ‘total_night_minutes’, ‘total_night_calls’, ‘total_night_charge’, ‘total_intl_minutes’, ‘total_intl_calls’, ‘total_intl_charge’, ‘number_customer_service_calls’]</p><p>Preprocessing on numerical columns -&gt; Standard Scaling</p><blockquote>EDA on numerical columns</blockquote><p>This is a correlation matrix plot to understand distribution of correlation between the numerical variables. As we can see from the plot, most of the variables are not too much related with each other, except for the varaibles that account for total minutes of day, evening, night and international calls with their charges, something which is to be expected of the nature of data we are dealing with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*35Fo0a-6IT1tJrteMUGf5A.png" /><figcaption>Fig: correlation matrix for numerical variables</figcaption></figure><p>Let’s find out the correlation between numerical variables and the target variable ‘churn’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*59Zis2YU10FKdbxzP5Ckjw.png" /><figcaption>Fig: correlation plot for numerical variables</figcaption></figure><p>As we can see from the above plot, variables <em>number_customer_service_calls, total_day_minutes </em>and<em> total_day_charge</em> show a high correlation with the target variable.</p><pre><em># Defining the numerical columns:</em><br><br>numericalColumns = df_train.select_dtypes(include=[np.float,np.int]).columns<br><br>print(&quot;Numerical columns: &quot;)<br>print(numericalColumns)<br><br>scaler_numerical = StandardScaler()<br><br>numerical_transformer = Pipeline(steps = [(&#39;scale&#39;,scaler_numerical)])</pre><p>A Pipeline method was created to facilitate data preprocessing.</p><pre><em># Preprocessing</em><br><br>preproc = ColumnTransformer(transformers=[(&#39;cat&#39;,categorical_transformer,categoricalColumns),<br>                          (&#39;num&#39;,numerical_transformer,numericalColumns)],<br>                                          remainder = &quot;passthrough&quot;)<br><br>df_churn_pd = preproc.fit_transform(df_train)<br>print(df_churn_pd)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZJ-kErvdMS7uG-pN7J-MA.png" /><figcaption>Fig: Pre-processed train set data</figcaption></figure><p>Target column ‘churn’ was label-encoded.</p><h3>3. Train-Test Split</h3><p>Data was split into training and testing sets using sklearn.model_selection library.</p><p>Train_size = 66.67% Test_size = 33.33%</p><h3>4. Random Forest Model</h3><p>Random forest is ensemble machine learning algorithm which builds a combination of several decision trees. The decision trees themselves are weak learners but when they are ensembled by the random forest algorithm, the predictive power of the algorithm is increased significantly and the model also generalizes better on unseen data. The trees are built by taking samples of data, with replacement from the original data. Each tree is grown to it’s maximum depth level and there is no pruning in the trees.</p><h4>Advantages of Random Forest Model:</h4><ul><li>It has a very high accuracy generally compared to the conventional machine learning algorithms.</li><li>It does not overfit on training data.</li><li>It can be run on large datasets and is also able to handle thousands of input variables without needing explicit variable selection methods.</li><li>It is can solve both regression and classification problems.</li><li>It can be used to select important features which play a major role in determining the target variable by use of the feature importance plot.</li><li>It can handle missing data by estimation of the missing values and the algorithm performs robustly even when a large proportion of data points are missing.</li><li>It performs well in case of unbalanced class prediction problem.</li></ul><h4>Disadvantages of Random Forest Model:</h4><ul><li>The Random Forest model is difficult to interpret.</li><li>For large datasets with too many features, the random forest model consumes a lot of memory.</li><li>The algorithm produces wild predictions for test observations never seen before by the training data. For example, for a training data containing two variables x and y with the range of x variable from 50 to 80: If the test data has x = 150, the algorithm would give an unreliable prediction.</li><li>It takes tong time to run as it builds a large number of trees.</li></ul><p>Accuracy of the model: 93.0%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*ZuN2f12nysGzNyfORU0uxA.png" /><figcaption>Fig: confusion matrix for random forest model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*v5EAmrPJKzFxUI618tmMYw.png" /><figcaption>Fig: classification report</figcaption></figure><h3>Feature Importance</h3><p>There are two types of feature importances that can be calculated in case of random forest model. Impurity based feature importance and permutation based feature importance.</p><p>As we have one hot encoded the categorical columns, we have increased the number of features in our data from 19 to 79, and this will give a distorted understanding of feature importances of the variables.</p><p>Furthermore, impurity-based importances are computed on training set statistics and therefore do not reflect the ability of feature to be useful to make predictions that generalize to the test set.</p><p>Hence, we will use permutation_importance method.</p><p>The permutation_importance method will be permuting categorical columns before they get one-hot encoded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*0JsFlP2mmq5JaRS6tY-I-Q.png" /><figcaption>Fig: Feature Importances boxplot</figcaption></figure><p>From the above plot, we can see that the variables international_plan, total_day_minutes, number_customer_service_calls and voice_mail_plan have high importance in building the model. In other words, these variables are affecting the target outcome.</p><p>To see this, let us build plots to understand their relationship with the target variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*j9inT0B7B36JB-D73CYW-Q.png" /><figcaption>Fig: Bivariate analysis</figcaption></figure><p>As we can see from the above plots:</p><p>For international_plan variable -&gt; churn rate is higher in cases which are having international plan as compared to the ones who have not subscribed to the international plan.</p><p>For the rest of the variables, the difference is much more subtle.</p><h3>5. Logistic Regression Model</h3><p>Logistic regression is a classification algorithm which belongs to the family of generalized linear models. It is a used when the response variable is binary (1 or 0). The model returns the probability of occurrence of the target variable which is converted to 0 or 1 prediction using a particular threshold.</p><p>The model basically applies sigmoid function to the output of a linear regression model.</p><h4>Advantages of Logistic Regression Model:</h4><ul><li>Logistic Regression is one of the simplest and easy to interpret machine learning algorithms.</li><li>It does not require very high computational power or memory.</li><li>It is less prone to over-fitting in a low dimensional dataset having a sufficient number of training examples.</li><li>It makes no assumptions about the distribution of the classes in the data.</li><li>The predicted parameters (trained weights) give inference about the importance of each feature. The direction of association i.e. positive or negative is also given. This can be used to understand the relationship between various features.</li><li>This algorithm can easily be extended to multi-class classification using a SoftMax function, which is known as Multinomial Logistic Regression.</li></ul><h4>Disadvantages of Logistic Regression Model:</h4><ul><li>Logistic Regression requires that the independent variable should be linearly related to the log odds (log(p/(1-p)).</li><li>The algorithm is only able to build linear decision boundaries to separate data of different classes. This means that problems involving formation of non-linear boundaries cannot be solved by this algorithm.</li><li>Adding too many features to the model which may suffer from multicollinearity can degrade the predictive power of the model.</li><li>More powerful algorithms like Neural Networks, SVM, Random Forest can easily outperform this algorithm.</li><li>The algorithm is sensitive to outliers and as such when the data values deviate from expected ranges, this can lead to erratic classification of the data point which may affect the overall accuracy and interpretability of the model as it would also affect the Sensitivity and Specificity of the results of the algorithm.</li></ul><p>Accuracy of the model: 86.0%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*PkloW0lKSWt7CIqWsZVxHw.png" /><figcaption>Fig: confusion matrix for logistic regression model</figcaption></figure><h3>6. K-Nearest Neighbors Model</h3><p>KNN is a simple and easy to interpret supervised machine learning algorithm that can be used to solve both classification and regression problems. The algorithm works by trying to determine the class of a data point by looking at the class of it’s K nearest neighbors. It assumes that data points which are close to each other belong to the same class and uses a distance metric like Euclidean distance or other metric to find the distance between data points. KNN is a non-linear classifier, so it will work with data that cannot be simply classified with the help of linear classifiers.</p><p>However, it does not perform well if the dataset is too large or has too many features. The model also requires feature scaling as features of different scales can give a distorted picture of distance between data points. It is also sensitive to missing data and presence of outliers.</p><p>Accuracy of the model: 88.0%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*hufwPzuE5NJuM6zRhij5Gg.png" /><figcaption>Fig: confusion matrix for KNN model</figcaption></figure><h3>7. Model Comparison</h3><p>Table with accuracy in percentage of all the models:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/0*FkZtC9O-bAZtpCvg.png" /><figcaption>Fig: Model accuracy comparison (%)</figcaption></figure><h3>8. Results</h3><p>Graphical comparison:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/0*0WQ-k6GRFyNkKhie.png" /><figcaption>Fig: bar plot of percentage accuracy</figcaption></figure><p>As we can see, Random Forest model performed the best out of all the models used here.</p><p>Now, we finally use the random forest model to make predictions on test.csv file and match the ‘id’ column to the predictions. I have also created a pivot table on the below image to help understand the distribution of prediction. The test.csv dataset contains 750 rows, out of which we get churn=yes for 55 rows or 7.33% of the cases while we get churn=no for 695 rows or 92.67% of the cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l0jAItREF04NSGsqfIlNWA.png" /><figcaption>Fig: Predictions on test.csv dataset</figcaption></figure><blockquote>Other Key Indicators to look out for</blockquote><h3><strong>1. Pricing points of competitors and their subscription models</strong></h3><p>One of the key factors to analyse is how the company’s competitors have designed their subscription model. What are the time spans for which they offer their services? How are these models priced?</p><h3><strong>2. Customer behavior pattern</strong></h3><p>How likely are the customers to exit the system based on the frequency of usage of services of the company by customers? How does their behavior change if the company tweaks their price point or the model of subscription/quality of it’s services? How do they react if the company provides additional services like Amazon Prime Video or Netflix subscription along with it’s package?</p><h3><strong>3. Competitor reaction</strong></h3><p>How did the competition react to changes made by the company or by a change in market conditions? Did they offer discounts on their services or include more services into their product line by incorporating newer technologies or partnering with other firms to get more product support?</p><blockquote>Ways to Reduce Customer Churn</blockquote><h3>1. Focussing attention towards your better customers</h3><p>Instead of spending huge amount of resources to try to incentivize the customers who are likely to churn based on customer behavior analysis, it is better for the company to spend those resources on it’s existing customers. This will not only ensure customer loyalty but will also create meaningful long term relationship with those customers.</p><h3>2. Analyzing customer churn pattern</h3><p>Analyzing the churn pattern of customers is the key method by which it can understand which customers are about to leave and which features of a company’s product are most important to the customers. It may be possible that customers prefer all: low, medium and high valued products or subscriptions that would be suitable to them according to their needs or they may also prefer only low valued products. Changing churn behavior of customers when pricing or features of products are changed along with time is also an essential analysis that must be done by the company.</p><h3>3. Developing a grievance redressal system</h3><p>While using a company’s products, it is very likely that customers will have some issues with them at some point of time. Therefore, it is extremely essential that a company install a feedback system and also create a system of fast and reliable customer service. These things add up a lot to increase the overall customer experience over long durations of time.</p><h3>4. Creating a new subscription model and improving renewal system</h3><p>While a company may have designed their products and subscription models to tend to the need of it’s customers, it may be better off if it can provide more tailor made packages and features to it’s customers. This will ensure that they get to pay only for the services that they actually need and do not end up paying extravagantly for services they have no use for.</p><p>The company should also focus on improving it’s renewal model by providing flexibility to it’s customers for auto-renewal or change of subscription plan during run-period of subscription of an already subscribed plan.</p><p><em>Link to GitHub repository:</em> <a href="https://github.com/rahulkhandelwal396/Telco-Churn-Prediction">https://github.com/rahulkhandelwal396/Telco-Churn-Prediction</a></p><p>…</p><p><em>Hope you liked the article. Please let me know at rahulkhandelwal396@gmail.com if there is anything missing.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad95a3a67454" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/telco-churn-prediction-ad95a3a67454">Telco Churn Prediction</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Myth of Natural Talent]]></title>
            <link>https://rahulkhandelwal.medium.com/the-myth-of-natural-talent-ea64ed869d34?source=rss-42b04d527af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea64ed869d34</guid>
            <category><![CDATA[perseverance]]></category>
            <category><![CDATA[success]]></category>
            <category><![CDATA[talent]]></category>
            <category><![CDATA[hard-work]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Rahul Khandelwal]]></dc:creator>
            <pubDate>Sat, 09 Sep 2017 14:54:11 GMT</pubDate>
            <atom:updated>2017-09-10T05:05:29.032Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*USTNVZjxMB9lRoJ0Glvm3w.jpeg" /></figure><p>This one is about <strong>Talent </strong>versus <strong>Hard Work</strong>.</p><p>Maybe you’ve already read about it or heard it, but if you can still think of even a single person on this planet as being talented, read on:</p><p>We all have seen people who say or think that I can never be as good as ‘he’ is, in some task. He is a natural. He is born talented.</p><p>Well, let me tell you that there is no such thing as<strong> Talent.</strong></p><p>There is only <strong>Hard Work</strong>.</p><p>Period.</p><p>People who seem to be excellent and natural at doing something <em>have</em> toiled day in and day out for far more days than you have even tried. Most people don’t know that they have worked so hard at it because once they’ve mastered it, you can’t see strain on their faces while they do it.</p><p>They’ll give you a shrug and say “<em>huh, this? this is child’s play”.</em></p><p>Listening to them, let’s say even you want to try and do it. You try. If you succeeded on your first try, maybe you were just lucky or you have a good working mind.</p><p>But if you fail, you start chastising yourself for being incompetent to do a simple task and then you start doubting yourself. Why was I not able to do that? Am I not smart enough? Am I not thinking properly? Is my thinking process impaired?</p><p>Am I dumb?</p><p>What you have not realized is called the ‘truth’.</p><p>And if you want to know the truth, read this old saying which says —</p><blockquote><strong><em>“The master has failed more times than the student has even tried”</em></strong></blockquote><p>Therefore, practice.</p><blockquote>The only reason why some people can start doing something and be initially good at it because of their natural inclination towards that thing.</blockquote><p>Even such people can’t be masters if they get lazy and stop practicing.</p><p>In the process of working on a task, there is something that you must not tell anyone, including yourself. If you do so, you’ll fail. Don’t tell your friend that I am not as talented. That I don’t have the time. That I don’t have the money. Save yourself those excuses and start working hard on what you really want to achieve in life. If you really want to do something, you will find a way. Don’t let anyone discourage you or steer you away from your aim.</p><p>Know that you have the power to change your life. It’s all in the mind. Even if you start today. Even if you think <em>today </em>is already late. Start today and keep working with unparalleled dedication for a lot more time in that field than anyone else anyone has ever known to have been working for in that area.</p><p>Be true to yourself, otherwise someday, I promise, you’ll pay for it. Even if you feel that you are at the very start and the others have gone so far they seem impossibly out of reach. If you give years of hard work and dedication in that field, you will surpass the competence of any living organism who ever was able to do that task. In fact, I think that every person is <em>born</em> capable of doing anything. It’s just that their interests differ.</p><p>To be good at anything, you really have to believe in yourself to the core or your heart. Lay the foundation stone of ‘I believe in myself’ in your heart today. It’s not as easy as you think to stand firm on that belief. <em>So, make it a part of your character.</em></p><blockquote>You can do anything. Remember that.</blockquote><p>But, to really achieve mastery in a particular task, don’t leave it until you’ve completed it. Either you’ve done something or you haven’t. Same goes for knowledge, sports, music, or anything. You name it. There is no such thing as a 90% completed task. It’s not done and you know it. Similarly, there is no such thing as half-knowledge. Either you know something or you don’t.</p><p>But all your effort will be worthless if you give up in between. Therefore, delete the phrase ‘I Give Up’ from your mental dictionary permanently.</p><blockquote>“No matter how many mistakes you make or how slow you progress, you’re still way ahead of everyone who isn’t trying” — Tony Robbins</blockquote><p>So, if you want to be good at something, start by taking a single step at a time. But only in one direction. And keep going.</p><p>Remember this line which I read earlier today on the Internet:</p><blockquote><strong>“Success is 20 steps in one direction, not 1 step in 20 directions”</strong></blockquote><p><strong>Additional tip:</strong> To maximize your efficiency for maximum output of your hard work, work <em>smart </em>as well<em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea64ed869d34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The ‘Dark’ side of Social Media]]></title>
            <link>https://medium.com/manager-mint/the-other-side-of-social-media-f936f04ac20b?source=rss-42b04d527af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f936f04ac20b</guid>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[depression]]></category>
            <category><![CDATA[instagram]]></category>
            <category><![CDATA[life-advice]]></category>
            <dc:creator><![CDATA[Rahul Khandelwal]]></dc:creator>
            <pubDate>Thu, 07 Sep 2017 02:46:13 GMT</pubDate>
            <atom:updated>2017-09-12T01:05:53.127Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*W6Jp2FHKb4UsRmwyEixPwg.jpeg" /></figure><p>The amount of time that teens and adults are spending on Social Media is constantly increasing, day by day. With the enormous technological revolution giving us swifter internet speeds, billions of people can now access data intensive apps like YouTube and Instagram easier than ever before.</p><p>Therefore, it is integral that we start talking about the time we spend on social media and how it changes our personality over time.</p><blockquote><strong>Time spent on Social Media</strong></blockquote><p>We live in a world where our ‘real’ lives are overtaken by the virtual world. People are sharing more and more posts on Instagram, Facebook, Twitter and what not. A significant part of our lives is now spent on social media platforms. In fact, I found the following infographic on the Internet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*iicSBeEhMOlzIKvPNUq0Ng.png" /><figcaption><em>Source: </em><a href="http://www.adweek.com/digital/mediakix-time-spent-social-media-infographic/"><em>http://www.adweek.com/digital/mediakix-time-spent-social-media-infographic/</em></a></figcaption></figure><p>Of course, not all of us spend this amount of time on these platforms. Some of us spend a little more time and some a little less. If you add up the above numbers, we get a total of 1 hr and 16 minutes. This number is the global average. Considering that only 47% of the world’s population has access to the internet, it is only logical that in the countries which have access to high-speed internet, people spend more time on Social Media. For example, according to a recent study, the average youth spends up to 5 hours per day on Social Media in America. That may not seem a lot, but when you see the bigger picture, here is a break up of the time we spend on social media in a lifetime:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*mAAQizTxmmkw18m8GjrQqA.png" /><figcaption>Total: 5 Years, 4 Months</figcaption></figure><p>So now, here we are. Spending around 5 Years of our life (mostly youth) in a virtual world. Imagine what we could have done otherwise in that time.</p><p>These social media platforms — Facebook, Instagram, YouTube, etc. have no doubt proved to be a really good medium for information exchange. There are those who come online to pass time by looking at useless posts (Sure, they might have an emotional impact, but not so much in terms of knowledge every time), and then there are those who look out for ways to learn at these platforms — Learning by watching videos from YouTube channels, Facebook groups, Quora answers, etc. Well, at least some of us have something to gain after we spend so much time there. Nice.</p><blockquote><strong>Effects of living in a Virtual World</strong></blockquote><p>With some statistics established, it seems fair enough for me now to say that a significant ‘chunk’ of our real life is spent in a virtual world. This causes us to live a dual life — One real and the other: Virtual. The time we have in a day is split between trying to live both of those lives simultaneously. This creates a mashed up version of reality — even if we don’t unanimously agree upon it. This causes us to be defined not only by the way we look or the way we think, but also by our social media posts. I’ll talk more about this in the section below:</p><blockquote><strong>The ‘Dark’ Side</strong></blockquote><p>But what happens when we share posts on these social media platforms is that we start relating them to being an image of how we want other people to perceive us. We feel like the type of snapshots we share on Instagram, or the stories we put on Facebook define the type of life we live and then we follow up to that reputation by living that character that we portray knowingly or unknowingly. Some of might argue that this is not the case for them — they don’t care what other people perceive of them. While this is true and even good, unfortunately, I think that all of us are (even if a bit slightly) affected by the amount of likes and the amount of comments we get on our social media posts. Maybe, just maybe, what we are essentially doing is trying to look cool on these social media platforms. We only share the best moments of our lives — the best thoughts, best achievements and the best photos. Whatever it may be, it creates a type of social obligation (again, it may not be for some people, but it is now, for most of the youth) on us to make our lives look cooler than they actually are. The topic I am discussing about is not how ‘cool’ our lives are, but the reality of the posts we share on these social media sites.</p><p>What this does — according to me is that it creates a <strong><em>‘Boomerang’ effect</em></strong>. The action you take, goes around and gets back at you.</p><p>Whenever we share some ‘cool’ moments of our lives on social media, we sure want others to see it. And guess what, they do. The next thing that happens (as a part of our human nature) is that whoever sees those posts, they have an immediate psychological mental reaction to the post. Even they want to portray themselves as having a great social life — in order to get the social acceptance that no matter how much you deny, every human wants. So they start going places or sharing better pictures on Instagram. This thing may not happen instantly, but if you ask yourself, you know that somewhere or somehow, this can happen over time. And then you see the posts that your friends have shared — Like having dinner with people at an expensive hotel that you know if not affordable for you. Seeing how good the lives of your friends are, can sometimes start making you hate your own life. Yeah, the scientific term for this feeling is called <strong>Depression — </strong>the word as we know it. Well, this happened for them too, if you shared a good post too.</p><p>The overall effect of this sharing of posts is that even though our lives are better than, say it would have been 500 years ago, of course, due to technological advancement, we are ever less happy than we used to be before joining social media. Even if someone is happy, that indirect obligation of constantly living in the same state, or better — is on them, at least according to me.</p><blockquote><strong>Conclusion</strong></blockquote><p>I think that people should try not to portray themselves as someone else on social media. Be who you are. Don’t think that in order to gain social acceptance, you have to show your life as being ‘cool’. Remember the best person you can ever be — is yourself. Well, this goes for the other side as well — stop trying to show your life as being perfect on social media. All those stories and those posts. They might cause another person to feel sad about their life.</p><p><em>Note: These are my personal views, they don’t essentially have to match up with your thinking. This article shares what I, or what I think others feel about social media.</em></p><p>Find this article and more at <a href="http://www.managermint.com/">www.ManagerMint.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f936f04ac20b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/manager-mint/the-other-side-of-social-media-f936f04ac20b">The ‘Dark’ side of Social Media</a> was originally published in <a href="https://medium.com/manager-mint">Manager Mint Media</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>