<?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 Barış Akdeniz on Medium]]></title>
        <description><![CDATA[Stories by Barış Akdeniz on Medium]]></description>
        <link>https://medium.com/@akdenizb?source=rss-295a0880b1e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7O8-x_ihlHzDVfAV5rPTzw.jpeg</url>
            <title>Stories by Barış Akdeniz on Medium</title>
            <link>https://medium.com/@akdenizb?source=rss-295a0880b1e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 18:44:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akdenizb/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 with RFM]]></title>
            <link>https://medium.com/@akdenizb/customer-segmentation-with-rfm-73bc031f9354?source=rss-295a0880b1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/73bc031f9354</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[rfm-analysis]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Barış Akdeniz]]></dc:creator>
            <pubDate>Mon, 11 Jul 2022 19:38:43 GMT</pubDate>
            <atom:updated>2022-07-11T19:38:43.323Z</atom:updated>
            <content:encoded><![CDATA[<p>Customer segmentation is so crucial to analyze customer demographics and behiviours with common techniques like RFM. RFM is one of many powerful KPIs that can be used to inform and measure the success of your enterprise’s marketing programs and customer experiences. RFM can be explained as a marketing technique that is created group and grade of each of them to determine best customers or campaign target customers depending recency, frequency, monetary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gFqKZnbfLcylpjkJ.jpg" /><figcaption><a href="https://www.moengage.com/blog/predicitve-segments-rfm-analysis/">https://www.moengage.com/blog/predicitve-segments-rfm-analysis/</a></figcaption></figure><p>With or without these more sophisticated approaches, marketers can use RFM analysis to:</p><p>Increase the effectiveness of email marketing campaigns: Build an automated drip campaign with messages tailored to each segment. Increase loyalty and user engagement: Follow up with recent customers or new customers with timely promotions and educational content likely to increase their engagement with your brand. Decrease churn: Send personalized messages, offer repeat purchases at a discount or provide surveys that help you understand and address potential concerns. Reduce marketing costs and increase ROI: Reduce costs by focusing quickly and easily on smaller segments that are more likely to produce revenue and use insights from RFM analysis to optimize campaigns going forward.</p><p>RFM analysis ranks each customer on the following factors:</p><p><strong>Recency</strong>: How recent was the customer’s last purchase? Customers who recently made a purchase will still have the product on their mind and are more likely to purchase or use the product again. Businesses often measure recency in days. But, depending on the product, they may measure it in years, weeks or even hours.</p><p><strong>Frequency</strong>: How often did this customer make a purchase in a given period? Customers who purchased once are often are more likely to purchase again. Additionally, first time customers may be good targets for follow-up advertising to convert them into more frequent customers.</p><p><strong>Monetary</strong>: How much money did the customer spend in a given period? Customers who spend a lot of money are more likely to spend money in the future and have a high value to a business.</p><h3>Business Case Study</h3><p>A e-commerce company that sell some product based on United Kingdom analyze with customers segmentation according to RFM values. The company share a dataset that consists of sales information about 01/12/2009 to 09/12/2011. The sales numbers of company include in Kaggle Dataset that is <a href="https://www.kaggle.com/datasets/ilkeryildiz/online-retail-listing">https://www.kaggle.com/datasets/ilkeryildiz/online-retail-listing</a></p><p>Columns of the dataset are explained below side.</p><p>Invoice: Invoice number. Nominal. A 6-digit integral number uniquely assigned to each transaction. If this code starts with the letter ‘c’, it indicates a cancellation.</p><p>StockCode: Product (item) code. Nominal. A 5-digit integral number uniquely assigned to each distinct product.</p><p>Description: Product (item) name. Nominal.</p><p>Quantity: The quantities of each product (item) per transaction. Numeric.</p><p>InvoiceDate: Invice date and time. Numeric. The day and time when a transaction was generated.</p><p>UnitPrice: Unit price. Numeric. Product price per unit in sterling (Â£).</p><p>CustomerID: Customer number. Nominal. A 5-digit integral number uniquely assigned to each customer.</p><p>Country: Country name. Nominal. The name of the country where a customer resides.</p><h3>Data Preparation</h3><p>In this part, the data has to be changed for data processing, so the data has to be examined attentively such as type of price is transformed to “float64”.</p><pre>df[&quot;Price&quot;] = df[&quot;Price&quot;].apply(lambda x: float(str(x.replace(&#39;,&#39;,&#39;.&#39;))))</pre><p>Also, the numerical variables are examined with statistical information in below table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*Lw_z2bBfB6JdNVIquXiqJQ.png" /></figure><h3>Calculating RFM Scores</h3><p>Recency: from today date to last shopping date of numbers of days.</p><p>Frequency: Invoice number of customer.</p><p>Monetary: Total price of total invoice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*iZY89HiB70QpZXml7r1qNQ.png" /></figure><p>Value of monetary has to be positive number.</p><p>Let’s analyze these values with graphs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*dG12yg7PfjA42D9T1xrFrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*O3BxigcjPJx3izBoTaNfoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*3rQc1r2VXHER4rAi9PcVDw.png" /></figure><h3>Calculating RFM Scores</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*kF8ZJU2-YnaTxsMl6Di2uw.png" /></figure><h3>Creating &amp; Analysing RFM Segments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*Xy--LXbh8qKSK1k4Gdt8SA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*IcuAF1m8yWgTDA2YhwgmvA.png" /></figure><h3>Data Visulazation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*qbymY7RmWyHRArZJCHrO8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*XP2fy8SufJxTMMwhEvNYQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*7OiAPvfRRyg9Y8pGlQdgrg.png" /></figure><p>These segments are applied some different policy like if you campaign for “at_Risk” and “hibernating” customers via email or text massage, it can be reduced churn rate and sales of products can be increased. So customers of company can be managed very easily and wisely.</p><p>Also you can find this study at kaggle.</p><p><a href="https://www.kaggle.com/code/brskdnz/customer-segmentation-with-rfm-and-cltv-prediction">https://www.kaggle.com/code/brskdnz/customer-segmentation-with-rfm-and-cltv-prediction</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73bc031f9354" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Exploratory Data Analysis]]></title>
            <link>https://medium.com/@akdenizb/advanced-exploratory-data-analysis-14489cd5fba6?source=rss-295a0880b1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/14489cd5fba6</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[statistical-analysis]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[exploratory-data-analysis]]></category>
            <dc:creator><![CDATA[Barış Akdeniz]]></dc:creator>
            <pubDate>Sat, 09 Jul 2022 12:40:39 GMT</pubDate>
            <atom:updated>2022-07-09T12:40:39.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*yR9ithXv1gG5-RaroieqCg.png" /></figure><h3>How to analyze a data set with Python ?</h3><p>A new data set includes many informations that has various columns and rows and it tells a story that what we need to understand. This understanding process can be seperated four parts that are general impression, classification of variables, analysis of categorical variables, analysis of numerical variables, analysis of target variable, analysis of correlation. Firstly, it has to be good initial impression a new one creating with Python analyzing skills. Let’s start to with first step.</p><h3>General Impression</h3><h4>In that stage, Python has various packages for using capable of functions in this programming language. So firstly, if you need to acessibility of those functions, it has to be import some packages. Also the number of displaying columns is settin with next code stage in pandas package. Later, titanic is very well-known dataset that is loaded with nex code rowns and described as ‘df’. The next step is creating function for initial impression that are using variables codes in maths and statistics, of new data set. Let’s examine and interpetting of dataset.</h4><p>Shape: it shows number of rows and columns. So titanic dataset has 891 rows and 15 columns. Dtypes: it shows each columns types. So it includes 4 int64 types, 2 float64 types 2 category types, 2 bool types, 5 object types. Head: it shows initial number of rows that can be described as a number in that function or already defined as 20 in that functions. We don’t enter any number in the function. So it shows initial 20 of rows in titanic dataset. Tail: it shows last number of rows that can be described as a number in that function or already defined as 20 in that functions.We don’t enter any number in the function. So it shows last 20 of rows in titanic dataset. Isnull(): It makes questioning of the na that means unknown values and the answer shows as a bool type (True or False). If it adds “.sum()” end of code, that shows of the total na values of each of columns in a dataset. Clearly, age columns has 177 unknown rows, deck columns has 688 unknown rows, and embarked columns has 2 unknown columns in titanic dataset. Describe():It calculates and shows statistical information that count, mean, std, min in standard conditions. If it is added a list like [0,0.05, 0.50, 0.95, 0.99, 1], it sort from lowest value to highest value and that list shows 0% (minimum value), 5%, 50% (median value), 95%, 99%, and 100% (maximum value). That functions is so cruical for assesting a new dataset regarding statistical knowledge. If it is adding “.T”, that shows more conveniently and that means transpose.</p><pre>import pandas as pd<br>import seaborn as sns <br>import matplotlib.pyplot as plt<br>pd.set_option(&#39;display.max_columns&#39;,500)<br><br>df = sns.load_dataset(&quot;titanic&quot;)<br><br>def gen_imp(dataframe, number=20):<br>    print(&quot;############################### Shape #####################################&quot;)<br>    print(&quot;#############################&quot;, dataframe.shape, &quot;########################&quot; )<br>    print(&quot;############################## Types ######################################&quot;)<br>    print(&quot;#############################&quot;, dataframe.dtypes, &quot;########################&quot;)<br>    print(&quot;############################## Head #######################################&quot;)<br>    print(&quot;############################&quot;, dataframe.head(number),&quot;####################&quot;)<br>    print(&quot;############################## Tail #######################################&quot;)<br>    print(&quot;############################&quot;, dataframe.tail(number),&quot;####################&quot;)<br>    print(&quot;############################# NA ##########################################&quot;)<br>    print(&quot;############################&quot;, dataframe.isnull().sum(),&quot;##################&quot;)<br>    print(&quot;############################ Quantiles ####################################&quot;)<br>    print(dataframe.describe([0,0.05, 0.50, 0.95, 0.99, 1]).T)<br>    <br>gen_imp(df)</pre><h3>Classification of Variables</h3><pre>def class_variables(dataframe, numbers_nbc=10, numbers_cbc=20):<br>    <br>    cat_cols = [col for col <strong>in</strong> dataframe.columns if str(dataframe[col].dtypes) <strong>in</strong> [&quot;category&quot;, &quot;object&quot;, &quot;bool&quot;]]<br>    <br>    num_but_cat = [col for col <strong>in</strong> dataframe.columns if dataframe[col].nunique() &lt; numbers_nbc <strong>and</strong> dataframe[col].dtypes <strong>in</strong> [&quot;int64&quot;, &quot;float64&quot;]]<br>    <br>    cat_but_car = []<br>    <br>    for col <strong>in</strong> dataframe.columns:<br>        if dataframe[col].nunique() &gt; numbers_cbc <strong>and</strong> str(dataframe[col].dtypes) <strong>in</strong> [&quot;category&quot;, &quot;object&quot;]:<br>            cat_but_car.append(col)<br>    cat_cols = cat_cols + num_but_cat<br>    cat_cols = [col for col <strong>in</strong> cat_cols if col <strong>not</strong> <strong>in</strong> cat_but_car]<br><br>    num_cols = [col for col <strong>in</strong> dataframe.columns if dataframe[col].dtypes <strong>in</strong> [&quot;int64&quot;, &quot;float64&quot;]]<br>    num_cols = [col for col <strong>in</strong> num_cols if col <strong>not</strong> <strong>in</strong> cat_cols]<br><br>    print(f&quot;Observations: <strong>{</strong>dataframe.shape[0]<strong>}</strong>&quot;)<br>    print(f&quot;Variables: <strong>{</strong>dataframe.shape[1]<strong>}</strong>&quot;)<br>    print(f&#39;cat_cols: <strong>{</strong>len(cat_cols)<strong>}</strong>&#39;)<br>    print(f&#39;num_cols: <strong>{</strong>len(num_cols)<strong>}</strong>&#39;)<br>    print(f&#39;cat_but_car: <strong>{</strong>len(cat_but_car)<strong>}</strong>&#39;)<br>    print(f&#39;num_but_cat: <strong>{</strong>len(num_but_cat)<strong>}</strong>&#39;)<br><br>    return cat_cols, num_cols, cat_but_car<br><br>import seaborn as sns<br>df = sns.load_dataset(&quot;titanic&quot;)<br>class_variables(df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*zeRoBTE2WBgwqK-x_XQNNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*878WoH1gPDUtuPNGIv90qw.png" /></figure><p>In this part, “class_variables” function classifies variables as three class that are categorical variables, numerical variables, and categorical but cardinal variables. This part is significant to understanding variables in dataset. Categorical variables are includes object and category types. The important parts, these variables are seperated a meaningful category, so sometimes numerical variables are included these variables due to less diversity of variables. It should be less than the value of numbers_nbc that can be changed according to a dataset. On the other hand, it can be removed as a categorical type due to meaningless categorical variables so it can be defined as cardinal variables. Those variables have many categories so it is too hard classified as a categorical type. It should be higher than numbers_cbc that can be changed dataset. So in this dataset (“titanic”) has 15 variables that are 13 categorical types and 2 numerical types.</p><h3>Analysis of Categorical Variables</h3><pre>import pandas as pd<br>import seaborn as sns <br>import matplotlib.pyplot as plt<br><br>df = sns.load_dataset(&quot;titanic&quot;)<br><br><br>def cat_variables(dataframe, columns_name, plot=False):<br>    if dataframe[columns_name].dtypes == &quot;bool&quot;:<br>        dataframe[columns_name] = dataframe[columns_name].astype(int)<br>        print(pd.DataFrame({col_name: dataframe[columns_name].value_counts(),<br>                           &quot;Ratio&quot;: 100 * df[columns_name].value_counts() / len(dataframe)}))<br>        print(&quot;############################################################################&quot;)<br>        if plot:<br>            sns.countplot(x=dataframe[columns_name], data=dataframe)<br>            plt.show(block=True)<br>    else:<br>        print(pd.DataFrame({columns_name: dataframe[columns_name].value_counts(),<br>                           &quot;Ratio&quot;: 100 * df[columns_name].value_counts() / len(dataframe)}))<br>        if plot:<br>            sns.countplot(x=dataframe[columns_name], data=dataframe)<br>            plt.show(block=True)<br><br>            <br>cat_variables(df,&quot;embark_town&quot;, plot=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*s11kasWtuJtX8eQz3tRs8g.png" /></figure><p>That function analyzing a categorical variables that are examined in each of category are showing counts of category and percentage of presence. In addition to, if plot is equal to “True”, it shown as columnn chart according to count of category in that variable.</p><h3>Analysis of Numeriacal Variables</h3><pre>import pandas as pd<br>import seaborn as sns <br><br>df = sns.load_dataset(&quot;titanic&quot;)<br><br>def num_variables(dataframe, numerical_col, plot=False):<br>    quantiles = [0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95]<br>    print(dataframe[numerical_col].describe(quantiles).T)<br><br>    if plot:<br>        dataframe[numerical_col].hist()<br>        plt.xlabel(numerical_col)<br>        plt.title(numerical_col)<br>        plt.show(block=True)<br>        <br>num_variables(df,&quot;age&quot;, plot=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*k8s35V_TLVagpSVUy06mFA.png" /></figure><p>That function show count, mean, standard deviation of variables and it shows some percantage of value as mentioned above as a list. Also, if “plot” is equal to “True”, it shown as histogram graph that is shown count of variables equivalent and certain intervals.</p><h3>Analysis of Target Variable</h3><pre>import pandas as pd<br>import seaborn as sns <br>import matplotlib.pyplot as plt<br><br>df = sns.load_dataset(&quot;titanic&quot;)<br><br>def target_analysis(dataframe, target,variable_type, col):<br>    if (variable_type == &quot;categorical&quot;):<br>        print(pd.DataFrame({&quot;TARGET_MEAN&quot;: dataframe.groupby(col)[target].mean()}))<br>    elif (variable_type == &quot;numerical&quot;):<br>        print(dataframe.groupby(target).agg({col:&quot;mean&quot;}), end=&quot;<strong>\n\n\n</strong>&quot;)<br>    else:<br>        print(&quot;Please enter known type of variable type that can be &#39;categorical&#39; or &#39;numerical&#39;&quot;)<br>        <br>target_analysis(df,&quot;survived&quot;, &quot;numerical&quot;, &quot;age&quot;)<br>target_analysis(df,&quot;survived&quot;, &quot;categorical&quot;, &quot;sex&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*8HbYb4Emet8QN4PJJ0hYqQ.png" /></figure><p>That functions is examined a target variable that is critical information and most important variable of dateset with categorical or numerical variables. It has to be known very well story of dataset to determine target variable. Also it has to know about type of variable so it can be analyzed with target variable. Thus, one of them can be creating significant statiscial results with target variable in this part.</p><h3>Analysis of Correlation</h3><pre>import pandas as pd<br>import seaborn as sns <br><br>df = sns.load_dataset(&quot;titanic&quot;)<br><br>def high_correlated_cols(dataframe, plot=False, corr_th=0.90):<br>    corr = dataframe.corr()<br>    cor_matrix = corr.abs()<br>    upper_triangle_matrix = cor_matrix.where(np.triu(np.ones(cor_matrix.shape), k=1).astype(np.bool))<br>    drop_list = [col for col <strong>in</strong> upper_triangle_matrix.columns if any(upper_triangle_matrix[col] &gt; corr_th)]<br>    if plot:<br>        import seaborn as sns<br>        import matplotlib.pyplot as plt<br>        sns.set(rc={&#39;figure.figsize&#39;: (15, 15)})<br>        sns.heatmap(corr, cmap=&quot;RdBu&quot;)<br>        plt.show()<br>    return drop_list<br><br>high_correlated_cols(df, plot=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*vcceylLUAohRVpOIjDjwQw.png" /></figure><p>That function is examined with high correlated variables. if correlation values of these varibles are higher than “corr_th” it adds “drop_list”. It can be shown as drop list that means it should be removed only one of them due to any obstructing analysis of dataset. Because these variables tells same story and it is more clarified that analysis of dataset with just one of them. Moreover, if plot is equal to “True”, relationship of correlation with each other are shown in heatmap.</p><p>To sum up, a dataset is examined with classified variables and relationship with target variable in statistical informations and python programming language.</p><p>Also you can find this project in kaggle.</p><p><a href="https://www.kaggle.com/code/brskdnz/advanced-eda">https://www.kaggle.com/code/brskdnz/advanced-eda</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14489cd5fba6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>