<?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 Cem ÖZÇELİK on Medium]]></title>
        <description><![CDATA[Stories by Cem ÖZÇELİK on Medium]]></description>
        <link>https://medium.com/@i.cemozcelik?source=rss-e7aec74cd6ed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9-1ZJGaHvVQr7OYh6oiBvw.png</url>
            <title>Stories by Cem ÖZÇELİK on Medium</title>
            <link>https://medium.com/@i.cemozcelik?source=rss-e7aec74cd6ed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:27:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@i.cemozcelik/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[Multivariate Time Series Forecasting]]></title>
            <link>https://medium.com/@i.cemozcelik/multivariate-time-series-forecasting-8011ffde303a?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/8011ffde303a</guid>
            <category><![CDATA[retail]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Sun, 02 Jul 2023 11:24:58 GMT</pubDate>
            <atom:updated>2023-11-07T18:21:26.670Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Art of Forecasting in the Retail Industry</h4><h4>Part I : Exploratory Data Analysis &amp; Time Series Analysis</h4><p>In this article, I will conduct exploratory data analysis and time series analysis using a dataset consisting of product sales in different categories from a store in the US between 2015 and 2018. Following these steps, I will preprocess the data and perform a multivariate forecasting study.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IaALt3UvvlVntG08hB0U6w.jpeg" /><figcaption>Pixabay, Pexels</figcaption></figure><p>Hello, today I am thrilled to finally sit in front of my computer and delve into an exciting data science project that I have been putting off for quite some time. In this article, I will share the first part of my two-phase project. Through exploratory data analysis and time series analysis, I will embark on a captivating journey into the realm of my dataset. Here, I will uncover the secrets behind sales trends in different categories of products. By visualizing the data, we will witness the fluctuations in sales figures and then delve deeply into the intricate dynamics of these patterns over time.</p><p>I utilized the <a href="https://plotly.com/">Plotly</a> library as a visualization tool to gain insights from my dataset. <a href="https://plotly.com/">Plotly</a> proved to be immensely helpful in creating interactive graphs for visualizing the data. I highly recommend using this library for data visualization purposes. Given that my <a href="https://www.kaggle.com/datasets/rohitsahoo/sales-forecasting">dataset</a> is a time series dataset, this article includes an exploratory data analysis section covering various aspects of time series analysis, such as stationarity, seasonality, and cyclicality.</p><p>Now I can start by importing the libraries that I will be using in the study.</p><pre>import numpy as np <br>import pandas as pd <br>import seaborn as sns<br>from datetime import datetime as dt<br><br><br>import plotly.express as px<br>import plotly.graph_objects as go<br><br><br>import itertools<br><br>import statsmodels.api as sm<br>from statsmodels.tsa.seasonal import seasonal_decompose<br>import statsmodels.tsa.api as smt<br><br>import warnings<br>warnings.filterwarnings(&#39;ignore&#39;)<br>#pd.set_option(&#39;display.max_columns&#39;, None)<br>pd.set_option(&#39;display.max_rows&#39;, None)<br>pd.set_option(&#39;display.width&#39;, None) <br>pd.set_option(&#39;display.float_format&#39;, lambda x: &#39;%.f&#39; % x)<br>pd.set_option(&#39;display.expand_frame_repr&#39;, False)</pre><p>After importing the necessary libraries, I proceed to import the dataset that I will be using for this project. The work presented in this article is based on <a href="https://www.kaggle.com/smailcemzelk/super-store-dataset-eda-time-series-analysis">my notebook published on Kaggle</a>, where I shared my findings and analysis. By leveraging the power of data science techniques, I aim to offer valuable insights and illustrate the step-by-step process involved in this project. The dataset serves as a valuable resource to demonstrate the practical application of various data analysis and forecasting techniques.</p><pre>dataset = pd.read_csv(&#39;/kaggle/input/sales-forecasting/train.csv&#39;)<br>df = dataset.copy()</pre><p>Well, once I’ve imported the dataset, I begin my work. In the first step, I define a function called ‘check_df.’ This function is highly valuable for comprehending the overall structure of the dataset. It offers access to various information, including the dataset’s dimensions, feature names, data types, and the ability to review the first and last 5 rows of the dataset. Furthermore, I aim to uncover valuable patterns and trends within the dataset by analyzing the statistical properties of numerical variables</p><pre>def check_df(dataset, head = 5):<br>    print(&#39;#&#39;*30 + &#39;Shape of Dataset&#39; + &#39;#&#39;*30, end = &#39;\n&#39;*2)<br>    print(dataset.shape, end = &#39;\n&#39;*2)<br>    print(&#39;#&#39;*30 + &#39;General informations about to Dataset&#39; + &#39;#&#39;*30, end = &#39;\n&#39;*2)<br>    print(dataset.info(), end = &#39;\n&#39;*2)<br>    print(&#39;#&#39;*30 + &#39;First 5 Lines Of Dataset&#39; + &#39;#&#39;*30, end = &#39;\n&#39;*2)<br>    print(dataset.head(head), end = &#39;\n&#39;*2)<br>    print(&#39;#&#39;*30 + &#39;NaN values of Features&#39; + &#39;#&#39;*30, end = &#39;\n&#39;*2)<br>    print(dataset.isnull().sum(), end = &#39;\n&#39;*2)<br>    print(&#39;#&#39;*30 + &#39;Descriptive Statistics of Numerical Features&#39; + &#39;#&#39;*30, end = &#39;\n&#39;*2)<br>    print(dataset.describe().T, end = &#39;\n&#39;*2)<br>    print(&#39;#&#39;*30 + &#39;Quantiles of Numerical Features&#39; + &#39;#&#39;*30, end =&#39;\n&#39;*2)<br>    print(dataset.describe([0,0.10, 0.25, 0.50,0.75,0.99]).T, end = &#39;\n&#39;*2)<br><br>check_df(df)</pre><p>When I run the function called check_df that I created, the general view of the dataset is as follows:</p><pre>##############################Shape of Dataset##############################<br><br>(9800, 18)<br><br>##############################General informations about to Dataset##############################<br><br>&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;<br>RangeIndex: 9800 entries, 0 to 9799<br>Data columns (total 18 columns):<br> #   Column         Non-Null Count  Dtype  <br>---  ------         --------------  -----  <br> 0   Row ID         9800 non-null   int64  <br> 1   Order ID       9800 non-null   object <br> 2   Order Date     9800 non-null   object <br> 3   Ship Date      9800 non-null   object <br> 4   Ship Mode      9800 non-null   object <br> 5   Customer ID    9800 non-null   object <br> 6   Customer Name  9800 non-null   object <br> 7   Segment        9800 non-null   object <br> 8   Country        9800 non-null   object <br> 9   City           9800 non-null   object <br> 10  State          9800 non-null   object <br> 11  Postal Code    9789 non-null   float64<br> 12  Region         9800 non-null   object <br> 13  Product ID     9800 non-null   object <br> 14  Category       9800 non-null   object <br> 15  Sub-Category   9800 non-null   object <br> 16  Product Name   9800 non-null   object <br> 17  Sales          9800 non-null   float64<br>dtypes: float64(2), int64(1), object(15)<br>memory usage: 1.3+ MB<br>None<br><br>##############################First 5 Lines Of Dataset##############################<br><br>   Row ID        Order ID  Order Date   Ship Date       Ship Mode Customer ID    Customer Name    Segment        Country             City       State  Postal Code Region       Product ID         Category Sub-Category                                       Product Name  Sales<br>0       1  CA-2017-152156  08/11/2017  11/11/2017    Second Class    CG-12520      Claire Gute   Consumer  United States        Henderson    Kentucky        42420  South  FUR-BO-10001798        Furniture    Bookcases                  Bush Somerset Collection Bookcase    262<br>1       2  CA-2017-152156  08/11/2017  11/11/2017    Second Class    CG-12520      Claire Gute   Consumer  United States        Henderson    Kentucky        42420  South  FUR-CH-10000454        Furniture       Chairs  Hon Deluxe Fabric Upholstered Stacking Chairs,...    732<br>2       3  CA-2017-138688  12/06/2017  16/06/2017    Second Class    DV-13045  Darrin Van Huff  Corporate  United States      Los Angeles  California        90036   West  OFF-LA-10000240  Office Supplies       Labels  Self-Adhesive Address Labels for Typewriters b...     15<br>3       4  US-2016-108966  11/10/2016  18/10/2016  Standard Class    SO-20335   Sean O&#39;Donnell   Consumer  United States  Fort Lauderdale     Florida        33311  South  FUR-TA-10000577        Furniture       Tables      Bretford CR4500 Series Slim Rectangular Table    958<br>4       5  US-2016-108966  11/10/2016  18/10/2016  Standard Class    SO-20335   Sean O&#39;Donnell   Consumer  United States  Fort Lauderdale     Florida        33311  South  OFF-ST-10000760  Office Supplies      Storage                     Eldon Fold &#39;N Roll Cart System     22<br><br>##############################NaN values of Features##############################<br><br>Row ID            0<br>Order ID          0<br>Order Date        0<br>Ship Date         0<br>Ship Mode         0<br>Customer ID       0<br>Customer Name     0<br>Segment           0<br>Country           0<br>City              0<br>State             0<br>Postal Code      11<br>Region            0<br>Product ID        0<br>Category          0<br>Sub-Category      0<br>Product Name      0<br>Sales             0<br>dtype: int64<br><br>##############################Descriptive Statistics of Numerical Features##############################<br><br>             count  mean   std  min   25%   50%   75%   max<br>Row ID        9800  4900  2829    1  2451  4900  7350  9800<br>Postal Code   9789 55273 32041 1040 23223 58103 90008 99301<br>Sales         9800   231   627    0    17    54   211 22638<br><br>##############################Quantiles of Numerical Features##############################<br><br>             count  mean   std  min   0%   10%   25%   50%   75%   99%   max<br>Row ID        9800  4900  2829    1    1   981  2451  4900  7350  9702  9800<br>Postal Code   9789 55273 32041 1040 1040 10024 23223 58103 90008 98115 99301<br>Sales         9800   231   627    0    0     8    17    54   211  2480 22638</pre><p>When we observe the general structure of the dataset, we see that we are working with a dataset containing 9800 observation lines and 18 variables. We also detect missing observations in the variable named ‘Postal Code’. By examining the missing observations, we aim to develop strategies on how to fill these values. In addition, there are a few more variables in our data set that, although they have numerical values, are actually categorical variables according to the information they contain. For example, the postcode and Row ID columns are represented numerically, even though they actually have a categorical attribute. We will move forward in converting these variables to categorical variables.</p><pre>df.loc[(df[&quot;Postal Code&quot;].isnull()), :][[&quot;City&quot;, &quot;State&quot;]].value_counts()<br><br>## Output ##<br><br>City        State  <br>Burlington  Vermont    11<br>dtype: int64</pre><p>All 11 rows of missing observations in the dataset are observations from the same State-City group. With a simple Google search, I found the Postal Code for this region and filled in these values for the missing observations. In order to continue our work, we need to change the types of some variables. Columns ‘Ship Date’ and ‘Order Date’ are seen as ‘object’ as data types, but since these two variables actually contain date information, I want to convert them to ‘datetime’ format.</p><pre>df.drop(columns = [&#39;Row ID&#39;], inplace = True) <br><br>df.loc[(df[&quot;Postal Code&quot;].isnull()), &quot;Postal Code&quot;] = 5401 <br><br>df[&quot;Postal Code&quot;] = df[&quot;Postal Code&quot;].astype(&quot;str&quot;) <br><br>def convert_datetime(dataframe):     <br>    date_cols = [col for col in dataframe.columns if &#39;Date&#39; in col]<br>   <br>    for col in date_cols:<br>        dataframe[col] = pd.to_datetime(dataframe[col], errors = &#39;coerce&#39;)<br>    return dataframe.info()<br><br>convert_datetime(df)<br><br><br><br>## Output ## :<br><br>&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;<br>RangeIndex: 9800 entries, 0 to 9799<br>Data columns (total 17 columns):<br> #   Column         Non-Null Count  Dtype         <br>---  ------         --------------  -----         <br> 0   Order ID       9800 non-null   object        <br> 1   Order Date     9800 non-null   datetime64[ns]<br> 2   Ship Date      9800 non-null   datetime64[ns]<br> 3   Ship Mode      9800 non-null   object        <br> 4   Customer ID    9800 non-null   object        <br> 5   Customer Name  9800 non-null   object        <br> 6   Segment        9800 non-null   object        <br> 7   Country        9800 non-null   object        <br> 8   City           9800 non-null   object        <br> 9   State          9800 non-null   object        <br> 10  Postal Code    9800 non-null   object        <br> 11  Region         9800 non-null   object        <br> 12  Product ID     9800 non-null   object        <br> 13  Category       9800 non-null   object        <br> 14  Sub-Category   9800 non-null   object        <br> 15  Product Name   9800 non-null   object        <br> 16  Sales          9800 non-null   float64       <br>dtypes: datetime64[ns](2), float64(1), object(14)<br>memory usage: 1.3+ MB</pre><p>We fixed the missing observations in the dataset and edited the wrong data type. After converting the Date variables in my dataset from object data type to Datetime data type, my next step involves categorizing the variables in the dataset into different types, including categorical, numerical etc.. Following this categorization, I will employ various visualizations to examine the class frequencies of the categorical variables.</p><pre>def grab_col_name(dataframe, cat_th = 5, car_th = 49):<br>    cat_cols = [col for col in dataframe.columns if dataframe[col].dtypes == &quot;O&quot;]<br>    num_but_cat = [col for col in dataframe.columns if dataframe[col].dtypes != &quot;O&quot; and dataframe[col].nunique() &lt; cat_th]<br>    cat_but_car = [col for col in dataframe.columns if dataframe[col].dtypes == &quot;O&quot; and dataframe[col].nunique() &gt; car_th]<br>    <br>    cat_cols = cat_cols + num_but_cat<br>    cat_cols = [col for col in cat_cols if col not in cat_but_car]<br>    <br>    num_cols = [col for col in dataframe.columns if dataframe[col].dtypes in [&quot;int64&quot;, &quot;float64&quot;] and &quot;ID&quot; not in col.upper()]<br>    num_cols= [col for col in num_cols if col not in num_but_cat]<br>    <br>    date_cols = [col for col in dataframe.columns if &#39;Date&#39; in col]<br>    <br>    for col in date_cols:<br>            dataframe[col] = pd.to_datetime(dataframe[col], errors = &#39;coerce&#39;)<br>            <br>    return cat_cols, num_cols, cat_but_car,date_cols<br><br><br>grab_col_name(df)<br><br>## Output  : <br><br>([&#39;Ship Mode&#39;, &#39;Segment&#39;, &#39;State&#39;, &#39;Region&#39;, &#39;Category&#39;, &#39;Sub-Category&#39;],<br> [&#39;Sales&#39;],<br> [&#39;Row ID&#39;,<br>  &#39;Order ID&#39;,<br>  &#39;Customer Name&#39;,<br>  &#39;City&#39;,<br>  &#39;Postal Code&#39;,<br>  &#39;Product ID&#39;,<br>  &#39;Product Name&#39;],<br> [&#39;Order Date&#39;, &#39;Ship Date&#39;])<br><br>##<br><br>cat_cols, num_cols, cat_but_car, date_cols = grab_col_name(df)</pre><p>I am currently categorizing the variables in the dataset based on their types. Next, I will define a function to visualize the frequency of category classes in my categorical data.</p><pre># Function for Categorical Variables:<br><br>def cat_summary(dataframe, plot=False, categorical_columns = cat_cols, threshold=10):<br>    for col_name in categorical_columns:<br>        print(&quot;#&quot; * 30 + &quot; Unique Values Of &quot; + col_name + &quot; column &quot; + &quot;#&quot; * 30)<br>        print(col_name + &quot;: &quot; + str(dataframe[col_name].nunique()))<br>        <br>        print(&quot;#&quot; * 30 + &quot; Frequencies of Class Values &quot; + &quot;#&quot; * 30)<br>        value_counts = dataframe[col_name].value_counts()<br>        if dataframe[col_name].nunique() &gt; threshold:<br>            top_n_values = value_counts.head(threshold)<br>            #other_count = value_counts[threshold:].sum()<br>            #top_n_values[&#39;Others&#39;] = other_count<br>            value_counts = top_n_values<br>        <br>        print(pd.DataFrame({col_name: value_counts,<br>                            &quot;Ratio&quot;: value_counts / len(dataframe[col_name])}))<br>        <br>        if plot:<br>            rgb_values = sns.color_palette(&quot;Set2&quot;, 6)<br>            sns.set_theme(style=&quot;darkgrid&quot;)<br>            <br>            if dataframe[col_name].nunique() &gt; threshold:<br>                plt.figure(figsize=(13,6))  <br>            <br>            ax = sns.barplot(x=value_counts.index, y=value_counts.values, palette=rgb_values)<br>            ax.set_xticklabels(ax.get_xticklabels(), rotation=60)<br>            for p in ax.patches:<br>                ax.annotate(f&#39;\n{p.get_height()}&#39;, (p.get_x() + p.get_width() / 2., p.get_height()), ha=&#39;center&#39;, va=&#39;top&#39;, color=&#39;white&#39;, size=10)<br>            plt.show()<br>            <br># Function for Numerical Variables :<br><br>def num_summary(dataframe, plot = False):<br>    quantiles = [0, 0.25, 0.50, 0.75, 1.0]<br>    <br>    for col_name in num_cols:<br>        print(&quot;#&quot;*30 + &quot; Distribution of &quot; + col_name+ &quot; column&quot; + &quot;#&quot;*30)<br>        print(dataframe[col_name].describe(quantiles).T)<br>        <br>        if plot:<br>            sns.histplot(data = dataframe, x = col_name)<br>            plt.xlabel(col_name)<br>            plt.title(&quot;The Distribution of &quot;+ col_name)<br>            plt.grid(True, alpha = 0.5)<br>            plt.show(block = True)<br><br># Function For Percent Format  <br>            <br>def autopct_format(values): <br>    def my_format(pct): <br>        total = sum(values) <br>        val = int(round(pct*total/100.0))<br>        return &#39; ${v:d}&#39;.format(v=val)<br>    return my_format</pre><pre>categorical_columns = [&#39;Ship Mode&#39;, &#39;Segment&#39;, &#39;State&#39;,&#39;Region&#39;, <br>                        &#39;Category&#39;, &#39;Sub-Category&#39;, &#39;Customer Name&#39;, &#39;City&#39;]<br><br>cat_summary(df,True,categorical_columns = categorical_columns,threshold = 10)</pre><pre>############################## Unique Values Of Ship Mode column ##############################<br>Ship Mode: 4<br>############################## Frequencies of Class Values ##############################<br>                Ship Mode  Ratio<br>Standard Class       5859   0.60<br>Second Class         1902   0.19<br>First Class          1501   0.15<br>Same Day              538   0.05</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaU7L4wd5usLzjMzhCbwXg.png" /></figure><p>When we examine the Ship Mode variable, we see that the class named Standard Class is predominantly in the data set. Orders are generally sent as standard.</p><pre>############################## Unique Values Of Segment column ##############################<br>Segment: 3<br>############################## Frequencies of Class Values ##############################<br>             Segment  Ratio<br>Consumer        5101   0.52<br>Corporate       2953   0.30<br>Home Office     1746   0.18</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hcz-BRAw4dXErOm7vsNT1A.png" /></figure><p>In the segment variable, we see that the Consumer type customer group is dominant. In the second place is the name Corporate.</p><pre>############################## Unique Values Of State column ##############################<br>State: 49<br>############################## Frequencies of Class Values ##############################<br>                State  Ratio<br>California       1946   0.20<br>New York         1097   0.11<br>Texas             973   0.10<br>Pennsylvania      582   0.06<br>Washington        504   0.05<br>Illinois          483   0.05<br>Ohio              454   0.05<br>Florida           373   0.04<br>Michigan          253   0.03<br>North Carolina    247   0.03</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bh3_sxH9Chl6LrPZuGCI8Q.png" /></figure><p>When we look at the frequencies of the states in the data set, we see that California is dominant.</p><pre>############################## Unique Values Of Region column ##############################<br>Region: 4<br>############################## Frequencies of Class Values ##############################<br>         Region  Ratio<br>West       3140   0.32<br>East       2785   0.28<br>Central    2277   0.23<br>South      1598   0.16</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CRZYhrnUhAPVPRl_ZDnMCQ.png" /></figure><p>When we look at the region variable, the distribution seems somewhat homogeneous and class frequencies seem close to each other. But West is seen more intensely.</p><pre>############################## Unique Values Of Category column ##############################<br>Category: 3<br>############################## Frequencies of Class Values ##############################<br>                 Category  Ratio<br>Office Supplies      5909   0.60<br>Furniture            2078   0.21<br>Technology           1813   0.18</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZN6fUYDEedmHQArZ3UGWjw.png" /></figure><p>We see that there are 3 classes in the Category variable, which stores the categories of the products sold. I see that the Office Supplies class is dominant. I see Furniture in second place.</p><pre>############################## Unique Values Of Sub-Category column ##############################<br>Sub-Category: 17<br>############################## Frequencies of Class Values ##############################<br>             Sub-Category  Ratio<br>Binders              1492   0.15<br>Paper                1338   0.14<br>Furnishings           931   0.10<br>Phones                876   0.09<br>Storage               832   0.08<br>Art                   785   0.08<br>Accessories           756   0.08<br>Chairs                607   0.06<br>Appliances            459   0.05<br>Labels                357   0.04</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7J4VqUZHXBucR91zp2JOLw.png" /></figure><p>When I look at the distribution of class frequencies of the Sub-categories variable, we see that classes such as Binders and Papers are the most sold Sub-Categories.</p><pre>############################## Unique Values Of City column ##############################<br>City: 529<br>############################## Frequencies of Class Values ##############################<br>               City  Ratio<br>New York City   891   0.09<br>Los Angeles     728   0.07<br>Philadelphia    532   0.05<br>San Francisco   500   0.05<br>Seattle         426   0.04<br>Houston         374   0.04<br>Chicago         308   0.03<br>Columbus        221   0.02<br>San Diego       170   0.02<br>Springfield     161   0.02</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Hw6oV7ggtSHVdoJl0BK7Q.png" /></figure><p>When we look at the City variable, we see that the class named New York City is dominant.</p><p>I utilize both histograms and box plots to visualize the distribution of sales values. When we examine the statistical characteristics of the sales values using the ‘check_df’ function, we find that the series has a mean of 231, a standard deviation of 627, and a median value of 54. Additionally, the maximum value observed is 22,638. Based on this data, it’s evident that our dataset exhibits a skewed distribution. Given that the median of the values in the dataset is smaller than the mean, we expect a right-skewed histogram. In such cases, it’s more appropriate to use the median as a measure of central tendency to represent our dataset.</p><pre>import plotly.graph_objects as go<br>import plotly.subplots as sp<br><br>fig_histogram = go.Figure()<br><br>fig_histogram.add_trace(go.Histogram(x=df[&#39;Sales&#39;], name=&#39;Sales&#39;, histnorm=&#39;probability&#39;, opacity=0.7))<br><br>fig_histogram.update_layout(<br>    title=&#39;Sales Distribution (Histogram)&#39;,<br>    xaxis_title=&#39;Sales&#39;,<br>    yaxis_title=&#39;Probability&#39;,<br>    barmode=&#39;overlay&#39;,<br>    bargap=0.1,<br>    legend=dict(x=0.7, y=0.95),<br>    autosize=False,<br>    width=500,<br>    height=400<br>)<br><br><br>fig_boxplot = go.Figure()<br><br>fig_boxplot.add_trace(go.Box(y=df[&#39;Sales&#39;], name=&#39;Sales&#39;, boxpoints=&#39;all&#39;, jitter=0.3, pointpos=-1.8))<br><br>fig_boxplot.update_layout(<br>    title=&#39;Sales Distribution (Box Plot)&#39;,<br>    yaxis_title=&#39;Sales&#39;,<br>    autosize=False,<br>    width=500,<br>    height=400<br>)<br><br><br>mean = df[&#39;Sales&#39;].mean()<br>median = df[&#39;Sales&#39;].median()<br>max_value = df[&#39;Sales&#39;].max()<br><br>fig_histogram.add_shape(<br>    type=&#39;line&#39;,<br>    x0=mean,<br>    x1=mean,<br>    y0=0,<br>    y1=1,<br>    line=dict(color=&#39;red&#39;, width=3, dash=&#39;dash&#39;),<br>    name=&#39;Mean&#39;<br>)<br><br>fig_histogram.add_shape(<br>    type=&#39;line&#39;,<br>    x0=median,<br>    x1=median,<br>    y0=0,<br>    y1=1,<br>    line=dict(color=&#39;green&#39;, width=3, dash=&#39;dash&#39;),<br>    name=&#39;Median&#39;<br>)<br><br>fig_histogram.add_shape(<br>    type=&#39;line&#39;,<br>    x0=max_value,<br>    x1=max_value,<br>    y0=0,<br>    y1=1,<br>    line=dict(color=&#39;blue&#39;, width=3, dash=&#39;dash&#39;),<br>    name=&#39;Max&#39;<br>)<br><br><br>fig_dashboard = sp.make_subplots(rows=1, cols=2, subplot_titles=(&quot;Histogram&quot;, &quot;Box Plot&quot;))<br><br>fig_dashboard.add_trace(fig_histogram[&#39;data&#39;][0], row=1, col=1)<br>fig_dashboard.add_trace(fig_boxplot[&#39;data&#39;][0], row=1, col=2)<br><br>fig_dashboard.update_layout(height=600, width=1200, title_text=&quot;Sales Distribution Dashboard&quot;)<br><br><br>fig_dashboard.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*77keWN1CwxmRoWsOMXGTaA.png" /></figure><p>As we predicted above, our dataset exhibits a right-skewed distribution. Another remarkable point is that the sales value is at the maximum level. This value can be seen as quite an extreme value compared to the overall distribution of the data set and may even be considered an outlier. However, it would not be correct to say that this value is only contrary to the general data distribution. Let’s consider an example scenario; Let’s have Category and Sub-Category, which are different categorical variables in our dataset. Some of the sales that occur in the categories of these categorical variables may be high-priced products purchased in large quantities. This may result in the observed values in our data set. At this point, it is important to understand the relationship between numerical variables and categorical variables. We will carry out the next steps of our work with this focus. Now I will try to explore the categorical variables that interact with the target variable Sales in the dataset.</p><pre>from matplotlib import pyplot as plt<br>from matplotlib import figure<br>def desc_stats(dataframe):<br>    desc = dataframe.describe(percentiles =[0, 0.25, 0.50, 0.75, 0.85, 0.95, 0.99, 1]).T<br>    desc_df = pd.DataFrame(index= dataframe.columns, <br>                           columns= desc.columns,<br>                           data= desc)<br>    <br>    f,ax = plt.subplots(figsize=(20,<br>                                 desc_df.shape[0]*0.78))<br>    sns.heatmap(desc_df,<br>                annot=True,<br>                cmap = &quot;Wistia&quot;,<br>                fmt= &#39;.2f&#39;,<br>                ax=ax,<br>                linecolor=&#39;white&#39;,<br>                linewidths = 1.3,<br>                cbar = False,<br>                annot_kws={&quot;size&quot;: 12})<br>    plt.xticks(size = 18)<br>    plt.yticks(size = 14,<br>               rotation = 0)<br>    plt.title(&quot;Descriptive Statistics&quot;, size = 14)<br>    plt.show()<br><br><br>desc_stats(df[[col for col in df.columns if df[col].dtype in [&#39;int64&#39;, &#39;float64&#39;] ]])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RYxzFu50yfkQ539E4waG0g.png" /></figure><p>As we observed, the maximum value of the sales variable in the data set is much larger than the other quantile values. This indicates that sales values are generally low but increase significantly after 85%. For example, values up to 75% show a normal distribution, while a three-fold increase is observed between 85% and 95%. This may suggest that high resale values do occur, although rarely, and that customers with higher incomes usually shop in large volumes. By examining this relationship in more detail, we will try to understand the factors that affect sales value.</p><p>Now I will create a barplot to visualize the 10 highest revenue generating customers. This barplot will use the magnitude of sales values to color the bars representing each customer. This will enable us to more clearly highlight customers with higher sales values, allowing us to more easily identify the most important customers in terms of revenue. This visualization will help us identify the business’ main sources of revenue and the most valuable customer segments.</p><pre>customer_sales = df.groupby(&#39;Customer Name&#39;).agg({&#39;Sales&#39;:&quot;sum&quot;}).reset_index().sort_values(by = &quot;Sales&quot;, ascending = False)[:10]<br><br><br>fig = px.bar(customer_sales, x=&#39;Customer Name&#39;, y=&#39;Sales&#39;, hover_data=[&#39;Customer Name&#39;, &#39;Sales&#39;],<br>             labels={&#39;Customer Name&#39;: &#39;Customer Name&#39;, &#39;Sales&#39;: &#39;Sales&#39;}, <br>             color = &#39;Sales&#39;)<br><br><br>fig.update_traces(hovertemplate=&#39;Customer Name: %{x}&lt;br&gt;Sales: $%{y}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br>fig.update_layout(title=&#39;Top 10 Customer&#39;,width=1200, height=600)<br><br>fig.update_traces(text=customer_sales[&#39;Sales&#39;], <br>                  texttemplate=&#39;$%{text:.2f}&#39;, <br>                  textfont=dict(color=&#39;gray&#39;, size=14, family=&#39;Arial&#39;),<br>                  textangle=0,textposition=&#39;outside&#39;)<br><br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GgkPjMxqhg-17j0a01qsvA.png" /></figure><p>I create Barplot to examine the Sales variable relative to the State variable. There are 49 different state values in the data set, but I will be showing the 10 states with the most sales.</p><pre>state_sales = df.groupby(&#39;State&#39;).agg({&#39;Sales&#39;:&quot;sum&quot;, &quot;Order ID&quot;: lambda orderid: orderid.nunique()}).reset_index().sort_values(by = &quot;Sales&quot;, ascending = False)[:10]<br><br><br><br>fig = px.bar(state_sales, x=&#39;State&#39;, y=&#39;Sales&#39;, hover_data=[&#39;State&#39;, &#39;Sales&#39;],<br>             labels={&#39;State&#39;: &#39;State&#39;, &#39;Sales&#39;: &#39;Sales&#39;}, <br>             color = &#39;Sales&#39;)<br><br><br>fig.update_traces(hovertemplate=&#39;State: %{x}&lt;br&gt;Sales: $%{y}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br>fig.update_layout(title=&#39;Total Sales by State&#39;,width=1200, height=600)<br><br>fig.update_traces(text=state_sales[&#39;Sales&#39;], <br>                  texttemplate=&#39;$%{text:.2f}&#39;, <br>                  textfont=dict(color=&#39;gray&#39;, size=14, family=&#39;Arial&#39;),<br>                  textangle=0,textposition=&#39;outside&#39;)<br><br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r6X7WmwE6Mo6ML1yf1oMiQ.png" /></figure><pre>city_sales = df.groupby(&#39;City&#39;).agg({&#39;Sales&#39;:&quot;sum&quot;, &quot;Order ID&quot;: lambda orderid: orderid.nunique()}).reset_index().sort_values(by = &quot;Sales&quot;, ascending = False)[:10]<br><br><br><br>fig = px.bar(city_sales, x=&#39;City&#39;, y=&#39;Sales&#39;, hover_data=[&#39;City&#39;, &#39;Sales&#39;],<br>             labels={&#39;City&#39;: &#39;City&#39;, &#39;Sales&#39;: &#39;Sales&#39;}, <br>             color = &#39;Sales&#39;)<br><br><br>fig.update_traces(hovertemplate=&#39;City: %{x}&lt;br&gt;Sales: $%{y}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br>fig.update_layout(title=&#39;Total Sales by City&#39;,width=1200, height=600)<br><br>fig.update_traces(text=city_sales[&#39;Sales&#39;], <br>                  texttemplate=&#39;$%{text:.2f}&#39;, <br>                  textfont=dict(color=&#39;gray&#39;, size=14, family=&#39;Arial&#39;),<br>                  textangle=0,textposition=&#39;outside&#39;)<br><br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPyXcuJ6vBKDnBV3w6vAig.png" /></figure><p>When I examine the visualization, I see that the highest sales occurred in New York — NYC. However, the California state cities of LA, San Francisco and San Diego also have significant sales. One of the highlights on the chart is that California comes before New York. This shows that while New York has the most sales when compared at the City level, California is at the top of the list when compared at the State level. This shows that California’s overall sales volume is high and its different cities have a significant share of overall sales.</p><p>Alongside the sales values, I would like to analyze the number of orders received by the store for products purchased from these cities. I aim to determine whether there is a correlation between the sales value and the number of orders.</p><p>We examined sales values according to State and City. Finally, I create a barplot in the State variable to see the number of orders received.</p><pre>city_sales = df.groupby(&#39;City&#39;).agg({&quot;Order ID&quot;: lambda orderid: orderid.nunique()}).rename(columns = {&#39;Order ID&#39; : &#39;Order Count&#39;}).reset_index().sort_values(by = &quot;Order Count&quot;, ascending = False)[:10]<br><br><br><br>fig = px.bar(city_sales, x=&#39;City&#39;, y=&#39;Order Count&#39;, hover_data=[&#39;City&#39;, &#39;Order Count&#39;],<br>             labels={&#39;City&#39;: &#39;City&#39;, &#39;Order Count&#39;: &#39;Order Count&#39;}, <br>             color = &#39;Order Count&#39;)<br><br><br>fig.update_traces(hovertemplate=&#39;City: %{x}&lt;br&gt;Order Count: $%{y}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br>fig.update_layout(title=&#39;Total Sales by City&#39;,width=1200, height=600)<br><br>fig.update_traces(text=city_sales[&#39;Order Count&#39;], <br>                  texttemplate=&#39;%{text:.2f}&#39;, <br>                  textfont=dict(color=&#39;gray&#39;, size=14, family=&#39;Arial&#39;),<br>                  textangle=0,textposition=&#39;outside&#39;)<br><br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4b2IGW1BW9cc3ljeQ6hkQ.png" /></figure><p>I will create a donut chart to visualize the total amounts of invoices representing our customer segments. There are three main customer segments in our dataset: Consumer customers (Consumer), Corporate customers (Corporate) and Home Office segment. This pie chart will be used to show the ratio of invoice amount to total revenue for each customer segment. Thus, we will be able to see more clearly which customer segment generates the bulk of the operating income. By highlighting different segments with colors, we will be able to make a visual comparison of customer segments through each slice on the chart. This pie chart will help us understand the revenue contributions of customer segments and better shape our business strategies.</p><pre>segment_sales = df.groupby(&#39;Segment&#39;).agg({&quot;Sales&quot;:&quot;sum&quot;}).sort_values(by = &quot;Sales&quot;, ascending = False)<br>segment_sales = segment_sales[[&#39;Sales&#39;]]<br>segment_sales .reset_index(inplace = True)<br>total_revenues = segment_sales[&quot;Sales&quot;].sum() <br>total_revenues = str(int(total_revenues))<br>total_revenues = &#39;$&#39; + total_revenues <br><br><br>plt.rcParams[&quot;figure.figsize&quot;] = (10,6) <br>plt.rcParams[&#39;font.size&#39;] = 11.0 <br>plt.rcParams[&#39;font.weight&#39;] = 6 <br>colors = [&#39;#BC243C&#39;,&#39;#FE840E&#39;,&#39;#C62168&#39;] <br>explode = (0.05,0.05,0.05)<br>fig1, ax1 = plt.subplots()<br>ax1.pie(segment_sales[&#39;Sales&#39;], colors = colors, labels=segment_sales[&#39;Segment&#39;], autopct= autopct_format(segment_sales[&#39;Sales&#39;]),startangle=90,explode=explode)<br>centre_circle = plt.Circle((0,0),0.85,fc=&#39;white&#39;)<br>fig = plt.gcf()<br>fig.gca().add_artist(centre_circle)<br>ax1.axis(&#39;equal&#39;) <br>label = ax1.annotate(&#39;Total Revenue \n&#39;+str(total_revenues),color = &#39;red&#39;, xy=(0, 0), fontsize=12, ha=&quot;center&quot;)<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lP88dcOlM4vjhqXO1c8yHA.png" /></figure><p>In our dataset, there are 3 segments: Corporate, Home Office and Consumer. These customer segments indicate the nature of the customers who shop in the store. (Another possibility may be specifying the type of invoices the store has issued.)</p><p>When we look at the distribution in the data set, we see that the most individual customers shop. Corporate followed by consumers with a $688,494 share.</p><p>Well, I wonder in which categories and in which sub-categories these sales took place.</p><pre>topcat_subcat = df.groupby([&#39;Category&#39;,&#39;Sub-Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;}).sort_values(by = &quot;Sales&quot;, ascending=False)[:10]<br>topcat_subcat = topcat_subcat[[&quot;Sales&quot;]].astype(int)<br>topcat_subcat = topcat_subcat.sort_values(&quot;Category&quot;)<br>topcat_subcat.reset_index(inplace=True)<br>topcat_subcat_1 = topcat_subcat.groupby([&#39;Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;})<br>topcat_subcat_1.reset_index(inplace=True)<br><br><br>plt.rcParams[&quot;figure.figsize&quot;] = (15,10) <br>fig, ax = plt.subplots()<br>ax.axis(&#39;equal&#39;)<br>width = 0.1<br>outer_colors = [&#39;#FE840E&#39;,&#39;#009B77&#39;,&#39;#BC243C&#39;]<br>inner_colors = [&#39;Orangered&#39;,&#39;tomato&#39;,&#39;coral&#39;,&quot;darkturquoise&quot;,&quot;mediumturquoise&quot;,&quot;paleturquoise&quot;,&quot;lightpink&quot;,&quot;pink&quot;,&quot;hotpink&quot;,&quot;deeppink&quot;]<br>pie = ax.pie(topcat_subcat_1[&#39;Sales&#39;], radius=1, labels=topcat_subcat_1[&#39;Category&#39;],colors=outer_colors,wedgeprops=dict(edgecolor=&#39;w&#39;))<br>pie2 = ax.pie(topcat_subcat[&#39;Sales&#39;], radius=1-width, labels=topcat_subcat[&#39;Sub-Category&#39;],autopct= autopct_format(topcat_subcat[&#39;Sales&#39;]),labeldistance=0.7,colors=inner_colors,wedgeprops=dict(edgecolor=&#39;w&#39;), pctdistance=0.53,rotatelabels =True)<br>fraction_text_list = pie2[2]<br>for text in fraction_text_list: <br>    text.set_rotation(315) <br>centre_circle = plt.Circle((0,0),0.6,fc=&#39;white&#39;) <br>fig = plt.gcf()<br>fig.gca().add_artist(centre_circle)<br>ax1.axis(&#39;equal&#39;)  <br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKXVlRtt9sQtmwE6BW8DQw.png" /></figure><p>I am creating a donut chart to look at the distribution of Sales values according to the Ship mode variable in the data set.</p><pre>Top_shipping = df.groupby([&quot;Ship Mode&quot;]).agg({&#39;Sales&#39;:&#39;sum&#39;}).sort_values(by = &quot;Sales&quot;, ascending=False) <br>Top_shipping = Top_shipping[[&quot;Sales&quot;]]<br>Top_shipping.reset_index(inplace=True)<br>total_revenue_ship = Top_shipping[&quot;Sales&quot;].sum()<br>total_revenue_ship = str(int(total_revenue_ship))<br>total_revenue_ship = &#39;$&#39; + total_revenue_ship <br><br><br><br>plt.rcParams[&quot;figure.figsize&quot;] = (13,5) <br>plt.rcParams[&#39;font.size&#39;] = 12.0 <br>plt.rcParams[&#39;font.weight&#39;] = 6 <br>colors = [&#39;#BC243C&#39;,&#39;#FE840E&#39;,&#39;#C62168&#39;,&quot;limegreen&quot;] <br>fig1, ax1 = plt.subplots()<br>ax1.pie(Top_shipping[&#39;Sales&#39;], colors = colors, labels=Top_shipping[&#39;Ship Mode&#39;], autopct= autopct_format(Top_shipping[&#39;Sales&#39;]), startangle=90)<br>centre_circle = plt.Circle((0,0),0.82,fc=&#39;white&#39;) <br>fig = plt.gcf()<br>fig.gca().add_artist(centre_circle)<br><br>ax1.axis(&#39;equal&#39;) <br>label = ax1.annotate(&#39;Total Revenue \n&#39;+str(total_revenue_ship),color = &#39;red&#39;, xy=(0, 0), fontsize=12, ha=&quot;center&quot;)<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*cM-HELkwoEYuVBRJuIok1w.png" /></figure><p>When we examine the purchased products according to the type of shipment, the result we see is that the shipment was made in the standard class category at most. The highest technology expenditures were realized in shipments made in First Class and Same Day class.</p><p>We examined the distribution of the Sales variable according to the various categorical variables we have. Now I want to examine the Product Name variable, which contains many unique values. I want to see the products with the highest number of sales and the products with the highest income, respectively, and then I want to see the products with the highest sales with a donut chart.</p><pre>df_pop_items = df[[&#39;Product Name&#39;, &#39;Sales&#39;, &#39;Order ID&#39;]].groupby([&#39;Product Name&#39;]).agg({&#39;Sales&#39; : &#39;sum&#39;,&#39;Order ID&#39; : &#39;count&#39;}).rename(columns = {&#39;Order ID&#39; : &#39;Order Count&#39;, &#39;Sales&#39; : &#39;Total Sales&#39;}).reset_index().sort_values(by  = &#39;Order Count&#39;, ascending = False)[:10]<br>df_pop_items2 = df[[&#39;Product Name&#39;, &#39;Sales&#39;, &#39;Order ID&#39;]].groupby([&#39;Product Name&#39;]).agg({&#39;Sales&#39; : &#39;sum&#39;,&#39;Order ID&#39; : &#39;count&#39;}).rename(columns = {&#39;Order ID&#39; : &#39;Order Count&#39;, &#39;Sales&#39; : &#39;Total Sales&#39;}).reset_index().sort_values(by  = &#39;Total Sales&#39;, ascending = False)[:10]<br><br>print(&#39;Best Selling Products (By Order Amount)&#39; , df_pop_items, sep = &#39;\n&#39;, end = &#39;\n\n\n&#39;)<br>print(&#39;Best Selling Products (By Sales Amount)&#39; , df_pop_items2, sep = &#39;\n&#39;, end = &#39;\n\n&#39;)<br><br><br><br># Output :<br><br>Best Selling Products (By Order Amount)<br>                                           Product Name  Total Sales  Order Count<br>1492                                    Staple envelope      1675.65           47<br>1498                                            Staples       755.47           46<br>537                                   Easy-staple paper      2414.16           44<br>259                             Avery Non-Stick Binders       217.32           20<br>1495                                     Staple remover       263.09           18<br>1499                            Staples in misc. colors       459.66           18<br>941                          KI Adjustable-Height Table      4466.66           17<br>1510                            Storex Dura Pro Binders       278.59           17<br>1496                         Staple-based wall hangings       422.29           16<br>992   Logitech 910-002974 M325 Wireless Mouse for We...      1409.53           15<br><br><br>Best Selling Products (By Sales Amount)<br>                                          Product Name  Total Sales  Order Count<br>404              Canon imageCLASS 2200 Advanced Copier     61599.82            5<br>649  Fellowes PB500 Electric Punch Plastic Comb Bin...     27453.38           10<br>444  Cisco TelePresence System EX90 Videoconferenci...     22638.48            1<br>785       HON 5400 Series Task Chairs for Big and Tall     21870.58            8<br>685         GBC DocuBind TL300 Electric Binding System     19823.48           11<br>687   GBC Ibimaster 500 Manual ProClick Binding System     19024.50            9<br>804               Hewlett Packard LaserJet 3310 Copier     18839.69            8<br>786  HP Designjet T520 Inkjet Large Format Printer ...     18374.90            3<br>682          GBC DocuBind P400 Electric Binding System     17965.07            6<br>812        High Speed Automatic Electric Letter Opener     17030.31            3</pre><p>In the above list, we see the products with the highest sales in terms of income (Total Sales) and the number of purchases (Item Count) provided to the store. The highest sales amount is seen as ‘Staple Envelope’ according to the number of units.</p><p>When we sort the list in this way, we see more of the effect on the sales value of some products. For example, the price paid for the product named ‘Cisco TelePresence System EX90 Videoconferenci…’ is $22638, even if one purchase is made. It’s a pretty expensive item.</p><pre>Top_products = df.groupby([&quot;Product Name&quot;]).agg({&#39;Sales&#39;:&#39;sum&#39;}).sort_values(&quot;Sales&quot;,ascending=False).head(8) <br>Top_products = Top_products[[&quot;Sales&quot;]].round(2)<br>Top_products.reset_index(inplace=True) <br>total_revenue_products = &#39;$&#39; +str(int(Top_products[&quot;Sales&quot;].sum())) <br><br>plt.rcParams[&quot;figure.figsize&quot;] = (13,7)<br>plt.rcParams[&#39;font.size&#39;] = 12.0 <br>colors = [&#39;#ff9999&#39;,&#39;#66b3ff&#39;,&#39;#99ff99&#39;,&#39;#ffcc99&#39;,&#39;#55B4B0&#39;,&#39;#E15D44&#39;,&#39;#009B77&#39;,&#39;#B565A7&#39;] # colors are defined for the pie chart<br>explode = (0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05)<br>fig1, ax1 = plt.subplots()<br>ax1.pie(Top_products[&#39;Sales&#39;], colors = colors, labels=Top_products[&#39;Product Name&#39;], autopct= autopct_format(Top_products[&#39;Sales&#39;]), startangle=90,explode=explode)<br>centre_circle = plt.Circle((0,0),0.80,fc=&#39;white&#39;) <br>fig = plt.gcf()<br>fig.gca().add_artist(centre_circle)<br><br>ax1.axis(&#39;equal&#39;)  <br>label = ax1.annotate(&#39;Total Revenue \n of these products \n&#39;+str(total_revenue_products),color = &#39;red&#39;, xy=(0, 0), fontsize=12, ha=&quot;center&quot;)<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uIzhKkFBEjbQfQRZzdEIJQ.png" /></figure><p>We completed our exploratory data analysis study based on the categorical variables in the data set. If you remember, we had two date type variables in the data set, Ship Date and Order Date. In the current stage, I want to analyze the time-dependent changes of our Sales variable according to the Order Date between these two variables. Next, I will once again use line charts to visualize how the Sales variable changes over time across different categorical variables.</p><pre>df_time = df.copy()<br><br>df_time[&#39;Order Date&#39;] = pd.to_datetime(df[&#39;Order Date&#39;], format=&#39;%d/%m/%Y&#39;)<br>df_time[&#39;Ship Date&#39;] = pd.to_datetime(df[&#39;Ship Date&#39;], format=&#39;%d/%m/%Y&#39;)<br><br>df_time[&#39;Month-Year&#39;] = df_time[&#39;Order Date&#39;].dt.strftime(&#39;%b-%Y&#39;)<br><br>monthly_sales = df_time.groupby(&#39;Month-Year&#39;).agg({&#39;Sales&#39;: &#39;sum&#39;}).reset_index()<br>monthly_sales[&#39;Order&#39;] = pd.to_datetime(monthly_sales[&#39;Month-Year&#39;], format=&#39;%b-%Y&#39;)<br>monthly_sales = monthly_sales.sort_values(&#39;Order&#39;)<br><br><br>fig = px.line(monthly_sales, x=&#39;Month-Year&#39;, y=&#39;Sales&#39;, title=&#39;Monthly Sales&#39;,<br>              labels={&#39;Month-Year&#39;: &#39;Month-Year&#39;, &#39;Sales&#39;: &#39;Sales&#39;})<br><br>fig.update_traces(hovertemplate=&#39;Date: %{x}&lt;br&gt;Sales: %{y:,.2f}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br><br>fig.update_xaxes(tickangle=90, tickmode=&#39;array&#39;, tickvals=monthly_sales[&#39;Month-Year&#39;],<br>                 ticktext=monthly_sales[&#39;Month-Year&#39;])<br><br><br>fig.update_layout(width=900, height=600)<br><br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*6D_b1xz5-j03_HzyT5N6XA.png" /></figure><p>When we analyze the change in sales values over time, it initially appears that there is a trend in the series. However, it would be premature to draw conclusions based solely on appearance. To provide a more accurate interpretation, we can refer to the Augmented Dickey-Fuller (ADF) test. I will proceed with our time series analysis.</p><pre>def time_breakdown(dataframe = dataset, date_col = &#39;Order Date&#39;,categorical_columns = cat_cols, threshold = 15):<br>    dataframe[f&#39;Month_Year_{date_col}&#39;] = dataframe[date_col].dt.strftime(&#39;%b-%Y&#39;)<br>    for cat_col in categorical_columns:<br>        if dataframe[cat_col].nunique() &lt;= threshold:<br>            monthly_sales = dataframe.groupby([f&#39;Month_Year_{date_col}&#39;,cat_col]).agg({&#39;Sales&#39;: &#39;sum&#39;}).reset_index()<br>            monthly_sales[&#39;Order&#39;] = pd.to_datetime(monthly_sales[f&#39;Month_Year_{date_col}&#39;], format=&#39;%b-%Y&#39;)<br>            monthly_sales = monthly_sales.sort_values(&#39;Order&#39;)<br><br><br>            fig = px.line(monthly_sales, x=f&#39;Month_Year_{date_col}&#39;, y=&#39;Sales&#39;, title=&#39;Monthly Sales&#39;,<br>              labels={f&#39;Month-Year_{date_col}&#39;: f&#39;Month_Year_{date_col}&#39;, &#39;Sales&#39;: &#39;Sales&#39;}, color = cat_col)<br><br>            fig.update_traces(hovertemplate=&#39;Date: %{x}&lt;br&gt;Sales: %{y:,.2f}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br><br>            fig.update_xaxes(tickangle=90, tickmode=&#39;array&#39;, tickvals=monthly_sales[f&#39;Month_Year_{date_col}&#39;],<br>                     ticktext=monthly_sales[f&#39;Month_Year_{date_col}&#39;])<br><br><br>            fig.update_layout(width=1000, height=600)<br><br><br>            fig.show()</pre><pre>time_breakdown(df_time, &#39;Order Date&#39;, categorical_columns = categorical_columns, threshold = 10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*S8nA3g9RhUH0TJMsmm2D5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dvB94DBJQnfMMqb-xSPEEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*1WOtBiBsklRq9IbnRAKB3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*VFCD7SGtByFL9BoYN8Fknw.png" /></figure><p>I create a function to analyze the variation in sales values over time based on the categorical variables in our dataset. This function efficiently presents the sales value breakdown of the specified categorical columns as a list, in relation to time.</p><p>Now, I am generating new time variables by utilizing the Order Date column we possess. Subsequently, I will explore the fluctuations in product sales over time.</p><pre>df_time[&#39;WeekDay&#39;] = df_time[&#39;Order Date&#39;].dt.day_name()<br><br>start_date = df_time[&#39;Order Date&#39;].min()<br>df_time[&#39;Week&#39;] = ((((df_time[&#39;Order Date&#39;] - start_date).dt.days)/7) +1).astype(int)</pre><p>We have previously seen the Sales Change according to the Order Date variable. But I didn’t create this chart day by day. Now it’s time to recreate the chart.</p><pre>df_plot = df_time.groupby(&#39;Order Date&#39;).agg({&#39;Sales&#39;:&#39;sum&#39;}).rename(columns = {&#39;Sales&#39;:&#39;Total Sales&#39;}).reset_index().sort_values(by = &#39;Order Date&#39;, ascending = True)<br><br>fig = px.line(df_plot, x=&quot;Order Date&quot;, y=&quot;Total Sales&quot;, title=&#39;Total Sales by Date&#39;)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*K6ZIlN2mYyS9fqK3LClDMA.png" /></figure><p>As observed in the figure, there is no apparent pattern in sales concerning the number of orders. However, upon closer examination, we can identify a seasonality trend.When we create a line plot based on the Total Sales Value, we do not discern a clear seasonality pattern.Furthermore, there is no distinct daily trend in the data. We will conduct tests to ascertain the stationarity and seasonality of the data.My next objective is to investigate whether there are variations in sales on different days of the week.In other words, I plan to group the days of the week to determine if sales peak on specific days.</p><pre>day_order = [&#39;Monday&#39;, &#39;Tuesday&#39;, &#39;Wednesday&#39;, &#39;Thursday&#39;, &#39;Friday&#39;, &#39;Saturday&#39;, &#39;Sunday&#39;]<br><br>df_plot_dayofweek = df_time[[&#39;WeekDay&#39;, &#39;Sales&#39;, &#39;Order ID&#39;]].groupby([&#39;WeekDay&#39;]).agg({&#39;Sales&#39;: &#39;sum&#39;, &#39;Order ID&#39;: &#39;count&#39;}).rename(columns = {&#39;Sales&#39;: &#39;Total Sales&#39;, &#39;Order ID&#39;:&#39;Order Count&#39;}).reset_index()<br><br>df_plot_dayofweek = df_plot_dayofweek.set_index(&#39;WeekDay&#39;).loc[day_order].reset_index()<br><br>fig_dayofweek = px.bar(df_plot_dayofweek, x = &#39;WeekDay&#39;, y = &#39;Order Count&#39;,hover_data=[&#39;WeekDay&#39;, &#39;Order Count&#39;], <br>                       labels={&#39;WeekDay&#39;: &#39;WeekDay&#39;, &#39;Order Count&#39;: &#39;Order Count&#39;}, <br>                       color = &#39;Order Count&#39;)<br>    <br>fig_dayofweek.update_traces(hovertemplate=&#39;WeekDay: %{x}&lt;br&gt;Order Count: %{y}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br>fig_dayofweek.update_layout(title=&#39;Total Sales by Day Of Week&#39;,width=1200, height=600)<br><br>fig_dayofweek.update_traces(text=df_plot_dayofweek[&#39;Order Count&#39;], <br>                  texttemplate=&#39;%{text:.2f}&#39;, <br>                  textfont=dict(color=&#39;gray&#39;, size=14, family=&#39;Arial&#39;),<br>                  textangle=0,textposition=&#39;outside&#39;)<br>fig_dayofweek.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFKpOqkPYLeVNA3D47zu9g.png" /></figure><p>As evident in the chart, sales experience peaks on certain Tuesdays and gradually decrease until Thursday. During the weekends, they begin to rise again.</p><pre>day_order = [&#39;Monday&#39;, &#39;Tuesday&#39;, &#39;Wednesday&#39;, &#39;Thursday&#39;, &#39;Friday&#39;, &#39;Saturday&#39;, &#39;Sunday&#39;]<br><br>df_plot_dayofweek = df_time[[&#39;WeekDay&#39;, &#39;Sales&#39;, &#39;Order ID&#39;]].groupby([&#39;WeekDay&#39;]).agg({&#39;Sales&#39;: &#39;sum&#39;, &#39;Order ID&#39;: &#39;count&#39;}).rename(columns = {&#39;Sales&#39;: &#39;Total Sales&#39;, &#39;Order ID&#39;:&#39;Order Count&#39;}).reset_index()<br><br>df_plot_dayofweek = df_plot_dayofweek.set_index(&#39;WeekDay&#39;).loc[day_order].reset_index()<br><br>fig_dayofweek = px.bar(df_plot_dayofweek, x = &#39;WeekDay&#39;, y = &#39;Total Sales&#39;,hover_data=[&#39;WeekDay&#39;, &#39;Total Sales&#39;], <br>                       labels={&#39;WeekDay&#39;: &#39;WeekDay&#39;, &#39;Total Sales&#39;: &#39;Total Sales&#39;}, <br>                    color = &#39;Total Sales&#39;)<br>    <br>fig_dayofweek.update_traces(hovertemplate=&#39;WeekDay: %{x}&lt;br&gt;Total Sales: $%{y}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br>fig_dayofweek.update_layout(title=&#39;Total Sales by Day Of Week&#39;,width=1200, height=600)<br><br>fig_dayofweek.update_traces(text=df_plot_dayofweek[&#39;Total Sales&#39;], <br>                  texttemplate=&#39;$%{text:.2f}&#39;, <br>                  textfont=dict(color=&#39;gray&#39;, size=14, family=&#39;Arial&#39;),<br>                  textangle=0,textposition=&#39;outside&#39;)<br>fig_dayofweek.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLfiXz9ZGVqam6T1Z88X8Q.png" /></figure><p>When we examine the sales values and the number of products sold separately by day, we notice that the highest product sales occur on Tuesday, followed by Tuesday, Saturday, and Monday. However, in terms of revenue, the days with the highest product sales are Saturday, Tuesday, Monday, and Wednesday. Interestingly, Sunday, which ranks highest in terms of product sales, falls to a lower rank in terms of revenue.</p><p>Based on this observation, we can conclude that items with higher monetary value are typically ordered on Saturdays. Since Tuesday tops both charts, it implies that products sold on Tuesdays are not only numerous but also valuable. On Wednesdays, similar to Saturdays, there is a lower volume of orders, but these orders tend to be more valuable</p><p>Now I want to reduce my time series analysis to a slightly smaller lens and look at the course of sales over a year. I would like to continue my work by creating a variable named single_year to examine the sales made in 2017 at random from the series.</p><pre>SINGLE_YEAR = 2017<br><br>df_sales_single_year = df_time[df_time[&#39;Order Date&#39;].dt.year == SINGLE_YEAR]<br>df_plot_single_year = df_sales_single_year[[&#39;Order Date&#39;,&#39;Sales&#39;,&#39;Order ID&#39;]].groupby([&#39;Order Date&#39;]).agg({&#39;Sales&#39;: &#39;sum&#39;, &#39;Order ID&#39;:&#39;count&#39;}).rename(columns = {&#39;Sales&#39;:&#39;Total Sales&#39;, &#39;Order ID&#39;: &#39;Order Count&#39;}).reset_index() <br>fig = px.bar(df_plot_single_year, x=&#39;Order Date&#39;, y=&#39;Order Count&#39;,facet_col_spacing=0, title=f&#39;Total Sales by Day {SINGLE_YEAR}&#39;)<br>fig.update_layout(bargap=0.0,bargroupgap=0.0, height = 600, width = 1200)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aok_t7kBVO0KxgMHRdvjcg.png" /></figure><pre>df_plot = df_sales_single_year[[&#39;Order Date&#39;,&#39;Category&#39;, &#39;Sales&#39;,&#39;Order ID&#39;]].groupby([&#39;Order Date&#39;,&#39;Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;, &#39;Order ID&#39;:&#39;count&#39;}).rename(columns = {&#39;Sales&#39;: &#39;Total Sales&#39;, &#39;Order ID&#39;: &#39;Order Count&#39;}).reset_index()<br>fig = px.bar(df_plot, x=&#39;Order Date&#39;, y=&#39;Total Sales&#39;,color=&quot;Category&quot;, title=f&#39;Item Sales by Date - {SINGLE_YEAR}&#39;)<br>fig.update_layout(bargap=0.0,bargroupgap=0.0, height = 600, width = 1200, showlegend = True)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RU8XLG-3k7Q5391xP9n-GQ.png" /></figure><pre>df_plot_weekly = df_sales_single_year[[&#39;Week&#39;,&#39;Category&#39;,&#39;Order ID&#39;,&#39;Sales&#39;]].groupby([&#39;Week&#39;,&#39;Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;, &#39;Order ID&#39;: &#39;count&#39;}).rename(columns = {&#39;Sales&#39;: &#39;Total Sales&#39;, &#39;Order ID&#39; : &#39;Order Count&#39;}).reset_index()<br>fig = px.bar(df_plot_weekly, x=&#39;Week&#39;, y=&#39;Total Sales&#39;,color=&quot;Category&quot;, title=f&#39;Total Sales by Week - {SINGLE_YEAR}&#39;)<br>fig.update_layout(bargap=0.0,bargroupgap=0.0, height = 600 , width = 1200, showlegend = True)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ifBLj9BXC4wwMgYtNRr5YA.png" /></figure><pre>day_order = [&quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;, &quot;Sunday&quot;]<br><br>df_plot_daily = df_time[[&#39;WeekDay&#39;,&#39;Category&#39;,&#39;Sales&#39;]].groupby([&#39;WeekDay&#39;,&#39;Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;}).rename(columns = {&#39;Sales&#39;:&#39;Total Sales&#39;}).reset_index()<br>df_plot_daily = df_plot_daily.set_index(&#39;WeekDay&#39;).loc[day_order].reset_index()<br>fig = px.bar(df_plot_daily, x=&#39;WeekDay&#39;, y=&#39;Total Sales&#39;,color=&quot;Category&quot;, title=f&#39;Total Sales by Day of Week - {SINGLE_YEAR}&#39;)<br>fig.update_layout(bargap=0.0,bargroupgap=0.0, height = 600 , width = 900, showlegend = True)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*nmqkyAlcdU_yM3blwKkGMQ.png" /></figure><pre>df_pop_cats = df_time[[&#39;Sub-Category&#39;, &#39;Sales&#39;, &#39;Order ID&#39;]].groupby([&#39;Sub-Category&#39;]).agg({&#39;Sales&#39; : &#39;sum&#39;,&quot;Order ID&quot;: lambda orderid: orderid.nunique()}).rename(columns = {&#39;Order ID&#39; : &#39;Order Amount&#39;, &#39;Sales&#39; : &#39;Total Sales&#39;}).reset_index().sort_values(by  = &#39;Total Sales&#39;, ascending = False)<br>df_pop_cats[:10]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*Lp28-az9MdOw4tGBId3X9Q.png" /></figure><pre>df_plot_sc = df_sales_single_year[[&#39;Order Date&#39;,&#39;Sub-Category&#39;, &#39;Sales&#39;]].groupby([&#39;Order Date&#39;,&#39;Sub-Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;}).rename(columns = {&#39;Sales&#39;: &#39;Total Sales&#39;}).reset_index()<br>fig = px.bar(df_plot_sc, x=&#39;Order Date&#39;, y=&#39;Total Sales&#39;,color=&quot;Sub-Category&quot;, title=f&#39;Item Sales by Date - {SINGLE_YEAR}&#39;)<br>fig.update_layout(bargap=0.0,bargroupgap=0.0, height = 600, width = 900)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*tBFEH4qmistmIOTGPgwS4g.png" /></figure><pre>df_plot_sc_weekly = df_sales_single_year[[&#39;Week&#39;,&#39;Sub-Category&#39;,&#39;Sales&#39;]].groupby([&#39;Week&#39;,&#39;Sub-Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;}).rename(columns = {&#39;Sales&#39;: &#39;Total Sales&#39;}).reset_index()<br>fig = px.bar(df_plot_sc_weekly, x=&#39;Week&#39;, y=&#39;Total Sales&#39;,color=&quot;Sub-Category&quot;, title=f&#39;Total Sales by Week - {SINGLE_YEAR}&#39;)<br>fig.update_layout(bargap=0.0,bargroupgap=0.0, height = 600 , width = 900)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*B2_VwEU0I1ywLRkWQuiT4A.png" /></figure><pre>day_order = [&quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;, &quot;Sunday&quot;]<br><br>df_plot_sc_daily = df_time[[&#39;WeekDay&#39;,&#39;Sub-Category&#39;,&#39;Sales&#39;]].groupby([&#39;WeekDay&#39;,&#39;Sub-Category&#39;]).agg({&#39;Sales&#39;:&#39;sum&#39;}).rename(columns = {&#39;Sales&#39;:&#39;Total Sales&#39;}).reset_index()<br>df_plot_sc_daily = df_plot_sc_daily.set_index(&#39;WeekDay&#39;).loc[day_order].reset_index()<br>fig = px.bar(df_plot_sc_daily, x=&#39;WeekDay&#39;, y=&#39;Total Sales&#39;,color=&quot;Sub-Category&quot;, title=f&#39;Total Sales by Day of Week - {SINGLE_YEAR}&#39;)<br>fig.update_layout(bargap=0.0,bargroupgap=0.0, height = 600 , width = 900)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*CVMPDwLVCwEhM6Ke36RBgw.png" /></figure><p>When analyzing sales changes in the Phones category, which boasts the highest sales value among sub-categories, we notice that peak phone sales occurred on Monday and the following Tuesday. Thursday experienced the lowest phone sales due to a general decline in store sales, but it’s noteworthy that the phone subcategory still represented the largest share of daily sales on Thursdays.</p><p>Another distinct sales pattern emerges in the Machines subcategory, where machine sales appear to reach their peak on Wednesdays and Sundays.</p><p>Within the furniture section, the Chairs subcategory exhibits a consistent sales trend. Upon closer inspection, it becomes evident that Tuesdays and Saturdays are the days when the most chairs are sold.</p><p>Before proceeding to the modeling and preprocessing stages, I intend to evaluate the stationarity and seasonality of the time series data as part of the time series analysis. My aim is to determine whether any seasonality or stationarity exists within our data.</p><p>I completed my time series analysis studies based on the Order Date variable. Now I want to test the stationarity of the time series.</p><pre>df_time[&#39;Month-Year&#39;] = df_time[&#39;Order Date&#39;].dt.strftime(&#39;%b-%Y&#39;)<br><br>monthly_sales = df_time.groupby(&#39;Month-Year&#39;).agg({&#39;Sales&#39;: &#39;sum&#39;}).reset_index()<br>monthly_sales[&#39;Order&#39;] = pd.to_datetime(monthly_sales[&#39;Month-Year&#39;], format=&#39;%b-%Y&#39;)<br>monthly_sales = monthly_sales.sort_values(&#39;Order&#39;)<br><br><br>fig = px.line(monthly_sales, x=&#39;Month-Year&#39;, y=&#39;Sales&#39;, title=&#39;Monthly Sales&#39;,<br>              labels={&#39;Month-Year&#39;: &#39;Month-Year&#39;, &#39;Sales&#39;: &#39;Sales&#39;})<br><br>fig.update_traces(hovertemplate=&#39;Date: %{x}&lt;br&gt;Sales: $%{y:,.2f}&lt;extra&gt;&lt;/extra&gt;&#39;)<br><br><br>fig.update_xaxes(tickangle=90, tickmode=&#39;array&#39;, tickvals=monthly_sales[&#39;Month-Year&#39;],<br>                 ticktext=monthly_sales[&#39;Month-Year&#39;])<br><br><br>fig.update_layout(width=900, height=600)<br><br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*6D_b1xz5-j03_HzyT5N6XA.png" /></figure><p>At first glance, we can readily observe a clear trend in the time series data. When we group the sales data by Month-Year, it becomes evident that sales are consistently increasing over time.</p><p>The other tests I will conduct include assessments for seasonality, cyclical patterns, and stagnation. In the initial overview, we observe that the time series data exhibits seasonality, reaching peak points at specific intervals. The concept of cyclicality is somewhat similar to seasonality, even though it may not have a substantial impact on forecasting processes. Understanding it can be valuable. It refers to a series repeating a certain pattern at specific intervals. For instance, we expect ice cream sales to rise during the summer months. If we were to model ice cream sales, we would find that they consistently follow the same pattern during the summer months.</p><pre>plt.figure(figsize = (15,6))<br>plt.style.use(&#39;seaborn-colorblind&#39;)<br>plt.grid(True, alpha = 0.6)<br><br>sns.kdeplot(df.sort_values(by= [&#39;Order Date&#39;],  ascending=True).loc[(df[&#39;Order Date&#39;] == &#39;2015-03-24&#39;), &#39;Sales&#39;], label = &#39;2015-March&#39;)<br>sns.kdeplot(df.sort_values(by= [&#39;Order Date&#39;],  ascending=True).loc[(df[&#39;Order Date&#39;] == &#39;2016-03-24&#39;), &#39;Sales&#39;], label = &#39;2016-March&#39;)<br>sns.kdeplot(df.sort_values(by= [&#39;Order Date&#39;],  ascending=True).loc[(df[&#39;Order Date&#39;] == &#39;2017-03-24&#39;), &#39;Sales&#39;], label = &#39;2017-March&#39;)<br><br>plt.xlim(left = 0, right = 5000)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3IbramsjTapz83pkmow5XQ.png" /></figure><p>As you can see, when I look at the distribution of same-day sales data in 3 different years, the data is not normally distributed. That’s why I want to use the median value instead of the average in the resample function to examine sales data within a day.</p><pre>df[&#39;Order Date&#39;] = pd.to_datetime(df[&#39;Order Date&#39;], format=&#39;%d/%m/%Y&#39;)<br>df_sorted = df.sort_values(by= [&#39;Order Date&#39;],  ascending=True)<br><br>df_sorted = df_sorted.set_index(&quot;Order Date&quot;)<br><br><br>df_time = pd.DataFrame(df_sorted[&#39;Sales&#39;])<br><br>df_time =  pd.DataFrame(df_time[&#39;Sales&#39;].resample(&#39;D&#39;).median())<br>df_time = df_time.interpolate(method=&#39;linear&#39;)</pre><pre>from statsmodels.tsa.stattools import adfuller<br>adf = adfuller(df_time) <br><br>print(adf)<br>print(&#39;\nADF = &#39;, str(adf[0])) <br>print(&#39;\np-value = &#39;, str(adf[1]))<br>print(&#39;\nCritical Values: &#39;)<br><br>for key, val in adf[4].items(): #for loop to print the p-value (1%, 5% and 10%) and their respective values<br>    print(key,&#39;:&#39;,val)<br><br>    if adf[0] &lt; val:<br>        print(&#39;Null Hypothesis Rejected. Time Series is Stationary&#39;)<br>    else:<br>        print(&#39;Null Hypothesis Accepted. Time Series is not Stationary&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4-AXGxhW8SvCIzD_J72QQ.png" /></figure><p>To test whether the series is stationary, we use the adfuller test in the statsmodels library. According to this test, we got the result that our data set is stationary. This is interesting because when we drew the line graph, we saw that the dataset was in an upward trend. Let’s do our other test..</p><pre>import matplotlib.pyplot as plt<br><br>def is_stationary(y):<br><br>    # &quot;HO: Non-stationary&quot;<br>    # &quot;H1: Stationary&quot;<br><br>    p_value = sm.tsa.stattools.adfuller(y)[1]<br>    if p_value &lt; 0.05:<br>        print(F&quot;Result: Stationary (H0: non-stationary, p-value: \<br>          {round(p_value, 3)})&quot;)<br>    else:<br>        print(F&quot;Result: Non-Stationary (H0: non-stationary, p-value: \<br>          {round(p_value, 3)})&quot;)<br><br>def ts_decompose(y, model=&quot;additive&quot;, stationary=False):<br>    result = sm.tsa.seasonal_decompose(y, model=model)<br>    fig, axes = plt.subplots(4, 1, sharex=True, sharey=False)<br>    fig.set_figheight(8)<br>    fig.set_figwidth(10)<br><br>    axes[0].set_title(&quot;Decomposition for &quot; + model + &quot; model&quot;)<br>    axes[0].plot(y, &#39;k&#39;, label=&#39;Original &#39; + model)<br>    axes[0].legend(loc=&#39;upper left&#39;)<br><br>    axes[1].plot(result.trend, label=&#39;Trend&#39;)<br>    axes[1].legend(loc=&#39;upper left&#39;)<br><br>    axes[2].plot(result.seasonal, &#39;g&#39;, label=&#39;Seasonality &amp; Mean: &#39; + str(round(result.seasonal.mean(), 4)))<br>    axes[2].legend(loc=&#39;upper left&#39;)<br><br>    axes[3].plot(result.resid, &#39;r&#39;, label=&#39;Residuals &amp; Mean: &#39; + str(round(result.resid.mean(), 4)))<br>    axes[3].legend(loc=&#39;upper left&#39;)<br>    plt.show(block=True)<br><br>    if stationary:<br>        is_stationary(y)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FUHQAYUGUuvAISBh579z_w.png" /></figure><p>We now agree that the Dataset is stationary. With the tests we have done, we have seen that our interpretation of ‘The data set is in an upward trend’ is not true.</p><p>I would like to explain the above chart simply. In this image, the top chart provides us with the level information of the data set and allows us to make up our minds about whether the series is stationary or not. The second chart provides trend information, the third chart seasonality information. Finally, the Residuals graph shows the residuals. The residuals show the deviation levels around the data. In the expected case, the mean of the residues around zero is 0.</p><p>I finished to EDA &amp; Time Series Analysis, I will build some ML or DL model. See u soon :)</p><p>Contact :</p><p><a href="https://www.linkedin.com/in/cemozcel%C4%B1k/">Linkedn</a></p><p><a href="https://www.kaggle.com/smailcemzelk">Kaggle</a></p><h4><a href="https://mlearning.substack.com/about">BECOME a WRITER at MLearning.ai</a> // <a href="https://open.substack.com/pub/mlearning/p/top-5-text-to-video-tools-in-comparison?r=z7zu8&amp;utm_campaign=post&amp;utm_medium=web">text-to-video</a> // <a href="https://open.substack.com/pub/mlearning/p/how-to-detect-image-generated-by-ai?r=z7zu8&amp;utm_campaign=post&amp;utm_medium=web">Detect AI img</a></h4><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8011ffde303a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Explatory Data Analysis Project On Retails]]></title>
            <link>https://medium.com/@i.cemozcelik/explatory-data-analysis-project-on-retails-aabd5e723210?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/aabd5e723210</guid>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[retail]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 14:09:26 GMT</pubDate>
            <atom:updated>2023-04-17T20:43:19.394Z</atom:updated>
            <content:encoded><![CDATA[<p>Istanbul is one of the most popular cities in the world, there are many reasons why it is such a popular city. Its historical monuments, cosmopolitan structure and lively nightlife are the factors that make Istanbul a center of attraction. At the same time, it is seen as a good spending center for millions of people for shopping. In this article, we will be diving into the shopping world of Istanbul. Without further ado, let’s dive in to our study…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftwdkPy-kfUEgeVkPCPCDg.jpeg" /><figcaption>Photograph Via : <a href="https://pixabay.com/tr/users/steven_yu-2625920/">Steven Yu </a>| Pexels, Pixabay</figcaption></figure><p>Hello, my previous work <a href="https://medium.com/mlearning-ai/analyzing-and-visualizing-earthquake-data-received-with-usgs-api-in-python-environment-8c7e7b6bed02"><em>Analyzing and Visualizing Earthquake Data Received with USGS API in Python Environment</em></a><em> </em>I prepared a new work after 3 weeks. Previously, I did <a href="https://medium.com/mlearning-ai/crm-analytics-customer-segmentation-customer-lifetime-value-prediction-1163fa6e4ae9">CRM</a> work and <a href="https://medium.com/@i.cemozcelik/data-science-project-sales-forecasting-with-arima-model-67321d547866">forecasting work</a> with a time series on the retail industry. Now, I will be conducting an exploratory data analysis study.</p><p>In this study, I will be conducting an exploratory data analysis study on the <a href="https://www.kaggle.com/datasets/mehmettahiraslan/customer-shopping-dataset">Customer Shopping Dataset — Retail Sales Data</a> dataset published on Kaggle by my dear friend <a href="https://www.kaggle.com/mehmettahiraslan">Mehmet Tahir Arslan</a>, who is among my <a href="https://www.linkedin.com/in/cemozcel%C4%B1k/">LinkedIn </a>connections.</p><p>We will recognize the dataset and create new variables (See Feature Engineering) Afterwards, we will do data visualization studies using data visualization libraries (Seaborn, Matplotlib, Plotly). We will also be seeing the findings we have obtained from these graphs that we have created.</p><p>Shopping occupies an important place in people’s lives. Shopping has become a necessity for people for reasons such as meeting daily needs, satisfying personal pleasures, and discovering new products.</p><p>Although the time spent in shopping centers varies according to personal preferences and reasons, it can vary between 1–2 hours, which corresponds to an average day, in general. However, longer periods can be spent, especially on weekends and holidays.</p><p>Expenditures made in shopping centers also vary according to personal preferences and needs. On average, daily expenses can be between 50–100 dollars.But in our study, our samples made transactions with Turkish Lira.</p><p>People usually buy clothing, shoes, cosmetics, electronics, household goods, food and beverage items from shopping malls. However, this may vary according to personal preferences and needs.</p><p>In recent years, with the widespread use of online shopping, people are now shopping online. This has led to changes in shopping habits.</p><p>However, the colorful world that brings many people together, hosting different activities and being an entertainment center where people go to spend time away from the computer in their daily life still maintain the interest in shopping centers.</p><p>First of all, I would like to introduce the data set that we will use in our study.</p><ul><li>Our dataset contains data on the shopping transactions that took place between the years 2021–2023 in 10 different shopping centers located in different parts of Istanbul. These data include information such as categories of shopping, gender and age of customers, shopping center, transaction date, unit price of the purchased product, and the number of products purchased. Detailed descriptions of the data set are given below.</li></ul><h3>Content</h3><p>Attribute Information:</p><ul><li><strong>invoice_no:</strong> Invoice number. Nominal. A combination of the letter ‘I’ and a 6-digit integer uniquely assigned to each operation.</li><li><strong>customer_id:</strong> Customer number. Nominal. A combination of the letter ‘C’ and a 6-digit integer uniquely assigned to each operation.</li><li><strong>gender:</strong> String variable of the customer’s gender.</li><li><strong>age:</strong> Positive Integer variable of the customers age.</li><li><strong>category:</strong> String variable of the category of the purchased product.</li><li><strong>quantity:</strong> The quantities of each product (item) per transaction. Numeric.</li><li><strong>price:</strong> Unit price. Numeric. Product price per unit in Turkish Liras (TL).</li><li><strong>payment_method:</strong> String variable of the payment method (cash, credit card or debit card) used for the transaction.</li><li><strong>invoice_date:</strong> Invoice date. The day when a transaction was generated.</li><li><strong>shopping_mall:</strong> String variable of the name of the shopping mall where the transaction was made.</li></ul><p>In addition to these variables, the TotalSales variable, which we created by multiplying the Quantity and Price values to carry out a more detailed analysis, the NEW_AGE_CAT variable, where we divided the observations in the data set into certain categories using the age variable, the vehicle capacity of the relevant shopping center and the number of stores, and finally 2 new variables. The variables Year, Month and Days Of Week, which we aim to see the change in shopping transactions based on time, are included in the data set.</p><p>Let’s dive in!</p><h4>Import To Necessary Libraries</h4><p>Here, at first, we import some libraries for data manipulation, analysis of numerical variables, and visualization of data. However, you may witness that I also imported different libraries at some points within the study.</p><pre><br>import numpy as np <br>import pandas as pd <br><br><br>import seaborn as sns <br>from matplotlib import pyplot as plt<br>from matplotlib import figure<br><br>import seaborn as sns <br>import plotly.express as px<br>import plotly.graph_objects as go<br><br>     <br>pd.set_option(&#39;display.max_columns&#39;, None)<br>pd.set_option(&#39;display.max_rows&#39;, None)<br>pd.set_option(&#39;display.float_format&#39;, lambda x: &#39;%.2f&#39; % x)<br>pd.set_option(&#39;display.expand_frame_repr&#39;, False)<br>pd.set_option(&#39;display.width&#39;, 500)D</pre><h4>Dataset</h4><pre>dataset = pd.read_csv(&#39;/kaggle/input/customer-shopping-dataset/customer_shopping_data.csv&#39;)<br><br>df = dataset.copy()<br><br>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8a2QMzvD-JLzIlyRIz-qaw.png" /></figure><h4>Descriptive Statistics Of Dataset</h4><p>In my studies, instead of writing separate commands, I define a function to see the shape value of the data set, missing observations, variable types, descriptive statistics of numeric variables. This not only saves me time, but also helps me access descriptive information about the data set with a single function.</p><pre>def check_df(dataframe, head = 5):<br>    print(&quot;#&quot;*30 + &quot; &quot;+ &quot;Dataset Shape&quot;+ &quot; &quot; + &quot;#&quot;*30)<br>    print(dataframe.shape)<br>    print(&quot;#&quot;*30 + &quot; &quot;+ &quot;Dataset Dtypes&quot;+ &quot; &quot; + &quot;#&quot;*30)<br>    print(dataframe.dtypes)<br>    print(&quot;#&quot;*30 + &quot; &quot;+ &quot;First 5 Rows Of Dataset&quot;+ &quot; &quot; + &quot;#&quot;*30)<br>    print(dataframe.head(head))<br>    print(&quot;#&quot;*30 + &quot; &quot;+ &quot;Last 5 Rows Of Dataset&quot;+ &quot; &quot; + &quot;#&quot;*30)<br>    print(dataframe.tail(head))<br>    print(&quot;#&quot;*30 + &quot; &quot;+ &quot;Is There Any NaN Observation In Dataset ?&quot;+ &quot; &quot; + &quot;#&quot;*30)<br>    print(dataframe.isnull().sum())<br>    print(&quot;#&quot;*30 + &quot; &quot;+ &quot;Descriptive Statics About to (Default) Numerical Features&quot;+ &quot; &quot; + &quot;#&quot;*30)<br>    print(dataframe.describe().T)<br>    print(&quot;#&quot;*30 + &quot; &quot;+ &quot;Quantile Values of (Default) Numerical Features&quot;+ &quot; &quot; + &quot;#&quot;*30)<br>    print(dataframe.quantile([0.00, 0.05, 0.25, 0.50, 0.75, 0.95, 1.00]).T)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UdjFiRmtFOLL2N8dZemFLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Fqqq5bWQQXMtPgqFuWR1w.png" /></figure><p>Now a separate fund is created to see the unique categories of the variables in the data set.</p><pre>def unique_categories(dataframe):<br>    cat_cols = dataframe.select_dtypes(include=[&#39;object&#39;]).columns<br>    res = pd.DataFrame(columns=[&#39;Column&#39;, &#39;Unique Values&#39;, &#39;Value Counts&#39;])<br>    for col in cat_cols:<br>        n_unique = dataframe[col].nunique()<br>        if n_unique &lt; 15:<br>            value_counts = dataframe[col].value_counts().to_dict()<br>            res = res.append({&#39;Column&#39;: col, &#39;Unique Values&#39;: n_unique, &#39;Value Counts&#39;: value_counts}, ignore_index=True)<br>        else:<br>            res = res.append({&#39;Column&#39;: col, &#39;Unique Values&#39;: n_unique, &#39;Value Counts&#39;: {}}, ignore_index=True)<br>    return res</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwSTnE0LDt1wjL2sxIc04Q.png" /></figure><p>I am writing a visualization function to see the class distributions of the categorical variables in the dataset.</p><pre>def plot_categorical_frequencies(df, n_unique=10, figsize=(8, 6), orient=&#39;h&#39;):<br>    cat_cols = df.select_dtypes(include=[&#39;object&#39;]).columns<br>    for col in cat_cols:<br>        n = df[col].nunique()<br>        if n &lt;= n_unique:<br>            plt.figure(figsize=figsize)<br>            ax = sns.countplot(x=col, data=df, orient=orient)<br>            ax.set_title(col)<br>            ax.set_xticklabels(ax.get_xticklabels(), rotation=60, ha=&#39;right&#39;)<br>            total = float(len(df))<br>            for p in ax.patches:<br>                height = p.get_height()<br>                if orient == &#39;h&#39;:<br>                    ax.text(p.get_x() + p.get_width() / 2., height + 3, &#39;{:.1%}&#39;.format(height/total), ha=&quot;center&quot;)<br>                else:<br>                    ax.text(height + 3, p.get_y() + p.get_height() / 2., &#39;{:.1%}&#39;.format(height/total), va=&quot;center&quot;)<br>            plt.show()</pre><pre>plot_categorical_frequencies(df, 10, (8,6), &#39;h&#39;)<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nlujQ5IJoLCmS-sSIxE7iQ.png" /></figure><p>When we look at the graphs, we can clearly see that the women in the observations made more shopping than the men.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OV_CWJ21Vv1yhwzkHcoSkA.png" /></figure><p>Afterwards, when we examine the purchased products, we see that clothing shopping, cosmetic product shopping and food shopping are the most purchased product types.</p><p>As an interesting result, technology expenditures, jewelery expenditures and book expenditures appear at the same intensity. Here, technology expenditures seem to be at the bottom of the ranking, due to the high exchange rates (for technology expenditures) for Turkish people along with their reading habits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-8DdU0XWPJqEoDOCT2svvQ.png" /></figure><p>When we look at the payment types, we see that it is more to pay with cash. While cash payment is followed by credit card payment, we see that the least used payment method is debit card. Here we can make a simple deduction:</p><ul><li><em>As my personal interpretation, in countries with high inflation like Turkey, people generally tend to hold money for fear that the value of their money will decrease rapidly. This, in turn, can be a hindrance to economic growth as it can reduce consumer spending. However, some people may want to spend their money quickly and dispose of it before it loses value. This can vary depending on inflation rates, income levels, consumption habits and personal preferences.</em></li></ul><p>When we look at the general lines of the chart, we clearly see that people tend to exchange the things they want to buy with the products in the market without losing their money.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lhm-oYwdSGrdEAES1udJhg.png" /></figure><p>Finally, when we examine the shopping centers in the data set, the shopping centers named Kanyon, Mall Of Istanbul and Metrocity are at the top of the ranking. Zorlu Center and Cevahir are in the lower ranks.</p><p>After this step, we create our first Additional Feature here. We create a new variable called TotalSales by multiplying Price and Quantity values.</p><pre>df[&#39;TotalSales&#39;] = df[&#39;quantity&#39;] * df[&#39;price&#39;]</pre><p>I have previously shown descriptive statistics for the numeric variable with the check_df function. Now, I’m writing a function called desc_stats to see this in an image.</p><pre>def desc_stats(dataframe):<br>    desc = dataframe.describe().T<br>    desc_df = pd.DataFrame(index= dataframe.columns, <br>                           columns= desc.columns,<br>                           data= desc)<br>    <br>    f,ax = plt.subplots(figsize=(10,<br>                                 desc_df.shape[0]*0.78))<br>    sns.heatmap(desc_df,<br>                annot=True,<br>                cmap = &quot;Wistia&quot;,<br>                fmt= &#39;.2f&#39;,<br>                ax=ax,<br>                linecolor=&#39;white&#39;,<br>                linewidths = 1.3,<br>                cbar = False,<br>                annot_kws={&quot;size&quot;: 12})<br>    plt.xticks(size = 18)<br>    plt.yticks(size = 14,<br>               rotation = 0)<br>    plt.title(&quot;Descriptive Statistics&quot;, size = 14)<br>    plt.show()<br><br><br>desc_stats(df[[col for col in df.columns if df[col].dtype != &#39;O&#39;]])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vsEEGC2y1yZnj1j-86MKtQ.png" /></figure><p>When we look at the customers in the data set, we see that they are between the ages of 18–69. These genders may differ within themselves. We’ll be reviewing that later.</p><p>When we look at the quantity variable, the products purchased generally vary between 1 and 5 pieces. (I wrote the number here, but the unit may vary depending on the product purchased)</p><p>When we look at the price variable and the total sales variable, we see that the standard deviation is high. In both variables, the standard deviation appears to be greater than the mean. In a numerical data, if the standard deviation is greater than the mean, it indicates that the data distribution is wider than the mean. This also means that the data is more widespread or has a more heterogeneous distribution.<br>For example, if the standard deviation of students’ math grades in a class is greater than their average, it means that students’ grades are more distributed and more different from each other, meaning that there is a lot of variation. However, standard deviation alone may not adequately explain a whole data set, so it is recommended to be used in conjunction with other statistical measures. Let’s examine the mean and median values of these two numerical variables.</p><p>If a numeric data set has a high standard deviation and also a very high mean relative to its median, this indicates that the data has a right-skewed distribution. In a right-skewed distribution, most of the data is collected at low values, while a few high values drive the mean value up. In this case, the median will be lower than the mean value.</p><p>For example, if a company’s distribution of employee salaries is skewed to the right, a few employees’ higher salaries will push the average salary up. However, its median value will be lower and most workers’ salaries will be below this value. Therefore, standard deviation and mean alone are not sufficient to understand the distribution of a data set, other statistical measures must also be taken into account.</p><p>I want to visualize the age and Total sales variables in the dataset</p><pre>import matplotlib.pyplot as plt<br>plt.figure(figsize=(12,6))<br>ax1 = plt.subplot(1,2,1)<br>ax2 = plt.subplot(1,2,2)<br><br>sns.boxplot(x=&quot;gender&quot;, y=&quot;age&quot;, data=df, ax=ax1)<br>sns.boxplot(x=&quot;gender&quot;, y=&quot;TotalSales&quot;, data=df, ax=ax2)<br><br>ax1.set_title(&quot;Age Distribution by Gender&quot;)<br>ax1.set_xlabel(&quot;Gender&quot;)<br>ax1.set_ylabel(&quot;Age&quot;)<br>ax1.grid(True)<br><br>ax2.set_title(&quot;Sales Distribution by Gender&quot;)<br>ax2.set_xlabel(&quot;Gender&quot;)<br>ax2.set_ylabel(&quot;Sales&quot;)<br>ax2.grid(True)<br><br>female_stats_age = df.groupby(&quot;gender&quot;)[&quot;age&quot;].describe().loc[&quot;Female&quot;]<br>male_stats_age = df.groupby(&quot;gender&quot;)[&quot;age&quot;].describe().loc[&quot;Male&quot;]<br><br>female_stats_sales = df.groupby(&quot;gender&quot;)[&quot;TotalSales&quot;].describe().loc[&quot;Female&quot;]<br>male_stats_sales = df.groupby(&quot;gender&quot;)[&quot;TotalSales&quot;].describe().loc[&quot;Male&quot;]<br><br><br>ax1.text(0, female_stats_age[&quot;25%&quot;], f&quot;Q1: {female_stats_age[&#39;25%&#39;]}&quot;, horizontalalignment=&quot;right&quot;)<br>ax1.text(0, female_stats_age[&quot;50%&quot;], f&quot;Median: {female_stats_age[&#39;50%&#39;]}&quot;, horizontalalignment=&quot;right&quot;)<br>ax1.text(0, female_stats_age[&quot;75%&quot;], f&quot;Q3: {female_stats_age[&#39;75%&#39;]}&quot;, horizontalalignment=&quot;right&quot;)<br>ax1.text(0, female_stats_age[&quot;mean&quot;], f&quot;Mean: {female_stats_age[&#39;mean&#39;]:.2f}&quot;, horizontalalignment=&quot;left&quot;)<br><br>ax1.text(1, male_stats_age[&quot;25%&quot;], f&quot;Q1: {male_stats_age[&#39;25%&#39;]}&quot;, horizontalalignment=&quot;right&quot;)<br>ax1.text(1, male_stats_age[&quot;50%&quot;], f&quot;Median: {male_stats_age[&#39;50%&#39;]}&quot;, horizontalalignment=&quot;right&quot;)<br>ax1.text(1, male_stats_age[&quot;75%&quot;], f&quot;Q3: {male_stats_age[&#39;75%&#39;]}&quot;, horizontalalignment=&quot;right&quot;)<br>ax1.text(1, male_stats_age[&quot;mean&quot;], f&quot;Mean: {male_stats_age[&#39;mean&#39;]:.2f}&quot;, horizontalalignment=&quot;left&quot;)<br><br>ax2.text(0, female_stats_sales[&quot;25%&quot;], f&quot;Q1: {female_stats_sales[&#39;25%&#39;]:.2f}&quot;, verticalalignment=&quot;top&quot;)<br>ax2.text(0, female_stats_sales[&quot;50%&quot;], f&quot;Median: {female_stats_sales[&#39;50%&#39;]:.2f}&quot;, verticalalignment=&quot;top&quot;)<br>ax2.text(0, female_stats_sales[&quot;75%&quot;], f&quot;Q3: {female_stats_sales[&#39;75%&#39;]:.2f}&quot;, verticalalignment=&quot;top&quot;)<br>ax2.text(0, female_stats_sales[&quot;mean&quot;], f&quot;Mean: {female_stats_sales[&#39;mean&#39;]:.2f}&quot;, verticalalignment=&quot;bottom&quot;)<br><br>ax2.text(1, male_stats_sales[&quot;25%&quot;], f&quot;Q1: {male_stats_sales[&#39;25%&#39;]:.2f}&quot;, verticalalignment=&quot;top&quot;)<br>ax2.text(1, male_stats_sales[&quot;50%&quot;], f&quot;Median: {male_stats_sales[&#39;50%&#39;]:.2f}&quot;, verticalalignment=&quot;top&quot;)<br>ax2.text(1, male_stats_sales[&quot;75%&quot;], f&quot;Q3: {male_stats_sales[&#39;75%&#39;]:.2f}&quot;, verticalalignment=&quot;top&quot;)<br>ax2.text(1, male_stats_sales[&quot;mean&quot;], f&quot;Mean: {male_stats_sales[&#39;mean&#39;]:.2f}&quot;, verticalalignment=&quot;bottom&quot;)<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_LCwyafu2ffLEcAv79XfQ.png" /></figure><pre>import matplotlib.pyplot as plt <br>import seaborn as sns <br><br>plt.figure(figsize=(20,6)) <br>ax1 = plt.subplot(1,2,1) <br>ax2 = plt.subplot(1,2,2)<br><br>sns.kdeplot(x=&quot;age&quot;, hue=&quot;gender&quot;, data=df, fill=True, ax=ax1) <br>sns.kdeplot(x=&quot;TotalSales&quot;, hue=&quot;gender&quot;, data=df, ax=ax2)<br><br>ax1.set_title(&quot;Age Distribution by Gender&quot;)<br>ax1.set_xlabel(&quot;Ages&quot;)<br>ax1.set_ylabel(&quot;Density&quot;)<br>ax1.grid(True)<br><br>ax2.set_title(&quot;Sales Distribution by Gender&quot;)<br>ax2.set_xlabel(&quot;Sales&quot;)<br>ax2.set_ylabel(&quot;Density&quot;)<br>ax2.grid(True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKPg5DvYauntKXrF7FoXIw.png" /></figure><p>The data set is fairly balanced distributed. No bias appears about gender’s ages. When we go into the details, we will be able to see the separation.</p><p>When we look at the average age of the men and women in the data set, the average age of both groups seems to be very close to each other.</p><p>Likewise, the average purchase amount of men and women are quite close to each other.</p><p>Also, when we look at the gender breakdown of the distribution of our TotalSales variable, we see that the data is skewed to the right. In case of positive skewness, this shows us that the mass of the TotalSales variable is concentrated on the left side.</p><p><em>*As additional information, in the case of a distribution where the distribution is skewed in this way, the median value is used to evaluate the central tendency of the data. When we look at it, we see that the median variable of the TotalSales variable is 600.17</em></p><p>When we examine the density graph of the TotalSales variable, we can see that there is a multi-peaked structure. This shows that there are different breakdowns in the data and that there are different separations. These breaks can be sub-breakdowns such as Shopping Center categorical data, Category data.</p><p>Now, we create a new categorical variable using the age variable we have. This variable will help us to group according to age ranges and to see certain patterns more easily.</p><p>I divide the age variable into ‘0_18’, ‘19_25’, ‘26_35’, ‘36_45’, ‘46_55’, ‘56_65’, ‘66_70’ categories. Thus, we examine shopping habits according to age categories.</p><pre>df.loc[:, &#39;NEW_AGE_CAT&#39;] = pd.cut(df[&#39;age&#39;], bins = [0,18,25,35,45,55,65,70], labels = [&#39;0_18&#39;, &#39;19_25&#39;, &#39;26_35&#39;, &#39;36_45&#39;, &#39;46_55&#39;, &#39;56_65&#39;, &#39;66_70&#39;])</pre><pre>import matplotlib.pyplot as plt <br>import seaborn as sns <br>import matplotlib.ticker as mtick<br><br>plt.figure(figsize=(20,8)) <br>ax1 = plt.subplot(1,2,1) <br>ax2 = plt.subplot(1,2,2)<br><br>sns.kdeplot(x=&quot;age&quot;, hue=&quot;NEW_AGE_CAT&quot;, data=df, fill=True, ax=ax1) <br>sns.kdeplot(x=&quot;TotalSales&quot;, hue=&quot;NEW_AGE_CAT&quot;, data=df, ax=ax2)<br><br>ax1.set_title(&quot;Age Distribution by New Age Cat&quot;)<br>ax1.set_xlabel(&quot;Ages&quot;)<br>ax1.set_ylabel(&quot;Density&quot;)<br>ax1.grid(True)<br><br><br>ax2.set_title(&quot;Sales Distribution by New Age Cat&quot;)<br>ax2.set_xlabel(&#39;Sales&#39;)<br>ax2.set_ylabel(&quot;Density&quot;)<br>ax2.grid(True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*apzgd09ODyx8GJySSYU-Ig.png" /></figure><p>We have created the age categories, now, let’s combine the gender variable and the age category variable and see the shopping habits between the two genders.</p><pre>import matplotlib.pyplot as plt<br>import seaborn as sns<br>import matplotlib.ticker as mtick<br><br>plt.figure(figsize=(20,8)) <br>ax1 = plt.subplot(1,2,1) <br>ax2 = plt.subplot(1,2,2)<br><br><br>grouped_ = df.groupby([&#39;NEW_AGE_CAT&#39;, &#39;gender&#39;, &#39;category&#39;]).agg({&#39;TotalSales&#39;:&#39;sum&#39;}).reset_index()<br><br><br>sns.barplot(x=&#39;NEW_AGE_CAT&#39;, y=&#39;TotalSales&#39;, hue=&#39;category&#39;, data=grouped_[grouped_[&#39;gender&#39;] == &#39;Male&#39;], ax=ax1, palette = &#39;Set2&#39;)<br>sns.barplot(x=&#39;NEW_AGE_CAT&#39;, y=&#39;TotalSales&#39;, hue=&#39;category&#39;, data=grouped_[grouped_[&#39;gender&#39;] == &#39;Female&#39;], ax=ax2,palette = &#39;Set2&#39;)<br><br><br>formatter = mtick.FuncFormatter(lambda x, p: format(int(x/1), &#39;,&#39;))<br>ax1.set_xlabel(&#39;Age Group&#39;)<br>ax1.set_ylabel(&#39;Total Sales&#39;)<br>ax1.set_ylim(0,15000000)<br>ax1.set_title(&#39;Shopping Preferences by Age Group for Males&#39;)<br><br>handles, labels = ax1.get_legend_handles_labels()<br>ax1.legend(handles, labels, loc=&#39;best&#39;)<br>ax1.yaxis.set_major_formatter(formatter)<br><br>ax2.set_xlabel(&#39;Age Group&#39;)<br>ax2.set_ylabel(&#39;Total Sales&#39;)<br>ax2.set_ylim(0,15000000)<br>ax2.set_title(&#39;Shopping Preferences by Age Group for Females&#39;)<br><br>handles, labels = ax2.get_legend_handles_labels()<br>ax2.legend(handles, labels, loc=&#39;best&#39;)<br>ax2.yaxis.set_major_formatter(formatter)<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zg8CznCgL0AUAqYU_YiEkg.png" /></figure><p>The graph on the left shows the amount in the categories that male customers spend on their purchases, and the graph on the right shows the amount in the categories that female customers spend on their purchases.</p><p>When we divide this information into age categories, we clearly see that the total price paid in clothing, shoes and technology categories is at the highest level in all age categories.</p><pre><br>grouped = df.groupby([&#39;NEW_AGE_CAT&#39;, &#39;gender&#39;, &#39;category&#39;, &#39;payment_method&#39;]).agg({&#39;TotalSales&#39;:&#39;sum&#39;}).reset_index()<br><br><br>g = sns.catplot(data=grouped, x=&#39;NEW_AGE_CAT&#39;, y=&#39;TotalSales&#39;, hue=&#39;category&#39;, col=&#39;gender&#39;, row=&#39;payment_method&#39;, kind=&#39;bar&#39;, height=5, aspect=2, palette=&#39;Set2&#39;)<br>g.set_axis_labels(&quot;Age Group&quot;, &quot;Total Sales&quot;)<br>g.fig.suptitle(&quot;Shopping Preferences by Age Group and Gender, Payment Method&quot;)<br><br><br>formatter = mtick.FuncFormatter(lambda x, p: format(int(x/1), &#39;,&#39;))<br><br>for ax in g.axes.flat:<br>    <br>    ax.yaxis.set_major_formatter(formatter)<br><br><br>handles, labels = g.axes.flat[-1].get_legend_handles_labels()<br>g.fig.legend(handles, labels, loc=&#39;upper right&#39;)<br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fEDGJfno9IFigt6xlA61g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQUqjalANRf9gL0-VRyEmQ.png" /></figure><p>In the graphics, we see that the salary card is the least preferred payment method for both genders. Generally, people paid with cash or credit card.</p><p>The debit card is the least preferred payment method for both genders. Generally, people paid with cash or credit card.</p><p>When comparing graphs, I compare the genders among themselves, as we clearly see that women shop more. While you are interpreting the graphics, you can interpret their genders among themselves. The only comment we will make between the genders is, for example,</p><p><em>“ When men and women are compared according to their cash payments, it can be seen that men in the 35–45 age category prefer to use their credit cards more for their technology expenditures. But female customers in the same age category are more inclined to use credit cards for their shoe expenditures. “</em><br> <br> Comment can be made. <br> <br>In addition, female customers aged 35–45 are more likely to pay their technology expenses in cash. Because when comparing credit card and cash payment graphics for female customers, while the difference between technology and shoe categories is less in the cash payment graph (even their technology and shoe expenditures are almost equal), when looking at credit, they generally prefer to use credit cards for card payments. But this is of course a top-notch interpretation.</p><p>In clothing expenses, customers, regardless of men and women, preferred the cash payment method. However, when we look carefully, we can see that female customers in the 35_45 and 55_65 age categories prefer more cash payment for their clothing expenditures. Because the difference between the columns representing the clothing payments between the two graphs is seen as 35_45 and 55_65, which are the most striking age categories.</p><p>A different graph I want to see is the distribution of the sales values of the categories in the dataset. For this, I use plotly as a different visualization library.</p><pre>px.box(df , y= &#39;TotalSales&#39;, color=&#39;category&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_eXB1_p2b7qZwo1zFJaVag.png" /></figure><p>When we draw the boxplot of the categories, we see that the highest distribution is in the technology category. Surprisingly, the most sold product category is Clothing — Shoes and Technology, but when we look at the distributions, we see that the biggest change is in technology.</p><p>The other categorical variable in my data set, called Shopping mall, keeps the shopping mall information that customers shop. To see which age category did the most shopping at which shopping centers</p><pre>import plotly.express as px<br><br>grouped = df.groupby([&#39;NEW_AGE_CAT&#39;, &#39;shopping_mall&#39;]).agg({&#39;customer_id&#39;: &#39;nunique&#39;}).reset_index()<br><br>fig = px.bar(grouped, x=&#39;shopping_mall&#39;, y=&#39;customer_id&#39;, color=&#39;NEW_AGE_CAT&#39;, barmode=&#39;group&#39;)<br><br>fig.update_layout(title=&#39;Number of Invoices by Shopping Center and Age Group&#39;)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GalCphC1Lr0eM8i18Ip25w.png" /></figure><p>When we examine the visitors coming to the shopping centers, we see that Kanyon, Mall Of Istanbul and Metrocity are dominant. It seems that the highest number of customers in almost every age category has come to these 3 shopping malls. I would like to examine the same chart according to the shopping made and the amounts paid.</p><p>What I don’t want to see now is how many transactions the age categories make in which shopping mall and how much they pay for each category in these shopping.</p><pre>import seaborn as sns<br>import matplotlib.pyplot as plt<br><br><br>df_count = df.groupby([&#39;NEW_AGE_CAT&#39;, &#39;shopping_mall&#39;]).agg({&#39;invoice_no&#39;: &#39;count&#39;}).reset_index()<br><br><br>df_total = df.groupby([&#39;NEW_AGE_CAT&#39;, &#39;shopping_mall&#39;, &#39;category&#39;]).agg({&#39;TotalSales&#39;: &#39;sum&#39;}).reset_index()<br><br><br>plt.figure(figsize=(20, 10))<br><br><br>ax1 = plt.subplot(1, 2, 1)<br>sns.barplot(x=&#39;shopping_mall&#39;, y=&#39;invoice_no&#39;, hue=&#39;NEW_AGE_CAT&#39;, data=df_count, ax=ax1, palette=&#39;Set2&#39;)<br><br>ax1.set_xlabel(&#39;Shopping Center&#39;)<br>ax1.set_xticklabels(ax1.get_xticklabels(), rotation=60, ha=&#39;right&#39;)<br>ax1.set_ylabel(&#39;Number of Invoices&#39;)<br>ax1.set_title(&#39;Number of Invoices by Shopping Center and Age Group&#39;)<br><br><br>ax2 = plt.subplot(1, 2, 2)<br>sns.barplot(x=&#39;shopping_mall&#39;, y=&#39;TotalSales&#39;, hue=&#39;category&#39;, data=df_total, ax=ax2, palette=&#39;Set2&#39;)<br><br>ax2.set_xlabel(&#39;Shopping Center&#39;)<br>ax2.set_xticklabels(ax2.get_xticklabels(), rotation=60, ha=&#39;right&#39;)<br>ax2.set_ylabel(&#39;Total Price&#39;)<br>ax2.set_title(&#39;Total Payments by Shopping Center, Age Group, and Category&#39;)<br><br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LxQkrQfYt3ABwt6LNIHKA.png" /></figure><p>Here are the graphics. So could there be a reason for this? Is there really a valid reason why Kanyon Mall, Mall Of İstanbul is the most visited and shopping mall? In this case, thinking that these shopping malls may be larger than the others, I first added the number of stores and parking capacities in these shopping malls to the data set. Let us now examine this situation in detail.</p><p>In addition, although the number of shoes purchased from Zorlu Center and Viaport shopping malls is almost equal to each other, the price paid for the shoe category at Zorlu Center is slightly higher than at Viaport.</p><pre>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Mall of Istanbul&quot;) , &quot;VEHICLE_CAP(~)-MALL&quot;] = 6500<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Mall of Istanbul&quot;) , &quot;SHOP_COUNT(~)-MALL&quot;] = 350<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Kanyon&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 2300<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Kanyon&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 160<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Metrocity&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 1200<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Metrocity&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 175<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Metropol AVM&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 4000<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Metropol AVM&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 250<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Istinye Park&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 3600<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Istinye Park&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 280<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Zorlu Center&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 3600<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Zorlu Center&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 200<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Cevahir AVM&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 2500<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Cevahir AVM&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 224<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Forum Istanbul&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 5000<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Forum Istanbul&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 265<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Viaport Outlet&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 3000<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Viaport Outlet&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 150<br><br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Emaar Square Mall&quot;), &quot;VEHICLE_CAP(~)-MALL&quot;] = 3000<br>df.loc[(df[&quot;shopping_mall&quot;] == &quot;Emaar Square Mall&quot;), &quot;SHOP_COUNT(~)-MALL&quot;] = 200</pre><pre>df.groupby(&quot;shopping_mall&quot;).agg({&quot;VEHICLE_CAP(~)-MALL&quot; : &quot;mean&quot;,<br>                                &quot;SHOP_COUNT(~)-MALL&quot;: &quot;mean&quot;}).sort_values(by =[&quot;VEHICLE_CAP(~)-MALL&quot;, &quot;SHOP_COUNT(~)-MALL&quot;], ascending = False)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*H8FvDbRTSOMFgE2lSaw9rA.png" /></figure><p>When we examine the results, Forum Istanbul seems to be the only shopping center that fits our opinion. Although the shopping centers named Kanyon and Metrocity are in the lower rankings, I think the reason behind them being the center of attraction is the other opportunities these malls offer to their visitors.</p><p>I would also like to examine the total amounts and averages of the purchases made in these shopping centers. Likewise, I would like to examine the averages of the fees paid to the various shopping categories in these shopping malls. Perhaps due to the products, these shopping centers may have become centers of attraction.</p><p>Now we will be seeing the effect of time in our work. Here, I want to see how the time-dependent shopping amounts change. As an example, I would like to see how there is a change in the amount of shopping in religious holidays in Turkey, during periods such as somester’s holidays. So I’m splitting the Invoice Date column in the dataset</p><pre>df[&#39;invoice_date&#39;] = pd.to_datetime(df[&#39;invoice_date&#39;])<br>df[&#39;Year&#39;] = df[&#39;invoice_date&#39;].dt.year<br>df[&#39;Month&#39;] = df[&#39;invoice_date&#39;].dt.month<br>df[&#39;DayOfWeek&#39;] = df[&#39;invoice_date&#39;].dt.day_name()</pre><pre>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br>plt.figure(figsize=(20,10))<br>sns.set_style(&quot;darkgrid&quot;)<br>ax1 = plt.subplot(2,2,1) <br>ax2 = plt.subplot(2,2,2)<br>ax3 = plt.subplot(2,2,3)<br>ax4 =  plt.subplot(2,2,4)<br><br><br><br>df_sales = df.groupby([&#39;Year&#39;, &#39;Month&#39;, &#39;DayOfWeek&#39;, &#39;NEW_AGE_CAT&#39;,&#39;shopping_mall&#39;,&#39;category&#39;]).agg({&#39;TotalSales&#39;:&#39;sum&#39;}).reset_index()<br><br>sns.barplot(data=df_sales, x=&quot;Year&quot;, y=&quot;TotalSales&quot;, ax= ax1)<br>ax1.set_xlabel(&quot;Year&quot;)<br>ax1.set_ylabel(&quot;Sales&quot;)<br>ax1.set_title(&quot;Sales by Years&quot;)<br><br>sns.lineplot(data=df_sales, x=&quot;Month&quot;, y=&quot;TotalSales&quot;, ax= ax2)<br>ax2.set_xlabel(&quot;Year&quot;)<br>ax2.set_ylabel(&quot;Sales&quot;)<br>ax2.set_title(&quot;Sales by Month&quot;)<br><br>sns.lineplot(data=df_sales, x=&quot;DayOfWeek&quot;, y=&quot;TotalSales&quot;, ax= ax3)<br>ax3.set_xlabel(&quot;Day Of Week&quot;)<br>ax3.set_ylabel(&quot;Sales&quot;)<br>ax3.set_title(&quot;Sales by Day Of Week&quot;)<br><br><br>sns.lineplot(data=df_sales, x=&quot;DayOfWeek&quot;, y=&quot;TotalSales&quot;, hue = &#39;NEW_AGE_CAT&#39;, errorbar = None, ax= ax4)<br>ax4.set_xlabel(&quot;Day Of Week&quot;)<br>ax4.set_ylabel(&quot;Sales&quot;)<br>ax4.set_title(&quot;Sales by Day Of Week&quot;)<br><br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3PXBM_SlgX980oCxzJAxWA.png" /></figure><p>When the graphs are examined, we can see that there are a lot of changes, especially when the graphs of the changes in the sales values according to the monthly and day of the week are examined.</p><p>We have come to the end of our exploratory data analysis studies on our data set. In this article, we created variables with feature engineering, we wrote some functions, we saw the descriptive statistics of the data set in a more practical way, we made a visualization on the data set. See you again in our next articles.</p><p><strong>Contact :</strong></p><p>Linkedn: <a href="https://www.linkedin.com/in/cemozcel%C4%B1k/">Cem Ozcelik</a></p><p>Github : <a href="https://github.com/ccemozclk?tab=repositories">ccemozclk</a></p><p>Kaggle :<a href="https://www.kaggle.com/smailcemzelk"> Cem Ozcelik</a></p><h4><a href="https://mlearning.substack.com/about">BECOME a WRITER at MLearning.ai</a></h4><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aabd5e723210" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing and Visualizing Earthquake Data Received with USGS API in Python Environment]]></title>
            <link>https://medium.com/@i.cemozcelik/analyzing-and-visualizing-earthquake-data-received-with-usgs-api-in-python-environment-8c7e7b6bed02?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c7e7b6bed02</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python-webscraping]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 11:53:05 GMT</pubDate>
            <atom:updated>2024-04-24T09:15:26.684Z</atom:updated>
            <content:encoded><![CDATA[<p>The scars of the devastating earthquake are still in our lives, perhaps the wounds that will never go away have opened. Well, if we were to look at the events through a data-oriented lens, what would he/she see?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OCr3qa8gcBuKm9Nz9hLU9g.jpeg" /><figcaption>Photograph Via : Pexels, Pixabay, <a href="https://pixabay.com/tr/users/tumisu-148124/">Tumisu</a></figcaption></figure><p>Hello everyone from a cloudy Sunday. I hope the weekend is going well for you. I love cloudy and rainy weather, I usually stay at home on weekends when the weather is like this, read my articles that I added to my list during the week and plan for the next week.</p><p>Well, when I look at my articles that I have shared, I am sharing my first article in 2023 with you. The year 2023 has not started very productively for me, and it cannot be said that it has started well for my country. The earthquake that occurred in Turkey, Hatay and the surrounding provinces in February affected us all. Thousands of people lost their lives and earthquake victims had to migrate to different cities from their cities where they lived for years.</p><p>In order to look at this devastating event we have experienced from a different perspective, I wanted to do some research on the tremors experienced and share the findings I have obtained with you.</p><p>Today, we will be using Web Scrapping to obtain the minimum 3 magnitude earthquakes that have occurred in Turkey and its surrounding points in the last 6 months by using an API belonging to the US Geological Survey (USGS).</p><p>Afterwards, we will visualize the data we have obtained on the map using the Heatmap. After the visualization, he conducts an exploratory data analysis study about the concussions experienced, but briefly summarizing the severity of the experienced situations.</p><p>Today, we will be using Web Scrapping to obtain the minimum 3 magnitude tremors that have occurred in Turkey and its surrounding points in the last 6 months by using an API belonging to the US Geological Survey (USGS).</p><p>Afterwards, we will visualize the data we have obtained on the map using the Heatmap. After the visualization, I will be conducting an exploratory data analysis study about the concussions experienced, but briefly summarizing the severity of the experienced situations.</p><p>Let’s dive in our work right away, without further ado:</p><ul><li>First, we import the Python Libraries that we will use in the study.</li></ul><pre>import requests<br>import pandas as pd<br>import folium<br>from folium.plugins import HeatMap<br><br><br>pd.set_option(&#39;display.max_columns&#39;, None)<br>pd.set_option(&#39;display.max_rows&#39;, None)<br>pd.set_option(&#39;display.float_format&#39;, lambda x: &#39;%.3f&#39; % x)<br>pd.set_option(&#39;display.expand_frame_repr&#39;, False)<br>pd.set_option(&#39;display.width&#39;, 500)</pre><p>We define the data we need for the scrapping process:</p><pre>start_time = &#39;now-180days&#39;<br>min_magnitude = 3<br>latitude = 39.1458<br>longitude = 34.1614<br>max_radius_km = 1500</pre><ul><li>Since we will be scrapping the data from the last six months, set the <strong>“start-time”</strong> parameter as <strong>“now-180days”</strong>;</li><li>Since we want to receive vibrations with a minimum magnitude of 3.0, set the “<strong>magnitude</strong>” parameter to <strong>3</strong>;</li><li>Since we want to receive the tremors that occur in Turkey and its surrounding locations, the latitude parameter “<strong>latitude</strong>” and the longitude parameter “<strong>longitude</strong>” parameters are <strong>39.1458</strong> and <strong>34.1614</strong>, respectively;</li><li>As the last parameter, we define the value of 1500 for the parameter named “<strong>min_radius_km</strong>” to get the vibrations that occur in an area of <strong>1500</strong> square kilometers.</li></ul><p>Now, let’s enter a url for the scrapp process and place the parameters we have defined into this url using the fstring method.</p><p>With this code, we have sent an HTTP GET request using the requests library. We have received the data we need from the USGS Earthquake API, which is available at earthquake.usgs.gov, in JSON format as a result of the request.</p><pre>url = requests.get(f&#39;https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&amp;starttime={start_time}&amp;minmagnitude={min_magnitude}&amp;latitude={latitude}&amp;longitude={longitude}&amp;maxradiuskm={max_radius_km}&#39;)<br>dataset = url.json()</pre><blockquote><em>The requests.get() method sends a GET request to a URL and receives a response. In this code, the URL parameters are created using the f-string formatting method.(e.g. </em><a href="https://medium.com/@urazakgul/usgs-api-ile-al%C4%B1nan-deprem-verilerinin-python-kullan%C4%B1larak-g%C3%B6rselle%C5%9Ftirilmesi-5c18e75e1fee"><em>Uraz Akgul | USGS API ile Alınan Deprem Verilerinin Python Kullanılarak Görselleştirilmesi)</em></a></blockquote><p>The url.json() part seen in this block converts the HTTP Response, response in json format to Python data format. The data type obtained as a result of url.json() is a Python dictionary containing data in JSON format from the USGS Earthquake API.</p><p><em>When we run the response, if 200 comes as below, it means that the response was successful.</em></p><pre>url<br>&lt;Output:&gt; &lt;Response [200]&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*59ohM-n6iIpM2NDvvDPVRQ.png" /></figure><p>We get the “features” in this json from data.</p><pre>features = dataset[&#39;features&#39;]</pre><p>To make the dataset more readable, we create several empty lists. Afterwards, we fill these lists with the appropriate information with a for loop. After that, our data will be suitable for visualization and data manipulation processes.</p><pre>places = []<br>mags = []<br>times = []<br>lats = []<br>lons = []<br>weights = []<br><br>for feature in features:<br>    places.append(feature[&#39;properties&#39;][&#39;place&#39;])<br>    mags.append(feature[&#39;properties&#39;][&#39;mag&#39;])<br>    times.append(pd.to_datetime(feature[&#39;properties&#39;][&#39;time&#39;], unit=&#39;ms&#39;).strftime(&#39;%y/%m/%d %H:%M:%S&#39;))<br>    lats.append(feature[&#39;geometry&#39;][&#39;coordinates&#39;][1])<br>    lons.append(feature[&#39;geometry&#39;][&#39;coordinates&#39;][0])<br>    weights.append(feature[&#39;properties&#39;][&#39;mag&#39;])</pre><blockquote>The for loop above adds the place, magnitude, time, latitude, longitude, and weight values of each feature to the places, mags, times, lats, lons, and weights lists, respectively.</blockquote><p>In order to convert the data into a data frame format, we define a pd.DataFrame and send the lists we created as empty at the beginning into this data frame, each with a dataframe column. Now our data has been turned into a dataframe.</p><p>There is no longer any obstacle to visualize the data that we have converted to dataframe format. Let’s move on to the visualization part.</p><h4>Data Visualization :</h4><p>In this section, we will visualize the data we hold as data frame on a map image with HeatMap in the Folium library.</p><pre>turkey_coord = [39, 35]<br>turkey_map_normal = folium.Map(location=turkey_coord, zoom_start=5.5)<br>HeatMap(data=df[[&#39;Latitude&#39;, &#39;Longitude&#39;, &#39;Weight&#39;]], radius=15).add_to(turkey_map_normal)<br><br>for index, row in df.iterrows():<br>    folium.CircleMarker(<br>        location=[row[&#39;Latitude&#39;], row[&#39;Longitude&#39;]],<br>        radius=row[&#39;Magnitude&#39;]/2,<br>        color=&#39;red&#39;,<br>        fill_color=&#39;red&#39;).add_to(turkey_map_normal)<br><br>turkey_map_normal</pre><p>A map was created in this code block and visualization was made using heatmap colors as a depiction tool according to the shaking magnitudes on the map. Let’s examine this code blog written in more detail:</p><ul><li>As a first step, we defined a list named “<strong>turkey_coord</strong>” to specify the center coordinates of the map. The coordinates in this list were used as the center coordinates of the map. Afterwards, the map was created using the folium library and a variable named “<strong>turkey_map_normal</strong>” was assigned. The zoom level was set to <strong>5.5</strong> to make it easier to view while creating the map.</li><li>Then, with HeatMap, a mask was created on the map to describe the magnitudes of the tremors. While creating this mask, in the data set; “<strong>Latitude</strong>”, “<strong>Longitude</strong>” and “<strong>Weight</strong>” columns were used. Finally, this heat map, which was created by setting the Radius degree to 15, was applied on the map named “<strong>turkey_map_normal</strong>”.</li><li>In the last step, a circle was drawn with the help of the CircleMarker function for each observation line in the data set with a for loop. As input to the CircleMarker function, the variable (<strong>Place</strong>) holding the location information of the earthquake and the variable (<strong>Magnitude</strong>) holding the tremor magnitude information were given. Filling was done with red in the created circle. The created circles were added to the <strong>turkey_map_normal</strong> map.</li></ul><p>The map image we created as the last step is as seen below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5vacvt_QLAsmwjx10VrPA.png" /><figcaption>Heatmap applied result output</figcaption></figure><p>To make the map in bold format, add a simple parameter:</p><pre>turkey_map_dark = folium.Map(location=turkey_coord, zoom_start=5.5, tiles=&#39;cartodbdark_matter&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WR6N7D7uCyHySZazrjpFig.png" /><figcaption>Heatmap applied result output with Dark Theme</figcaption></figure><p>We have done the data visualization part for now, now I want to analyze the data we have by manipulating it a little bit.</p><h4>Data Manipulation :</h4><p>First, there are empty values in the Place variable in the dataset. I want to fill these empty values with pd.Fillna.</p><pre>df[&#39;Place&#39;].fillna(&quot;NoInformation&quot;, inplace= True)</pre><p>Now we will be extracting the <strong>Country</strong> and <strong>City</strong> information from the “<strong>Place”</strong> feature, using some string methods. You could get faster results by using regex here, but I wanted to do it in a more challenging way because I am not good at regex(e.g <a href="https://en.wikipedia.org/wiki/Regular_expression">Reguler Expression</a>) yet.</p><pre>for place in list(df[&#39;Place&#39;].unique()):<br>    if &quot;,&quot; in place and &quot;border&quot; not in place:<br>        if &quot;Kahramanmaras&quot; in place:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = &#39;Turkey&#39;<br>        else:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = df[&#39;Place&#39;].apply(lambda x : x.split(&#39;,&#39;)[-1])<br>    elif &quot;,&quot; not in place and &quot;border&quot; not in place and &quot; &quot; in place and len(list(place.split(&#39; &#39;)))&gt;1 and len(list(place.split(&#39; &#39;)))&lt;3:<br>        if &quot;Iran&quot; in place:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = &quot;Iran&quot;<br>        elif &quot;Turkey&quot; in place:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = &quot;Turkey&quot;<br>        elif &quot;Greece&quot; in place:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = &quot;Greece&quot;<br>    elif &quot;,&quot; not in place and &quot;border&quot; not in place and &quot; &quot; in place :<br>        if &quot;Kahramanmaras&quot; in place:<br>             df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = &#39;Turkey&#39;<br>        elif &quot;region&quot; in place:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = df[&#39;Place&#39;].apply(lambda x : x.split(&#39; &#39;)[0])<br>        elif &quot;Sea&quot; in place:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = place<br>        elif &quot;coast&quot; in place:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = df[&#39;Place&#39;].apply(lambda x : x.split(&#39; &#39;)[-1])<br>        else:<br>            df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = df[&#39;Place&#39;].apply(lambda x : x.split(&#39; &#39;)[1])<br>    elif &quot;border&quot; in place:<br>        df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = place<br>    <br>    else:<br>        df.loc[(df[&#39;Place&#39;] == place), &#39;Country&#39;] = place<br>        <br>        <br>df.loc[((df[&#39;Country&#39;].isnull()) &amp; (df[&#39;Place&#39;].str.contains(&#39;Cyprus&#39;))), &#39;Country&#39; ] = &#39;Cyprus&#39;<br>df.loc[((df[&#39;Country&#39;].isnull()) &amp; (df[&#39;Place&#39;].str.contains(&#39;Sea&#39;))), &#39;Country&#39; ] = df[&#39;Place&#39;]        <br><br>for place in list(df[&#39;Place&#39;].unique()):<br>    if &quot;,&quot; in place:<br>        df.loc[(df[&#39;Place&#39;] == place), &#39;City&#39;] = df[&#39;Place&#39;].apply(lambda x: x.split(&#39;,&#39;)[0].split(&#39; &#39;)[-1])<br><br>df[&#39;City&#39;].fillna(&#39;NO CITY INFORMATION&#39; ,inplace = True)</pre><p>The Time variable we have is in the format “<strong>yyyy/mm/dd HH:MM:ss</strong>”. Let’s keep this Time variable by separating the date and time parts into two.</p><pre>df[&#39;Date&#39;] = df[&#39;Time&#39;].apply(lambda x: x.split(&quot; &quot;)[0])<br>df[&#39;TimeZone&#39;] = df[&#39;Time&#39;].apply(lambda x: x.split(&quot; &quot;)[1])</pre><p>In the last case, our data set took a form as seen below. I think it has turned into a format that can be considered much more suitable for analysis than the previous one. Well, we are nearing the end…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*biUQzylks6A-OlPM4HyJMw.png" /><figcaption>New Shape of Our Dataset</figcaption></figure><p>I wanted to create a new variable in order to group the tremors according to months and years. Our variable named “Year/Month” keeps the year and month information of the earthquake.</p><pre>df[&#39;Year\Month&#39;] = df[&#39;Date&#39;].apply(lambda x : str(x.split(&quot;/&quot;)[0]) + &quot;/&quot; +  str(x.split(&quot;/&quot;)[1]))</pre><h4>Exploratory Data Analysis :</h4><p>In the exploratory data analysis part, we ask some questions to our dataset, and answer these questions using aggregation functions and groupby method.</p><p><strong>1 . How many earthquakes have occurred in which country in the last 6 months?</strong></p><pre>df.groupby(&#39;Country&#39;).agg({&quot;Weight&quot;: &quot;count&quot;}).sort_values(by = &quot;Weight&quot;, ascending = False)[:10]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*tZR80v6GEBzXzLWYLK251w.png" /><figcaption>The Answer Of the First Questions</figcaption></figure><ul><li>When we look at the tremors that have occurred within the countries in the last six-month period, we can see that quite a number of tremors have occurred in Anatolia.</li></ul><p><strong>2. What is the mean and standart deviation of the Magnitudes of the earthquakes that will occur?</strong></p><pre>mean_std = df.groupby(&#39;Country&#39;).agg({&quot;Magnitude&quot;: &quot;mean&quot;,<br>                          &quot;Weight&quot; : &quot;std&quot;}).sort_values(by = &quot;Magnitude&quot;, ascending = False)[:10]<br><br>mean_std.columns = [&#39;Magnitude_mean&#39;, &#39;Magnitude_std&#39;]<br>mean_std</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*J90EYXjEt3kHatWmTLB6Vw.png" /><figcaption>The Answer Of second Question</figcaption></figure><ul><li>It is an interesting result that although there are many earthquakes in Turkey, its average is 4.44. Although the 7.2 and 7.6 earthquakes, which are the big earthquakes, were very big tremors, the average magnitude of the earthquake in the main mass was seen as 4.44. As a separate result, the average of earthquakes in Iraq is seen as the highest. However, considering the number of tremors that occurred, very few tremors had occurred in Iraq. (e.g First question answer)</li></ul><p><strong>3. We know that earthquakes have occurred in the last 6 months. So, how many earthquakes were there in which month and what are their magnitudes?</strong></p><pre>    df.groupby([&#39;Year\Month&#39;,&#39;Country&#39;]).agg({&quot;Magnitude&quot;: &quot;count&quot;}<br>                                          ).reset_index().sort_values(by = &quot;Magnitude&quot;, ascending = False)[:15]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*taa4DuOBim_WidqST1QK-Q.png" /><figcaption>The Answer of third question</figcaption></figure><ul><li>There is no surprise in this result, in the last six months, Turkey is at the top in the number of earthquakes. It is seen that an earthquake over 3.0 is experienced almost every day. It’s a worrying situation…</li></ul><p><strong>4. I made the distribution according to the countries. How many earthquakes occurred in which city of which country?</strong></p><pre>df.groupby([&#39;Year\Month&#39;,&#39;Country&#39;, &#39;City&#39;]).agg({&quot;Magnitude&quot;: &quot;count&quot;}<br>                                          ).reset_index().sort_values(by = &quot;Magnitude&quot;, ascending = False)[:15]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*KXmkqWhngEkAlssFYXV2wg.png" /><figcaption>The Answer Of Fourth Question</figcaption></figure><p><strong>4.1 What is the average magnitude of these earthquakes?</strong></p><pre>table_ea = df[df[&#39;Country&#39;] != &quot;NoInformation&quot;].groupby([&#39;Year\Month&#39;,&#39;Country&#39;, &#39;City&#39;]).agg({&quot;Magnitude&quot;: &quot;count&quot;,<br>                                                      &quot;Weight&quot; : &quot;mean&quot;}).sort_values(by = &quot;Magnitude&quot;, ascending = False)<br><br>table_ea.columns = [&#39;Count&#39;, &#39;Magnitude&#39;]<br>table_ea</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJGRMhDp26GOBVXU_BphHA.png" /><figcaption>The Answer Of Sixth Question</figcaption></figure><p>Well, we got the data with Web Scrapping, then we visualized the data we obtained on a map. We made the data we visualized ready for analysis processes with data manipulation methods. And finally, we tried to find answers to our questions by asking questions to the data set. We have come to the end of our study today. I hope it has been a useful reading session for you and opening the door to new ideas.</p><p>In the meantime, don’t forget to follow me on my social media accounts and check out my other articles. See you again :)</p><p><a href="https://www.linkedin.com/in/cemozcel%C4%B1k/">Linkedn</a></p><p><a href="https://www.kaggle.com/smailcemzelk">Kaggle</a></p><p><a href="https://github.com/ccemozclk">Github</a></p><p><a href="https://ccemozclk.github.io/">My Portfolio</a></p><h4><a href="https://mlearning.substack.com/about"><strong>BECOME a WRITER at MLearning.ai</strong></a></h4><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c7e7b6bed02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Science Project : Rule Based Classification]]></title>
            <link>https://medium.com/@i.cemozcelik/data-science-project-rule-based-classification-633316645461?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/633316645461</guid>
            <category><![CDATA[multiclass-classification]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[dataset]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Sun, 23 Oct 2022 13:13:38 GMT</pubDate>
            <atom:updated>2022-10-23T13:13:38.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Science Project : Rule Based Classification</h3><h4>Creating Personas from Existing Customer Profiles and Classifying According to Customer Purchasing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ryklZ5e_wqR7ZVOPw4AYMQ.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/tr-tr/@goumbik/">Lukas</a> on <a href="https://www.pexels.com/tr-tr/">Pexels</a></figcaption></figure><p>This article written by <a href="https://medium.com/u/e7aec74cd6ed">Cem ÖZÇELİK</a> and <a href="https://medium.com/u/fe99f0a4a612">Alparslan Mesri</a>.</p><p>Organizations spend a great deal of money to provide the best service to their existing customers. While making these expenditures, knowing the customer profiles well and knowing the spending habits of the customers allows the expenditures to be directed in the best way. The knowledge of how much profit a customer in which profile brings him may depend on various variability in the customer profile. For example, depending on the degree of influence of the institution, information such as the nationality, age, gender of the relevant customer, the type of the device they shop with, the time the shopping takes place, the season in which the shopping takes place, the frequency of shopping made by the relevant customer from the institution can be effective variables when creating the customer profile. In this context, today, organizations can benefit from various methods while creating their customer profiles.</p><p>From the perspective of data science and machine learning, various segmentation and clustering algorithms offer customized performance for this and similar classification processes. However, although classification and clustering algorithms such as K-Means may sound cooler, sometimes the data set we have does not need such complex algorithms. It is also possible for us to make rule-based classifications using certain features of our customers for classification in smaller, compact datasets with less variability and uncertainty. Taking an approach in this way not only saves a great deal of work for our team, but also enables us to bring a more general and acceptable solution to the current business problem.</p><p>In this study, as an example business problem, an international gaming company wants to create new level-based customer definitions (personas) by using some features of its customers and to create segments according to these new customer definitions and to estimate how much new customers can earn on average according to these segments. For example, he wants to determine how much of a 26-year-old Android user in Turkey can offer to the relevant company.</p><p>Now we can get to work. First, let’s get to know our data set:</p><p>Our data set consists of 5 variables including,</p><ul><li><strong>‘PRICE’,</strong></li><li><strong>‘SOURCE’,</strong></li><li><strong>‘SEX’,</strong></li><li><strong>‘COUNTRY’,</strong></li><li><strong>‘AGE’.</strong></li></ul><p>Let’s also recognize these variables:</p><ul><li><strong>PRICE</strong>: It is the amount of expenditure of the customer concerned.</li><li><strong>SOURCE</strong> : A tour of the operating system of the device to which the customer is connected.</li><li><strong>SEX</strong> : Gender information of the customer.</li><li><strong>COUNTRY</strong> : Information of the country / nationality to which the customer is connected.</li><li><strong>AGE</strong>: Mournery information of the customer</li></ul><p>First, let’s import the libraries that we will use in the study.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acd1d6742f742cdd7b154b10218b8c7a/href">https://medium.com/media/acd1d6742f742cdd7b154b10218b8c7a/href</a></iframe><p>Next, let’s import our dataset and see the summary of the dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e094f0b89a2f1aeceed242dd4656469/href">https://medium.com/media/5e094f0b89a2f1aeceed242dd4656469/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*Oe_rylK9C8Rrrec70d-M_A.png" /><figcaption>Dataset Overview</figcaption></figure><p>Now let’s examine the data set in general terms so that we have a ten information about the data set:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e50d0fc4819f9d5e63771d0d0132d93/href">https://medium.com/media/6e50d0fc4819f9d5e63771d0d0132d93/href</a></iframe><p>We can see the output of this function blog in the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAV804AV7SqSdCsg6GrGAw.png" /><figcaption>Desriptive Statistics of Dataset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*6aR2cAcZ90qPhxQPeUbUJA.png" /><figcaption>Histogram Charts of PRICE &amp; AGE Features</figcaption></figure><p>When we look at the data set we have, we see that there is no empty view. Of course, we should not forget that this is an example data set. In fact, in data science projects in the world, we will not encounter clean and understandable data sets in this way. In addition, we have two digital variables (AGE, PRICE) in the data set. When we look at the statistics of these two variables, we can see that the variable PRICE varies between 9 units and 59 units, and the average is 34 units. In the same way, when we look at the lower and upper quarter slices of the PRICE variable, we can say that it has a balanced structure. There doesn’t seem to be much carouselage. However, when we examine the histogram graph, our values are not continuous; we need to keep in mind that it has a dashed structure. In addition to the PRICE variable, we also look at the AGE variable and the ages of the users in our data set vary between 15 and 66. Compared to the PRICE variable, we can see that the AGE variable is in the form of a Right-Skewed. The users in our dataset are mostly young people. When we think that our business problem belongs to a mobile gaming company, we can think that it is an expected situation.</p><p>Now we ask some questions in the dataset and find the answers to these questions:</p><p>First, we answer the question is :</p><p><strong>How much sales have been generated to the user in each SOURCE round?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/172b0ee048f36bc3393583fe4d0ebad8/href">https://medium.com/media/172b0ee048f36bc3393583fe4d0ebad8/href</a></iframe><p><strong>How many sales are there in each PRICE value?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b58decae5d434611c772678907fe527e/href">https://medium.com/media/b58decae5d434611c772678907fe527e/href</a></iframe><p>As we can see from the output here, the prices of our products we offer to our customers are 9, 19, 29, 39, 49 and 59.</p><p><strong>How many sales from which COUNTRY ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/064b277c5820c61ea9b2ef8d5bf5cb00/href">https://medium.com/media/064b277c5820c61ea9b2ef8d5bf5cb00/href</a></iframe><p>When we look at the output, we can see that sales are concentrated in the US and Brazil. When we look at the European countries, Germany and Turkey are seen in the near values, while the least sales from European countries are to the users in France. The least sales were in Canada.</p><p><strong>How much was earned in total from sales by COUNTRY ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79d2d4fa820b4e7f2fb02f98b99cca0c/href">https://medium.com/media/79d2d4fa820b4e7f2fb02f98b99cca0c/href</a></iframe><p>When the earnings obtained from the customers according to the countries are examined, as expected, the most earnings were provided from the users of the USA and Brazil. However, while the number of purchases made by users in Brazil was almost half that of US users, purchases were equivalent to 73% of US users in earnings. In European countries, although more products are sold in Germany than in Turkey, the profit obtained from Turkey is higher than in Germany. In this case, it can be interpreted that “Users in Turkey and Brazil have purchased products with higher prices than users in the USA and Germany.”</p><p><strong>What are the sales amount by SOURCE types ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b2c9e757a28c97a47855e00aaefdb55/href">https://medium.com/media/3b2c9e757a28c97a47855e00aaefdb55/href</a></iframe><p>As we can deduce from the results here, the gain from Android users is ~65% more than IOS users.</p><p><strong>What are the PRICE averages by COUNTRY ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4e6fe96a8236c6c56096811382d35b6/href">https://medium.com/media/b4e6fe96a8236c6c56096811382d35b6/href</a></iframe><p>In this case, as we can see, we have confirmed the comment we made to the question “<strong>How much was earned in total from sales by COUNTRY ?</strong>” in the previous section. As we can see, when we look at the earnings provided per sale, users in Turkey and Brazil are at the top of the list, followed by Germany and the USA. In the previous section, it is not out of sight, but as you can see, the situation of paying more fees per sale is also valid for users in Canada.</p><p><strong>What are the PRICE averages by SOURCE ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3d1b3563aee6fb90ee6b1c053b545ab/href">https://medium.com/media/b3d1b3563aee6fb90ee6b1c053b545ab/href</a></iframe><p>When we look at the earnings averages according to the device tour used by the users, we can see that Android users earn more than IOS users.</p><p><strong>What are the PRICE averages in the COUNTRY-SOURCE ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a37753b900cc1f411fa12fd70e4abe0/href">https://medium.com/media/0a37753b900cc1f411fa12fd70e4abe0/href</a></iframe><p>When the results here are examined, as expected, the averages of Android users are higher in each country, but we can surprisingly see that the averages of the USA, where the most sales and the most earnings are the lowest, are at the lowest level. In Canada, due to the low number of sales, the average according to the operating systems has been higher than other countries.</p><p><strong>What are the average earnings by COUNTRY-SOURCE-SEX-AGE ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bca72ae4996e0053a294990d5b387275/href">https://medium.com/media/bca72ae4996e0053a294990d5b387275/href</a></iframe><p>As a result of this, male Android users in Brazil and the USA are the ones who earn the most. Although the number of users is small, the fees they pay per sale are higher than those of young users. Young female android users of France are also seen to be in the user profile that pays the most per sale.</p><p>We asked the data set we had, questions that we could know and know about the data set, and we got some conclusions. Now, to create personalities from customers, let’s first categorize users according to their age. Therefore, we divide the <strong>AGE</strong> variable into age categories 0_18, 19_23, 24_30, 31_40 and 40_70.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97dc7cd84164b9469d92bb30db400343/href">https://medium.com/media/97dc7cd84164b9469d92bb30db400343/href</a></iframe><p>We are now concanate variables to create a level-based customer definition variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c49b057fa17d4aa16547b8db4c680bb/href">https://medium.com/media/6c49b057fa17d4aa16547b8db4c680bb/href</a></iframe><p>The point we need to pay attention to here is, after creating customers_level_based values with list comprehension, these values need to be unique. For example, it could be more than one of the following: FRA_IOS_FEMALE_31_40.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70b450645e66f0f14bedc761700e1b14/href">https://medium.com/media/70b450645e66f0f14bedc761700e1b14/href</a></iframe><p>We then look at the PRICE averages according to the CUSTOMERS_LEVEL_BASED variable we created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e2af5e326c6ae4e542eab1332a3652f/href">https://medium.com/media/8e2af5e326c6ae4e542eab1332a3652f/href</a></iframe><p>We divide users into segments according to the average price of the personas we create here. We name these segments as A, B, C, D.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7bb895ba68c400db67eeba2c72f1811/href">https://medium.com/media/c7bb895ba68c400db67eeba2c72f1811/href</a></iframe><p>Finally, let’s examine the statistical properties of the segments we have created:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fef28087b17e276c52c9a97284d57d89/href">https://medium.com/media/fef28087b17e276c52c9a97284d57d89/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*V6Oiacql2NHoNPHGMSy_xw.png" /><figcaption>Statistics of Segments</figcaption></figure><p>As we can see in this table, there are 27 users in each segment. The segment with the highest earnings is segment A and segment D with the least income. The highest sales value realized in the A segment is 45.42 units. The minimum amount is 36.06 units. Its average is 38.69 units.</p><p>Here, as a different approach, we can combine the segments that show the most similarity to each other. For this problem, segments B and C are the 2 segments that show the most similarity to each other. When we look, the average of the B segment is 34.99, while the average of the C segment is 33.50. Max values are also similar to each other. However, sometimes combining segments that are similar to each other may cause us to ignore some distinctive information. That’s why we don’t combine these two segments in this business problem.</p><p>Now, finally, we will define a few sample users and find out which segment these users are in our system.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad7c0a63282c0041b7b5a6934a0eba1f/href">https://medium.com/media/ad7c0a63282c0041b7b5a6934a0eba1f/href</a></iframe><p>As the output of this for block:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*EUERGMgG1RWztbptyHU1GQ.png" /></figure><p>In the first example, we segmented a 33-year-old male android user in Turkey, then in the second example, a 39-year-old female Ios user in France, and in the last example a 26-year-old male android user in Turkey.</p><p>We have come to the end of our study. In this study, we performed a rule-based classification on data sets with low uncertainty without the need for complex algorithms. more later</p><p>Linkedin: <a href="https://www.linkedin.com/in/cemozcel%C4%B1k/">https://www.linkedin.com/in/cemozcel%C4%B1k/</a></p><p>Github : <a href="https://github.com/ccemozclk">https://github.com/ccemozclk</a></p><p>To access the github repo for this work: <a href="https://github.com/ccemozclk/Rule_based_classification">https://github.com/ccemozclk/Rule_based_classification</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=633316645461" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Measurement Problems Episode II: Rating & Sorting Products — Reviews]]></title>
            <link>https://medium.com/@i.cemozcelik/measurement-problems-episode-ii-rating-sorting-products-reviews-510d3dc72e3d?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/510d3dc72e3d</guid>
            <category><![CDATA[business-development]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[amazon]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Wed, 20 Jul 2022 06:14:55 GMT</pubDate>
            <atom:updated>2022-07-20T10:19:53.027Z</atom:updated>
            <content:encoded><![CDATA[<h3>Measurement Problems Episode II: Rating &amp; Sorting Products — Reviews</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*T348JhtusltAnFWxJZ_l3Q.jpeg" /></figure><p>Hello again from the second episode of our measurement problems series. In our previous study, we focused on hypothesis testing and studied AB testing. In this article, we will work on the rating and sorting problems that we frequently encounter in the e-commerce industry.</p><p>In our previous study, we focused on hypothesis testing and studied AB testing. In this article, we will work on the rating and sorting problems that we frequently encounter in the e-shopping sector.</p><p>Sorting and rating, which are two important factors we encounter in the world of e-commerce, which is more involved in our lives during the pandemic period, are concepts that we can direct the purchasing movements of a user while performing the shopping process on the e-commerce site, which provide great profitability if used correctly and increase sales.</p><p>To explain a little more concretely, imagine that you want to buy a computer over the internet. You entered the website you want to buy a computer and searched for the computer you want to buy. There are dozens of products from different vendors on the computer you have searched against. So, how do you choose the product you want to buy among dozens of options? Product score? By looking at the comments of the product? Or maybe you’re considering both together. Well, what does it mean to you that the product you are interested in is bought and reviewed by how many people and even makes an evaluation about it?</p><p>I want to draw your attention to one issue. I want you to think that you have encountered a situation like the one we gave an example in the paragraph above. It is far from a coincidence that the products with the highest score are the first ones that come up when you search, the products with the most comments and reviews are at the top, and even when you make a choice, the comments that affect you the most are at the top, even in the comments of the product. All of these are conscious applications that are calculated by feeding the social proof concept and are made to guide your purchasing processes.</p><blockquote>The <a href="https://en.wikipedia.org/wiki/The_Wisdom_of_Crowds">wisdom of crowds</a> has an enormous impact on people’s daily behavior. From politics to shopping people are led by a super hyper voodoo thing called the wisdom of crowds. Here is how to prepare it:</blockquote><blockquote>3 grams of psychology</blockquote><blockquote>2 grams of neuroscience</blockquote><blockquote>5 grams of statistics</blockquote><blockquote>1 appropriate computer and a sprinkle of calculation skills</blockquote><p>Now that we’ve talked enough about what social proof is, let’s move on to the practical part.</p><p>Our data set contains information about the products in the <a href="https://www.amazon.com/">Amazon.com </a>database, product ratings, product evaluations and whether these evaluations have been found useful by other users.In order to get to know the dataset better, it can be emphasized more in the study.</p><p>In the first step, let’s import the necessary libraries</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6967eeb96d7c93e4af31ffc3e3b5f480/href">https://medium.com/media/6967eeb96d7c93e4af31ffc3e3b5f480/href</a></iframe><p>We also imported our dataset, in the next step, let’s take a look at the structure of the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OHpQTmHDEkvf2iu8pvziOQ.png" /><figcaption>Overlook of the Amazon dataset</figcaption></figure><p><strong>reviewID</strong> : Shopper user ID</p><p><strong>asin</strong>: Product ID</p><p><strong>reviewerName</strong>: Username who made the purchase</p><p><strong>helpful</strong>: The degree of useful review of the product</p><p><strong>reviewText</strong>: Review, comment for the product</p><p><strong>overall</strong>:Product average score</p><p><strong>summary</strong>: Review summary</p><p><strong>unixReviewTime</strong>: Time to comment</p><p><strong>reviewTime</strong>: Time to comment in raw format</p><p><strong>day_diff</strong>:Number of days after assessment</p><p><strong>helpful_yes</strong>:The number of usefulness of the review made for the product</p><p><strong>total_vote</strong>:Total number of reviews for the product</p><p>After examining the dataset better, we take a look at the structure and size of the dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d054bf1b442bae3d7799f1aa62fc76e/href">https://medium.com/media/6d054bf1b442bae3d7799f1aa62fc76e/href</a></iframe><p>The image of the dataset after applying these two functions to our dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Shqo6KXajgFFp7EjFZoEw.png" /><figcaption>The Image of the dataset</figcaption></figure><ul><li><strong><em>Note : The value_counts method was not used in the data set summary, as the Data Set contains only the comments and ratings for a product.</em></strong></li></ul><p>The first evaluation method of the product is to obtain the average score of the product. Therefore, we obtain the average of the “<strong>Overall</strong>” variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8c5ae7dde00803c1ee4b6e4aba591d8/href">https://medium.com/media/d8c5ae7dde00803c1ee4b6e4aba591d8/href</a></iframe><p>Obtaining the average evaluation score of the product may be considered sufficient for an evaluation of the product according to some business problems. However, it does not fully reflect the reality at the general level.</p><p>As the second stage in the evaluation, we will consider the time factor and break down the time period from the purchase of the product by the user who bought the product to the present day, and we will focus on the time periods. Thus, we will separate the reviews of the user who bought our product in the past, and the user reviews that we think have just bought the product and do not have a chance to make a correct assessment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/948c90686ef3410e4e57008480bd580d/href">https://medium.com/media/948c90686ef3410e4e57008480bd580d/href</a></iframe><p>As seen between time periods, there are no big differences. But as the number of days increases, a decrease is seen in the overall variable. If we are only going to comment on the days, the values given to the product decrease according to the increase in the time. And the raw score of the product can be found by starting from the averages given in 600&gt; days(q_3&gt;).</p><p>We found the net point value of the product by using the time weighting method. But in different business problems, it is possible to find the score level of the product on a more solid basis by weighting the user according to the business problem.</p><p>After finding the rating of the product, let’s list the comments and evaluations of the product. By using the social proof factor, we can influence the purchasing decisions of users who review the products on the site.</p><p>As a first step, let’s get the number of useless comments. For this, the number of useful comments out of all comments</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c171ee24efe7a5587391d577e03851c/href">https://medium.com/media/6c171ee24efe7a5587391d577e03851c/href</a></iframe><p>As the second step, we delete the variables that will not be used in our data set. We are making our dataset more useful.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/226160cad0a76b859935cdfc05650ea8/href">https://medium.com/media/226160cad0a76b859935cdfc05650ea8/href</a></iframe><p>In this part, I will introduce you to the Wilson Lower Bound Score. So what is the Wilson Lower Bound score? To summarize, *it is a tool used for scoring products, comments or items that contain binary interactions.</p><p><strong><em>*Note: Condition products or objects referred to as double interaction, Like-Dislike; Up Rate — Down Rate; Helpful — Not Helpful.</em></strong></p><p>As a working principle, Wilson Lower Bound calculates a confidence interval for the **Bernoulli parameter P. It accepts the lower bound of the confidence interval as the Wilson Lower Bound Score (WLB Score).</p><p><strong><em>**Note: Bernoulli is used as a statistical distribution to calculate probabilities of binary states.</em></strong></p><p>Let’s explain the working principle of WLB Score with an example, first of all, let’s assume that the ***average score of the comments made on a product is 0.6, in this case we set a confidence interval by the user and &lt;the confidence interval we set here is 95%&gt; for this product, “95% confidence Interpretations for this product will be in the range of 0.5–0.7”. Afterwards, we consider the lower limit of this confidence interval, 0.5, as the Wilson Lower Bound Score.</p><p><strong><em>***Note: We calculate the average score value of the product as Up Rate(Helpful Rate) / All Rate.</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3be1e473c73e4f8eaf3dc204e9c3b89/href">https://medium.com/media/d3be1e473c73e4f8eaf3dc204e9c3b89/href</a></iframe><p>Let’s define the other two evaluation metrics used in the rating of the comments made on the product and get a score for each of these two values. In this way, we will have the opportunity to interpret the rating made about the product from different perspectives and sort it correctly.</p><p>First, let’s define the Up-Down Differences Score function. The Up-Down Diff Score is found by subtracting the negative rate from the positive rate for the product. The difference between the two is considered the Up-down diff score.</p><p>Another measurement metric is the Average Score metric. With this metric, we rate the Up Rate values, which we accept as positive rates, to all rate values. That is, Up Rate/ (Up Rate+Down Rate). However, there is a potential error in this calculation metric. So let’s examine two situations:</p><p>In the first case, 2 Positive Rate 0 negative rate evaluations are made for the comment made for the product. In this case, the average value for the product will be 2/(2+0) = 1.0. In the second case, 100 positive rate and 1 negative rate evaluations should be made for the product. In this case, the average rate will be: 100/(100+1) = 0.99. When a ranking is made according to the comment average rate values, the product with 1.0 value but less comment rating will be placed above the product with 0.99 average. So the Social Proof factor will not be provided .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69c41760a8ad901637f35b62bcdabdb8/href">https://medium.com/media/69c41760a8ad901637f35b62bcdabdb8/href</a></iframe><p>The final image of the dataset was as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMX1ZUyZjTP_Xrbi51_Lhg.png" /><figcaption>Final shape of the dataset</figcaption></figure><p>Now, let’s evaluate our results, rank the top 20 comments according to Wilson Lower Bound Score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgTFc79G_Bgq3RD773t2IQ.png" /><figcaption>Sorting the comments made about the product</figcaption></figure><p>To summarize the sorting table:</p><ul><li>When we look at the observations at the top, we can see that they have the highest total vote values. We can also interpret that social proof is provided for the evaluated product, which causes it to be at the top of the ranking.</li><li>When we look at the helpful_yes and helpful_no distributions when we pay attention to the observations at the top, we see that the yes values ​​are high.</li><li>Also, when we take a look at the day_diff variable, we see that the products with some values ​​&lt;158, such as 283&gt; appear at the top, which shows us the products with potential. In other words, it will not be a surprise to see the products that will sell the most in the future.</li><li>Finally, when the overall variable is examined, although some products have an average of 1.00, they are at the top of the ranking. This is due to the social proof factor. In other words, the evaluation of a product by a large audience has affected the ranking logic of the product in this list.</li></ul><p>We have come to the end of the second and final study of our series of measurement problems. See you in our next post :)</p><p>You can reach the github repository of this work from the <a href="https://github.com/ccemozclk/Amazon_product_Sorting">link</a> and you can see my other works by visiting <a href="https://github.com/ccemozclk">my github profile</a>.</p><h4><strong>References:</strong></h4><ul><li><a href="https://ardabaysallar.medium.com/sorting-as-a-social-proof-the-sorting-wizard-of-statistics-world-e-b-wilson-3cb10e44401b">Sorting as a Social Proof &amp; The Sorting Wizard of Statistics World: E.B. Wilson</a></li><li><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=510d3dc72e3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Measurement Problems Episode I : Hypothesis Testing(A/B Testing)]]></title>
            <link>https://medium.com/@i.cemozcelik/measurement-problems-episode-i-hypothesis-testing-a-b-testing-cad3b17c78b1?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/cad3b17c78b1</guid>
            <category><![CDATA[business-development]]></category>
            <category><![CDATA[business-strategy]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ab-testing]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Tue, 19 Jul 2022 12:17:25 GMT</pubDate>
            <atom:updated>2022-10-24T05:26:48.114Z</atom:updated>
            <content:encoded><![CDATA[<h3>Measurement Problems Episode I : Hypothesis Testing(A/B Testing)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*Rvl9XOyAVXipH58arqdGDg.png" /></figure><p>Hello everyone from a burning summer day, today we will be with you on measurement problems and in the first article of the series, we will focus on the AB Test, which is one of the hypothesis tests. AB test, which is among the hypothesis tests, is a method we use to explain whether there is a statistically significant difference between the two groups.As a usage, the AB testing can reveal important effects in testing new developments in the world of science and in making decisions that can guide company expenditures in the business world. Thus, decisions based on solid foundations can be taken and studies are developed based on scientific facts. AB test, which reveals beneficial effects if used, is a method that can be recommended to be used instead of primitive methods such as trial and error method of investments and actions in growing companies.</p><p>Now let’s examine step by step how this method works.</p><h4>1. Establishment of hypotheses</h4><p>At the stage of establishing hypotheses, which is the first stage of the AB test, hypotheses regarding the effect applied on the data are established. As an example, an interface change was made for a mobile application. Hypotheses for this situation:</p><p>H0: After the development, there was no change in the number of users using the application.<br>H1 (Alternative Hypothesis): After the development, there has been a change in the number of users using the application.</p><p>will be in the form. Expressing these hypotheses mathematically is:<br>H0 : M1 = M2<br>H1: It is in the form of M1 ≠ M2. The number of users here may also appear as a multiplier number in some environments. M1 in these mathematical expressions expresses the number of users before the effect, the average, while M2 expresses the number of users after the effect, the average.</p><p>Another point regarding the establishment of hypotheses is that there are one-way or two-way approaches in the formation of hypotheses. For example, for a website, “Users spending time on the website, the time to be on the home page is 18 seconds.” A one-sided approach can be used. We can also state the same proposition in a two-way manner. In this case, our hypothesis is, “Our users, who spend time on our website, are on our website for 72 seconds to 88 seconds at a 95% confidence interval.” will be in the form.</p><p>Let’s clarify a concept that we have highlighted in bold and italics in the last paragraph. Confidence interval is a value previously determined by the user in a study. Confidence interval, which is also seen as alpha in the literature, is a measure of the sensitivity of the study. The sector knowledge and experience of us who carried out the study is an important factor in determining this level of importance, and the level of confidence is determined based on these two important factors. In addition, the confidence interval also tells us the level of risk we will face if we reject or reject a situation or decision.</p><p>The importance level is one of the important milestones in studies. Due to this situation, the situations should be conveyed clearly and transparently to the decision makers while the studies are carried out. Otherwise, the result of the study will be far from meeting the expectations and the harm will be more than the potential benefit.</p><h4>2. Controlling to assumptions</h4><p>After the hypotheses are established, we perform the hypothetical controls to determine the test to be used in the study. There are two assumptions we will check.</p><ol><li>Normality assumption</li></ol><p><strong><em>*Note: Before examining the assumption of normality, it may be useful to make adjustments that do not affect the general structure of the data, such as monthly value analysis, missing value analysis, and data manipulation, if necessary.</em></strong></p><p>2. Assumption of homogeneity of variance.</p><p>The normality assumption assumes that the relevant variable is normally distributed for the effect we are testing on the dataset. And its proposition is “There is no significant difference between the data distribution and the theoretical normal distribution”. To check the assumption of normality, the shapiro-wilks test is performed in python. If the P-value we have obtained as a result of this test is less than 0.05, we will reject the hypothesis and we will see that the data is not normally distributed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*QyAqZT-H_zckoPZym39cVw.png" /><figcaption>An example of controlling to normality assumption</figcaption></figure><p>The second assumption is the homogeneity of variance assumption. In the analysis of variance, a result emerged after the effect. This result is the change on the variable of interest for the samples taken before and after the effect. With the variance homogeneity control, we check whether the distribution of the variable of interest after the effect and the distribution of the data before the effect are similar. Levene’s test is used to test the variance homogeneity assumption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*G-9OF4fryxDqzRrPfsWv3g.png" /><figcaption>An example of controlling to variance homogenity assumption</figcaption></figure><h4>3. Application of hypotheses</h4><p>At this stage, after performing the assumption checks, we determine the tests that we will apply according to the assumption results we have obtained.</p><p>There are some situations that we consider when determining the test to be applied:</p><p>1. When the assumptions of normality and homogeneity of variance are checked, if both assumptions are met, then two independent sample T-tests are performed.</p><p><strong><em>**Note: After the control, the assumption of normality was provided; If variance homogeneity is not provided, T-Test is used again, but the “equal_vars = False” argument is entered during the test.</em></strong></p><p>2. After the assumption checks, if the assumption of normality is not provided, the “<strong>Manwhitneyu</strong>” test, which is one of the non-parametric tests, is performed.</p><h4>4. Result</h4><p>In the final stage of the study, after performing the assumption checks, we apply the tests that are suitable for our data (T-test, manwhitneyu test)</p><p>Then, based on the test output, we comment on the H0 and H1 hypotheses that we determined at the beginning of our study. At this stage, if the result of the test we determined as a result of the assumption control is lower than the value of 0.05, which is the alpha value (P-val), we reject the H0 hypothesis determined at the beginning of the study. Let’s remember the H0 hypothesis that we determined at the beginning of the study:</p><p>H0: After the development, there was no change in the number of users using the application.<br>H1 (Alternative Hypothesis): After the development, there has been a change in the number of users using the application.</p><p>Here we end the first article of our series. I hope it was an enjoyable reading session for you. See you in our next article :)</p><p>You can visit <a href="https://github.com/ccemozclk">my github profile</a> in the <a href="https://github.com/ccemozclk/AB_testing">link</a> for a more detailed applied study of the article.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cad3b17c78b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Football Analytics 101: How To Scrape Data From Understat.com]]></title>
            <link>https://medium.com/@i.cemozcelik/football-analytics-101-how-to-scrape-data-from-understat-com-74ea1cb0da17?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/74ea1cb0da17</guid>
            <category><![CDATA[football-analytics]]></category>
            <category><![CDATA[beautifulsoup]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Sat, 11 Jun 2022 20:13:00 GMT</pubDate>
            <atom:updated>2022-07-02T17:43:29.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M190nZ0jO9QmJyX2yr8yVw.jpeg" /><figcaption>Photograph Via : Pexels, Pixabay</figcaption></figure><p>Hello from another data science project. How r u ? I hope you all are cool. Today was a very productive day for me and I had the opportunity to make an introduction to a topic that I had postponed for myself for a long time. Yes, I wanted to start working on football analytics for a long time, but I kept putting it off. And I asked to myself why don’t I start today?</p><p>Today we will be doing an introductory study on football analytics and we will get our own data from understat.com. There are already many companies that keep the data revealed in football matches, such as statsbomb, whyscout, opta. But sometimes, having the freedom to scrape our own data will allow us to work faster in the studies we want to do, and according to our analytical approach, we will be able to get our data from the site we want as we want. The technique we use for this is web scrapping!! For this, we will use the BeautifulSoup library and Request libraries. Without further ado, we can move on to our study.</p><p>There is one thing I would like to point out before we start our study. In our study, we will be obtaining the data of the Aston Villa match from understat.com, where we witnessed the epic championship of Manchester City, which has signed an epic championship this season. In this match, we will transform the columns that have taken place and the goal expectations values of the columns scored by the players into a table and transform them as a dataset. So let’s start!!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a43eca216851816ce7af64562db0384/href">https://medium.com/media/5a43eca216851816ce7af64562db0384/href</a></iframe><p>Ok, now we assign the website from which we will receive our data to a variable and define the match ID variable. I’ll explain the <strong>Match ID</strong> part again.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/341f007218f083a036379635b381b858/href">https://medium.com/media/341f007218f083a036379635b381b858/href</a></iframe><p><strong>MatchID</strong>, which we saw in the above image, is an ID located at the end of the URL when we enter the relevant event, namely the Manchester City-Aston Villa match.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPVJC3inNR_UmeNynazq6A.png" /><figcaption>The Explanation of the MatchID</figcaption></figure><p>We got the matchID from the URL. Now, we get all the materials on the web page related to the Request.get method from the matchID we have, and then we parser the HTML elements with BeautifulSoup.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1543f631a1eabefec5f4a5e2a53ee4d/href">https://medium.com/media/c1543f631a1eabefec5f4a5e2a53ee4d/href</a></iframe><p>Above, I stated that we only want to take the shots that took place in the match. Now we only get the shots that took place in the match.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27b847a327585813a0b6801418e0cee5/href">https://medium.com/media/27b847a327585813a0b6801418e0cee5/href</a></iframe><p>Let’s see what’s inside the strings :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pnJ9TkEd6BFZxd6kioC5UA.png" /></figure><p>It looks very chaotic.Now let’s bring this structure to a more regular form.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5549977eaa7b8abc3424c3833741eaf4/href">https://medium.com/media/5549977eaa7b8abc3424c3833741eaf4/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*zf2onM7cK6YytMV89xiX7Q.png" /><figcaption>Home Team</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*t0Jb1LzGhfWk5jyqI9uhTQ.png" /><figcaption>Away Team</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/745aa91a114e7c9343285f4b3c639c29/href">https://medium.com/media/745aa91a114e7c9343285f4b3c639c29/href</a></iframe><p>We transform the organized data into a dataframe. We also define the column names of the dataframe we have created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a81f066fb6e47e05d8a25afef46f36f8/href">https://medium.com/media/a81f066fb6e47e05d8a25afef46f36f8/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qO5u4xwW6i0Y9vATsp7-Ew.png" /><figcaption>The Overlook Of Final Dataset</figcaption></figure><p>We put the scattered shot data on the website into a table. Here, our important variable is the result variable. Result variable contains various unique values. These values indicate that the shot was scored (Goal), blocked by an opponent player (BlockedShot), saved by the goalkeeper (SavedShot) and the shot leaving the field of play (MissedShots).</p><p>Web scrapping is used as a very useful method when we can’t get a data set from organizations such as Statsbomb that hold the data of sports competitions, or when we want to perform a different analysis approach. In this study, we saw that we can simply obtain football data from a web page. In our next studies, we will focus on more comprehensive topics on football analytics. We have come to the end of our article, I hope it was a pleasant reading session for you.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74ea1cb0da17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DATA SCIENCE PROJECT: PREDICTING THE AMOUNT OF SURGERY]]></title>
            <link>https://medium.com/@i.cemozcelik/data-science-project-predicting-the-amount-of-surgery-8186fddd459b?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/8186fddd459b</guid>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Sat, 11 Jun 2022 14:35:23 GMT</pubDate>
            <atom:updated>2022-06-22T05:15:31.772Z</atom:updated>
            <content:encoded><![CDATA[<p>This article written by <a href="https://medium.com/u/fe99f0a4a612">Alparslan Mesri</a> &amp; <a href="https://medium.com/u/e7aec74cd6ed">Cem ÖZÇELİK</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*egC80uYBfqEZqBVR8BxlOQ.jpeg" /><figcaption>Photograph via: Pexel, Vidal Balielo Jr.</figcaption></figure><p>It is very important for a health institution that the patients who come to this institution leave the health institution satisfied. On the other hand, the patients who come to the health institution leave satisfied, the service they have received, the positive approaches of the health institution employees, the facilities provided by the equipment of the institution to the visitors, etc. It is fed by various parameters such as At the same time, in addition to providing these opportunities to its visitors, there are also measures that a health institution can take in various areas in order to serve more than one patient or visitor and to get the best service for the patients who are in the customer position. For example, the correct planning of the appointments given to the patients, the time to deal with a patient, the precautions and preparations to be made for the post-operative care services of the patients who need surgery will increase the satisfaction of the patients.</p><p>In our study, we focused on a problem in order to prevent the disruptions arising from planning in the post-operative processes in order to ensure the satisfaction of the patients who need to have an operation in a hospital. And in this context, “How many days before the operation should a patient be given the date of surgery?” We went to the question. So much so that with the answer we can find to this problem, while the patients are planning their own lives, the healthcare institution management will be able to make their own planning so that the patient can get the best service in the post-operative period.</p><p>In this article, surgeries performed in a health institution have been studied on a sample data set, and how many days in advance is it appropriate to give the surgery date so that the health institution can provide the best service to these patients? An attempt was made to find an answer to the question.</p><p>The data set we used in the study will be shared at the end of the study. Without further ado, let’s get to our work. Let’s start by importing our libraries first.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6de0add245bb1582795e3caecd499ce/href">https://medium.com/media/e6de0add245bb1582795e3caecd499ce/href</a></iframe><p>Next, we import to dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/841eed543117ce5b47c451ac0adfbeb3/href">https://medium.com/media/841eed543117ce5b47c451ac0adfbeb3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6VAsUizercA8oOulGXs8Lg.png" /><figcaption>Overview of the dataset</figcaption></figure><p>Take a look at the descriptive statistics of the data set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43c0dd5c3c56f2a5af4c55918321d8ca/href">https://medium.com/media/43c0dd5c3c56f2a5af4c55918321d8ca/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*xKSQRb36q1ZH02Ujug-2qQ.png" /><figcaption>Descriptive Statistics</figcaption></figure><p>As can be seen, our dataset includes Actual(Number of operations performed on the date of the operation) and the number of operations 28 days before the time point named Actual. The values ​​in the data set are increasing cumulatively.</p><p>Here, our next step will be to look at the auto-correlation values ​​between the days. Since the problem we are considering can be considered as a time series problem, we will use the auto-correlation value to find the connection between the event occurring in a time unit and the event occurring in the previous time unit. To give brief information about the auto-correlation value, the auto-correlation between the day before today and today is always considered ~1.00 and the correlation will gradually decrease as of today.</p><p>Now, by making an aggregation between the days of the week, is there a connection between the days of the week and the surgeries performed in the health institution? Let’s answer your question. Here, we have aggregated according to the time zone T-1, which has the highest autocorrelation with the Actual value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c510ce5f814b68e9b6cd218673b2abe/href">https://medium.com/media/0c510ce5f814b68e9b6cd218673b2abe/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*KORY1ZhvmQkH15_uXGYyfw.png" /><figcaption>Mean &amp; Std. Dev by DOW</figcaption></figure><p>The first 5 rows in this image show the mean values and the next 5 rows show the std deviations.</p><p>Now that we have seen the statistical values of our dataset, let’s get more descriptive information about our dataset and the problem we are dealing with by doing data visualization.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d43eeb5835aced1d90671c52d7bddfe/href">https://medium.com/media/5d43eeb5835aced1d90671c52d7bddfe/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*jPAn7tBiZ_q3q9OziCD83g.png" /><figcaption>Distribution by DOW</figcaption></figure><p>As can be seen, the most surgeries are on Thursday in the days of the week. The least number of surgeries take place on Friday. Let’s also examine the average differences in the number of surgeries performed using boxplot.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71a290de84107e70f4747e82874f1f5d/href">https://medium.com/media/71a290de84107e70f4747e82874f1f5d/href</a></iframe><p>The output of the above piece of code is shown in the graph below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*zpl-aLIpca9W-d_EbZ8Dlg.png" /></figure><p>We see that by looking at the number of surgeries performed on the days of the week, we can conclude that there is a difference between the averages. Since Friday and Monday are the end and start days of the week, we can interpret that the noise level is more prominent on these two days.</p><p>After visualizing the variables of the data set, let’s perform anomaly test for the numerical variables in the data set. We will use the One-Way ANOVA test for this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d346ec7aea1924cdd8f6f19c82fc1c4/href">https://medium.com/media/3d346ec7aea1924cdd8f6f19c82fc1c4/href</a></iframe><p>As the output of this code, we get the following image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*AfrcV2RJ9no2LO_91LWS3w.png" /><figcaption>Statistical Informations By Timestamp</figcaption></figure><p>Since we examined the mean and std deviation values of the variables named <strong>T-x*</strong> in the data set in a table, we can perform our <strong>ANOVA</strong> test. Before performing our <strong>ANOVA</strong> test, let’s set up our alternative hypotheses, which we call <strong>H0</strong> and <strong>H1</strong>:</p><p><strong>H0</strong>: The total number of surgeries does not differ according to the day of the week.<br><strong>H1 (Alternative Hypothesis):</strong> The total number of operations varies according to the day of the week.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e88023936d31795b8636bed52b70235b/href">https://medium.com/media/e88023936d31795b8636bed52b70235b/href</a></iframe><p>The result table of the <strong>ANOVA</strong> test we performed is as follows. Below the table, you can see the results of the <strong>ANOVA</strong> test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*C5WIYufIdta5ffaVEKruEQ.png" /><figcaption>Results of One-Way ANOVA Test</figcaption></figure><ul><li>By looking at the results of the ANOVA test, <strong>we reject the H0 hypothesis at the 99% confidence</strong>&lt;We see that the P value we see as a result of the test is &lt;0.05&gt;</li><li>Looking at the test result, we can clearly say: T<strong>here is a clear difference between the days of the week.</strong></li></ul><p>After this stage, we test with the <strong>TUKEY</strong> test whether there is a significant difference between the number of operations performed on one day of the week and another weekday in combination with it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05a5ba6b7d508bc9ae78dbe849085152/href">https://medium.com/media/05a5ba6b7d508bc9ae78dbe849085152/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*D0JKWVt2yB_p8hfnUV3Oiw.png" /><figcaption>Result Of TUKEY Test</figcaption></figure><p>TUKEY Test results show us that there is a difference between the number of operations performed on any weekday and the number of operations performed in another week.</p><p>Now, “<strong>How many days before the surgery can we give the most appropriate surgery appointment to a patient who comes to the hospital for surgery?</strong>” We will be establishing a linear regression model to find an answer to the question.</p><p>First, we clarify the parameters of our model that we will build on our dataset:</p><ul><li>The dependent variable to be used in the Linear Regression model is the “<strong>Actual</strong>” variable. Our arguments are all columns <strong>T-1 </strong>through <strong>T-28</strong>.</li></ul><p>We already know the business problem we’re dealing with here. And we achieve the result we want to achieve by obtaining the unit of time that has the highest correlation with the Actual Variable. We can move on to building our model.</p><p>The point we pay attention to when setting up the model is that we need to clear the outlier parts of our data set from the data set. (We saw the outlier values in the box plot)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d6d65c255e830172fa9bec65cd796d3/href">https://medium.com/media/9d6d65c255e830172fa9bec65cd796d3/href</a></iframe><p>Then let’s start building our model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de7866b1478815d9f4842fc26f442eea/href">https://medium.com/media/de7866b1478815d9f4842fc26f442eea/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4PY4SJcRc559qzdB56drQ.png" /><figcaption>The Table Of OLS</figcaption></figure><p>By looking at the OLS table, we can derive the equation for our regression model:</p><p><strong>ACTUAL = (T-1)*1.0908 + (T-2)*0.1453 + (T-3)*(-0.1908) + 0*</strong></p><p>*<strong>NOTE</strong>: Since the model does not contain a constant, std. we got zero error amount.</p><p>We fit to model:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7dc05dc9dd1c6d783c6b107a851f3c63/href">https://medium.com/media/7dc05dc9dd1c6d783c6b107a851f3c63/href</a></iframe><p>The output image of the fitted model is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwEZtOpFdNXxHWLrF9mSsQ.png" /><figcaption>Result of Fitted Regression Model</figcaption></figure><p>We calculate to other performance metrics, RMS , RMSE, and other regression model metrics for the model we fit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f83db4fd52553aa83e87c2cf4aec5c8f/href">https://medium.com/media/f83db4fd52553aa83e87c2cf4aec5c8f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c89182a33135734eafac5ff46a1bd0e/href">https://medium.com/media/4c89182a33135734eafac5ff46a1bd0e/href</a></iframe><p>We set up our model for T-1, T-2, T-3 time points and obtained performance metrics. And now we set up a model again in order to find the compatibility between the surgery performed 3 days before the surgery date and the reality.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e3c69bfa4c884289bfcf0cf185b314d/href">https://medium.com/media/7e3c69bfa4c884289bfcf0cf185b314d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/faa236d13f3ce510988781e2dc7770b3/href">https://medium.com/media/faa236d13f3ce510988781e2dc7770b3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*q_18v2yKj3c7POa0YPwX6g.png" /><figcaption>OLS Table for Predicting Model for 3 days before the Surgery Date</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9adffd7a0af44e7734cecaef4447c58b/href">https://medium.com/media/9adffd7a0af44e7734cecaef4447c58b/href</a></iframe><p>We built our model that predicts the number of surgeries performed 3 days before the surgery date and obtained performance metrics. In order to find the compatibility between the surgery performed 7 days before the surgery date and the reality, after this step we find out which appointment date is the most appropriate time period for the health institution by re-establishing a model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3889fc6b7c1c416bffc0f294798800e8/href">https://medium.com/media/3889fc6b7c1c416bffc0f294798800e8/href</a></iframe><p>We set up our model 7 days before the operation date and obtained the outputs related to our model performance. Now we compare the models we have established in order to make a clear decision on the most appropriate appointment date for the surgery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*corKVFDjViUcc2-BR3V0LA.png" /><figcaption>Comparison of the models</figcaption></figure><p>Considering this table, we can say that:</p><ul><li>The health institution examined in the data set can accurately determine the surgical expectations 3 days before the surgery day, with the least estimation error.</li><li>Technically, the result we obtained is the day with the highest correlation with the day of the surgery in the last 3 days. The surgery appointment can be given by looking at the situation 3 days before the surgery.</li></ul><p>We got our result, and finally, we look at how the model we built follows a pattern in the time series graph.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41b3b26ed152e477d834b061e5bcc99c/href">https://medium.com/media/41b3b26ed152e477d834b061e5bcc99c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RQWtQGym_IahIStbLDJ3jQ.png" /><figcaption>The overlook’s of prediction model</figcaption></figure><p>We have come to the end of our work. I hope it was an enjoyable reading session for you. See you in our next article.</p><p>Data Set Source:</p><ul><li><a href="https://github.com/rashidesai24/Vanderbilt-University-Medical-Center-Elective-Surgery-Schedule">GitHub - rashidesai24/Vanderbilt-University-Medical-Center-Elective-Surgery-Schedule</a></li><li><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8186fddd459b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VERİ BİLİMİ PROJESİ : AMELİYAT MİKTARI TAHMİNLEME]]></title>
            <link>https://medium.com/@i.cemozcelik/veri%CC%87-bi%CC%87li%CC%87mi%CC%87-projesi%CC%87-ameli%CC%87yat-mi%CC%87ktari-tahmi%CC%87nleme-eea69c8b2733?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/eea69c8b2733</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Sat, 11 Jun 2022 13:59:46 GMT</pubDate>
            <atom:updated>2022-06-11T14:17:14.390Z</atom:updated>
            <content:encoded><![CDATA[<h3>VERİ BİLİMİ PROJESİ : AMELİYAT MİKTARI TAHMİNLEME</h3><p>Bu makale <a href="https://medium.com/u/fe99f0a4a612">Alparslan Mesri</a> ve <a href="https://medium.com/u/e7aec74cd6ed">Cem ÖZÇELİK</a> tarafından yazılmıştır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*egC80uYBfqEZqBVR8BxlOQ.jpeg" /><figcaption>Photograph via: Pexel, Vidal Balielo Jr.</figcaption></figure><p>Bir sağlık kuruluşu için bu kuruluşa gelen hastaların sağlık kuruluşundan memnun olarak ayrılması oldukça önemlidir. Sağlık kuruluşuna gelen hastaların memnun olarak ayrılması ise, almış oldukları hizmet, sağlık kuruluşu çalışanlarının pozitif yaklaşımları, kuruluşun ekipmanlarının ziyaretçilere sunduğu imkanlar vb. gibi çeşitli parametrelerden beslenmektedir. Aynı zamanda bir sağlık kuruluşunun da ziyaretçilerine bu imkanları sunmanın yanında birden fazla hastaya yada ziyaretçiye hizmet verebilmek ve müşteri konumunda olan hastaların en iyi hizmeti almaları için çeşitli alanlarda alabileceği önlemler de mevcuttur. Örneğin hastalara verilen randevuların doğru planlanması, bir hasta ile ilgilenme süresi, ameliyat olması gereken hastaların ameliyat sonrasındaki bakım hizmetleri hususunda alacakları önlem ve yapacakları hazırlıklar, hastaların memnuniyetini arttıracaktır.</p><p>Biz de çalışmamızda bir hastanede operasyon geçirmesi gereken hastaların memnuniyetinin sağlanabilmesi için operasyondan sonraki süreçlerde planlamadan doğan aksaklıkların önüne geçebilmek amacı ile bir problem üzerinde durduk. Ve bu bağlamda “Operasyon geçirmesi gereken bir hastaya ameliyattan kaç gün önce ameliyat tarihi verilmelidir ?” sorusunun üzerine gittik. Öyle ki bu soruna bulabileceğimiz yanıt ile hastalar kendi yaşamlarında planlamalarını da yaparken sağlık kuruluşu yönetimi de hastanın operasyon sonraki süreçte en iyi hizmeti alabilmesi için kendi planlamasını yapabilecektir.</p><p>Bu makalede örnek bir veri seti üzerinden bir sağlık kuruluşunda gerçekleşen ameliyatlar üzerinde çalışılmış ve sağlık kuruluşunun bu hastalara en iyi hizmeti sunabilmesi için kaç gün önceden ameliyat tarihi verilmesi uygundur? sorusuna cevap aranmaya çalışılmıştır.</p><p>Çalışmada kullanmış olduğumuz veri seti çalışma sonunda paylaşılıyor olacaktır. Daha fazla uzatmadan çalışmamıza geçelim. İlk olarak kütüphanelerimizi import ederek başlayalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6de0add245bb1582795e3caecd499ce/href">https://medium.com/media/e6de0add245bb1582795e3caecd499ce/href</a></iframe><p>Daha sonrasında veri setimizi import edelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/841eed543117ce5b47c451ac0adfbeb3/href">https://medium.com/media/841eed543117ce5b47c451ac0adfbeb3/href</a></iframe><p>Bu kod parçasının çıktısı aşağıdaki gibidir :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6VAsUizercA8oOulGXs8Lg.png" /><figcaption>Veri setinin gorunumu</figcaption></figure><p>Veri setimize ait tanımlayıcı istatistiklere de göz atalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43c0dd5c3c56f2a5af4c55918321d8ca/href">https://medium.com/media/43c0dd5c3c56f2a5af4c55918321d8ca/href</a></iframe><p>Bu kod parçasının çıktısı aşağıda görülmektedir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*xKSQRb36q1ZH02Ujug-2qQ.png" /><figcaption>Tanimlayici istatistikler</figcaption></figure><p>Görüldüğü gibi, veri setimiz Actual(Ameliyatın olduğu tarihte gerçekleşen ameliyat sayısı) ve Actual isimli zaman noktasından 28 gün öncesine ait ameliyat sayılarını içermektedir. Veri setindeki değerler kümülatif artmaktadir.</p><p>Burada sıradaki işlemimiz günler arasındaki oto-korelasyon değerlerine bakmak olacaktır. Ele aldığımız problem bir zaman serisi problemi de sayılabileceği için, bir zaman biriminde ortaya çıkan event ile kendinden önceki zaman biriminde gerçekleşen event arasındaki bağlantıyı bulmamız için oto-korelasyon değerinden faydalanacağız. Oto-korelasyon değeri hakkında kısaca bilgi vermek gerekirse, bugünden bir gün önce ile bugün arasındaki oto-korelasyon her zaman ~1.00 kabul edilir ve bugun itibari ile korelasyon giderek düşecektir.</p><p>Şimdi de haftanın günleri arasında bir toplulaştırma yaparak haftanın günleri ile sağlık kuruluşunda gerçekleşen ameliyatlar arasında bir bağlantı var mı? Sorusunu yanıtlamış olalım. Burada Actual değeri ile en yüksek oto-korelasyona sahip olan zaman dilimi T-1 e göre toplulaştırma yaptık.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c510ce5f814b68e9b6cd218673b2abe/href">https://medium.com/media/0c510ce5f814b68e9b6cd218673b2abe/href</a></iframe><p>Bu kod parçasının çıktısı aşağıdaki gibidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*KORY1ZhvmQkH15_uXGYyfw.png" /><figcaption>Mean &amp; Std. Dev by DOW</figcaption></figure><p>Bu görselde görülen ilk 5 satır ortalama değerleri gösterir ve sonraki 5 satır ise std sapmaları gösterir.</p><p>Artık veri setimize ait istatiksel değerleri gördüğümüze göre, veri görselleştirme de yaparak veri setimiz ve ele aldığımız problem hakkında daha açıklayıcı bilgilere ulaşalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d43eeb5835aced1d90671c52d7bddfe/href">https://medium.com/media/5d43eeb5835aced1d90671c52d7bddfe/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*jPAn7tBiZ_q3q9OziCD83g.png" /><figcaption>Distribution by DOW</figcaption></figure><p>Görülebileceği üzere, haftanın günlerinde en fazla ameliyat Perşembe günüdedir. En az ameliyat ise Cuma günü gerçekleşmektedir. Bir de boxplot kullanarak gerçekleşen ameliyat sayılarındaki ortalama farklarını inceleyelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71a290de84107e70f4747e82874f1f5d/href">https://medium.com/media/71a290de84107e70f4747e82874f1f5d/href</a></iframe><p>Yukarıdaki kod parçasının çıktısı aşağıdaki grafikte görülmektedir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*zpl-aLIpca9W-d_EbZ8Dlg.png" /></figure><p>Görüyoruz ki, haftanın günlerinde gerçekleşen ameliyat sayılarına bakarak ortalamalar arasında bir fark vardır sonucuna ulaşabiliriz. Cuma ve Pazartesi günleri haftanın bitiş ve başlangıç günleri oldukları için gürültü düzeyinin bu iki günde daha belirgin olarak kendini gösterdiği yorumunu yapabiliriz.</p><p>Veri setine ait değişkenleri görselleştirdikten sonra veri setindeki sayısal değişkenler için anormallik testi gerçekleştirelim. Bunun için <strong>One-Way ANOVA</strong> testinden faydalanacağız.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d346ec7aea1924cdd8f6f19c82fc1c4/href">https://medium.com/media/3d346ec7aea1924cdd8f6f19c82fc1c4/href</a></iframe><p>Bu kodun çıktısı olarak da aşağıdaki görseli elde ediyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*AfrcV2RJ9no2LO_91LWS3w.png" /><figcaption>Statistical Informations By Timestamp</figcaption></figure><p>Veri setinde yer alan <strong>T-x*</strong> olarak isimlendirilmiş değişkenlerin ortalama ve std sapma değerlerini de bir tablo halinde incelediğimize göre ANOVA testimizi gerçekleştirebiliriz. ANOVA testimizi gerçekleştirmeden önce <strong>H0</strong> ve <strong>H1</strong> olarak isimlendirdiğimiz alternatif hipotezlerimizi kuralım:</p><p><strong>H0</strong>: Toplam ameliyat sayısı haftanın gününe göre farklılık göstermez<br><strong>H1(Alternatif Hipotez)</strong>: Toplam ameliyat sayısı haftanın gününe göre değişmektedir.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e88023936d31795b8636bed52b70235b/href">https://medium.com/media/e88023936d31795b8636bed52b70235b/href</a></iframe><p>Gerçekleştirdiğimiz ANOVA testimize ait sonuç tablosu aşağıdaki gibidir. Tablonun altında ise ANOVA testine ait sonuç yorumlarını görebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*C5WIYufIdta5ffaVEKruEQ.png" /><figcaption>Results of One-Way ANOVA Test</figcaption></figure><ul><li>ANOVA testi sonucuna bakarak H0 hipotezini %99 güven aralığında reddetmiş oluyoruz.&lt;Test sonucunda gördüğümüz P değeri &lt;0.05 olduğunu görmekteyiz&gt;</li><li>Test sonucuna bakarak açıkça söyleyebiliriz ki : <strong>Haftanın günleri arasında net bir fark vardır .</strong></li></ul><p>Bu aşamadan sonra haftanın bir günü ile kombinasyon halinde olan diğer bir hafta gününde gerçekleşen ameliyat sayıları arasında anlamlı bir fark olup olmadığını TUKEY testi ile test ediyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05a5ba6b7d508bc9ae78dbe849085152/href">https://medium.com/media/05a5ba6b7d508bc9ae78dbe849085152/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*D0JKWVt2yB_p8hfnUV3Oiw.png" /><figcaption>Result Of TUKEY Test</figcaption></figure><p>TUKEY Testi sonuçları bize gösteriyor ki herhangi bir hafta içi gününde gerçekleşen ameliyat sayısı ile başka bir hafta içinde gerçekleşen ameliyat sayısı arasında farklılık vardır.</p><p>Şimdi ise, <strong>“Ameliyat başvurusu için hastaneye gelen bir hastaya en uygun ameliyat randevusunu ameliyattan kaç gün önce verebiliriz?”</strong> sorusuna yanıt bulmak amacı ile lineer regresyon modeli kuruyor olacağız.</p><p>İlk olarak veri setimiz üzerinde kuracak olduğumuz modelimizin parametrelerini netleştirelim:</p><ul><li>Lineer Regresyon modelinde kullanılacak bağımlı değişken “<strong>Actual</strong>” değişkenidir. Bağımsız değişkenlerimiz ise <strong>T-1</strong>&#39;den <strong>T-28</strong>&#39;e kadar tüm sütunlardır.</li></ul><p>Burada üzerinde durduğumuz iş problemini halı hazırda biliyoruz. Ve ulaşmak istediğimiz sonuca da Actual Değişkeni ile en yüksek korelasyona sahip zaman birimini elde ederek yapıyoruz. Modelimizi kurmaya geçebiliriz.</p><p>Modeli kurarken dikkat ettiğimiz husus, veri setimizde outlier olarak geçen kısımları veri setinden temizlememiz gerekli.(Box plotta outlier değerlerini görmüştük)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d6d65c255e830172fa9bec65cd796d3/href">https://medium.com/media/9d6d65c255e830172fa9bec65cd796d3/href</a></iframe><p>Sonrasında modelimizi kurmaya başlayalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de7866b1478815d9f4842fc26f442eea/href">https://medium.com/media/de7866b1478815d9f4842fc26f442eea/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4PY4SJcRc559qzdB56drQ.png" /><figcaption>The Table Of OLS</figcaption></figure><p>OLS tablosuna bakarak regresyon modelimize dair denklemi elde edebiliriz:</p><p>ACTUAL = <strong>(T-1)*1.0908 + (T-2)*0.1453 + (T-3)*(-0.1908) + 0*</strong></p><p><em>*NOT : Model bir sabit içermediği için std. hata miktarını sıfır aldık.</em></p><p>Modelimizi fit edelim:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7dc05dc9dd1c6d783c6b107a851f3c63/href">https://medium.com/media/7dc05dc9dd1c6d783c6b107a851f3c63/href</a></iframe><p>Fit edilen modele ilişkin çıktı görseli aşağıdaki gibidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwEZtOpFdNXxHWLrF9mSsQ.png" /><figcaption>Result of Fitted Regression Model</figcaption></figure><p>Fit ettiğimiz modele ilişkin, performans metriklerimiz olan RMS , RMSE ve diğer regresyon modeli metriklerini de bulalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f83db4fd52553aa83e87c2cf4aec5c8f/href">https://medium.com/media/f83db4fd52553aa83e87c2cf4aec5c8f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c89182a33135734eafac5ff46a1bd0e/href">https://medium.com/media/4c89182a33135734eafac5ff46a1bd0e/href</a></iframe><p>T-1, T-2, T-3 zaman noktalarına ilişkin modelimizi kurduk ve performans metriklerini elde ettik. Ameliyat tarihinden 3 gün önce gerçekleşen ameliyatlar ile gerçek arasındaki uyumluluğu bulabilmek için yeniden bir model kuralım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e3c69bfa4c884289bfcf0cf185b314d/href">https://medium.com/media/7e3c69bfa4c884289bfcf0cf185b314d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/faa236d13f3ce510988781e2dc7770b3/href">https://medium.com/media/faa236d13f3ce510988781e2dc7770b3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*q_18v2yKj3c7POa0YPwX6g.png" /><figcaption>OLS Table for Predicting Model for 3 days before the Surgery Date</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9adffd7a0af44e7734cecaef4447c58b/href">https://medium.com/media/9adffd7a0af44e7734cecaef4447c58b/href</a></iframe><p>Ameliyat tarihinden 3 gün öncesinde gerçekleşen ameliyat sayılarını tahminleyen modelimizi kurduk ve performans metriklerini elde ettik. Bir de Ameliyat tarihinden 7 gün önce gerçekleşen ameliyatlar ile gerçek arasındaki uyumluluğu bulabilmek için yeniden bir model kurarak hangi randevu tarihinin sağlık kuruluşu için en uygun zaman dilimi olduğunu bulalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3889fc6b7c1c416bffc0f294798800e8/href">https://medium.com/media/3889fc6b7c1c416bffc0f294798800e8/href</a></iframe><p>Ameliyat tarihinden 7 gün öncesine göre de modelimizi kurduk ve model performansımıza ilişkin çıktıları elde ettik. Şimdi ameliyat için en uygun randevu tarihi konusunda net bir karar verebilmek için kurmuş olduğumuz modelleri karşılaştıralım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*corKVFDjViUcc2-BR3V0LA.png" /><figcaption>Comparison of the models</figcaption></figure><p>Bu tabloyu göz önünde bulundurarak söyleyebiliriz ki:</p><ul><li>Veri setinde incelenen sağlık kuruluşu ameliyat gününden 3 gün öncesine ait ameliyat beklentilerini doğru şekilde, en az tahmin hatası ile saptayabilmektedir.</li><li>Teknik olarak da çıkarttığımız sonuç, son 3 gün ameliyatın gerçekleştiği gün ile en fazla korelasyona sahip olan gündür. Ameliyat randevusu ameliyattan 3 gün öncesindeki duruma bakılarak verilebilir.</li></ul><p>Sonucumuzu elde ettik ve son olarak kurmuş olduğumuz modelin zaman serisi grafiğinde nasıl bir desen takip ettiğine bakıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41b3b26ed152e477d834b061e5bcc99c/href">https://medium.com/media/41b3b26ed152e477d834b061e5bcc99c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RQWtQGym_IahIStbLDJ3jQ.png" /><figcaption>The overlook’s of prediction model</figcaption></figure><p>Bir çalışmamızın daha sonuna geldik. Umarım sizin adınıza keyifli bir okuma seansı olmuştur. Bir sonraki yazımızda görüşmek üzere.</p><p>Veri Seti Kaynağı:</p><p><a href="https://github.com/rashidesai24/Vanderbilt-University-Medical-Center-Elective-Surgery-Schedule">GitHub - rashidesai24/Vanderbilt-University-Medical-Center-Elective-Surgery-Schedule</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eea69c8b2733" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CRM Analytics : Customer Segmentation & Customer Lifetime Value Prediction]]></title>
            <link>https://medium.com/@i.cemozcelik/crm-analytics-customer-segmentation-customer-lifetime-value-prediction-1163fa6e4ae9?source=rss-e7aec74cd6ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/1163fa6e4ae9</guid>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[crm]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Cem ÖZÇELİK]]></dc:creator>
            <pubDate>Thu, 19 May 2022 19:34:13 GMT</pubDate>
            <atom:updated>2022-06-19T04:30:29.166Z</atom:updated>
            <content:encoded><![CDATA[<h3>CRM Analytics : Customer Segmentation &amp; Customer Lifetime Value Prediction</h3><p>Hello everyone, after a long time, we are together with you again in a new case. Today, in the data age, a study is carried out on the customer relationship management of businesses and customers, which have a great role in the continuity and profitability of businesses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z4JHf9-CW3FKjgJ9ajV0hg.jpeg" /></figure><p>Gaining the loyalty of a customer is a very important issue for a business to maintain its profitability. As we can understand from the studies conducted in this field, retaining a customer is much more economical and profitable than acquiring a new customer. In fact, to add an interesting statistic in this regard, the cost of acquiring a new customer reveals an extra cost that can vary between 5 and 10 times the cost of retaining an existing customer. Even if we look at this scenario from a different perspective, we can say that losing an existing customer may cause both the elimination of the added value added by the existing customer to the company and the increase in the expenses of the company when finding a new customer to replace the old customer.</p><p>So, where should we start to retain our current customers in order to best manage the customer factor that has such an impact on our business? What steps need to be taken to make those who buy your products and services more committed to your company? How can you identify the current needs, demands and complaints of your customers? Starting from these questions, we can look at different performance metrics and calculations in the scientific world.</p><p>Let’s go over the customer lifetime value, which is the most important metric that we come across here and which you will encounter in this study as well. So what is the customer lifetime value?</p><p>In a simple description, customer lifetime value can also be defined as the expected return on investment made for a customer over a certain period of time. Or, to be a little more descriptive, as another description, “The profit made from the first purchase a customer makes from your business to the time they stop shopping” gives the customer lifetime metric.</p><p>The result we have obtained from these two short explanations is a metric used in the processes of customer lifetime value, gaining new customers, increasing the tendency to buy with direct or cross-selling methods, tracking customer behaviors and making strategic decisions.</p><p>Customer lifetime value, which is one of the important performance criteria, cannot be calculated accurately by many businesses today. By calculating the customer lifetime value metric correctly, you can decide the cost you have to spend to acquire a customer. You can even predict more profitable for your business whether to gain new customers or increase revenue from existing customers.</p><p>After explaining what the customer lifetime value is, we will perform a sample customer segmentation study using the data of an e-shopping site and then calculate the customer lifetime value for these customers.So let’s start !</p><p>First, let’s import the libraries and packages that we will use in the study.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bab3617cfb36989906f53fb9a90e9e1/href">https://medium.com/media/8bab3617cfb36989906f53fb9a90e9e1/href</a></iframe><p>Then let’s import our sample data set to be used in the study.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4557ac3194fb934119673d9080768bba/href">https://medium.com/media/4557ac3194fb934119673d9080768bba/href</a></iframe><p>output of this line of code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ytS6itFKB72sbYb4i_JyTQ.png" /><figcaption>Overview of the dataset</figcaption></figure><p>After taking a good look at our dataset, let’s look at our descriptive statistics for exploratory data analysis of the dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/615aaffdec2f011a219f15e839e0295c/href">https://medium.com/media/615aaffdec2f011a219f15e839e0295c/href</a></iframe><p>The output of this image is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*ZU9UfzhmJwkQZIQWs0sZSg.png" /><figcaption>Descriptive statistics of the data set</figcaption></figure><p>We looked at the descriptive statistics of the dataset. Now let’s see the distribution of the shopping that took place on the shopping site according to the regions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb1fe6285eec43ab385cbe6a18422191/href">https://medium.com/media/fb1fe6285eec43ab385cbe6a18422191/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qHqcSoSVTT224SDm0Nomg.png" /><figcaption>Sales according to regions</figcaption></figure><p>After seeing the division of our total sales by regions, let’s look at the numerical variables in more detail and see the outliers and missing values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da87148cf4e3336898f1dc98180e4498/href">https://medium.com/media/da87148cf4e3336898f1dc98180e4498/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIEVrgnrfBq3ZCK5KVU8GA.png" /><figcaption>Descriptive Statistics</figcaption></figure><p>The information we obtained when we looked at these statistics is listed below:</p><ul><li>As we can see, some variables have missing values. The missing values of the Quantity and UnitPrice variables need to be cleared.</li><li>There are negative values in UnitPrice and Quantity. That mean is cancelled orders.</li><li>Quantity and Unit Price should be multiplied to create Total Price.</li><li>Missing values in Customer ID and Description.</li><li>InvoiceDate should be datetime, not object.</li></ul><p>After making these inferences based on descriptive statistics, we can move on to data preprocessing.</p><h4>Data Pre-Processing :</h4><p>First, let’s clean up the missing values in the data set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab92e0f4defd69efa264f5d4b029ad7e/href">https://medium.com/media/ab92e0f4defd69efa264f5d4b029ad7e/href</a></iframe><p>The output we get in this code blog is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cb21638ac56f013859448da4d5720c1/href">https://medium.com/media/1cb21638ac56f013859448da4d5720c1/href</a></iframe><p>We talked about canceled orders in our dataset. These data are data lines that start with the “c” character in the “Invoice No” column. We need to delete canceled orders from our dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d487d5c46cca27b411960a139725d3f5/href">https://medium.com/media/d487d5c46cca27b411960a139725d3f5/href</a></iframe><p>After deleting canceled orders datasets from our dataset, we also delete outliers from our dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e674afbfc0a55021f8cbf70739a0df4a/href">https://medium.com/media/e674afbfc0a55021f8cbf70739a0df4a/href</a></iframe><p>We create Total Price variable and look at the descriptive statistics again according to the new version of the data set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/700f03a551a9c48dff97e7caf9993f2a/href">https://medium.com/media/700f03a551a9c48dff97e7caf9993f2a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wSfku9tJxIZ7wNmDXhEIfQ.png" /><figcaption>New Descriptive Statistics</figcaption></figure><p>We have finished the preprocessing of our dataset. After the data preprocessing, we will dwell on the RFM analysis. First, we explain RFM and then RFM analysis work for our dataset.</p><h4>RFM Analysis :</h4><p>What is RFM Analysis? This is the question we must first clarify. RFM, stands for Recency, Frequency, and Monetary value, each corresponding to some key customer trait. In other words, it is some numerical value analysis that summarizes customer behavior. The reason we summarize in this way is simply put: frequency and monetary value affect a customer’s lifetime value, and innovation affects retention, which is a measure of engagement.</p><p>As a result of RFM Analysis:</p><ul><li>With the closeness of the purchase date to the current date, we can measure the customer’s sensitivity to promotions.</li><li>At the same time, we can conclude that the more often the customer buys, the more interested and satisfied they are.</li><li>Monetary value separates heavy spenders from low value buyers</li></ul><p>Now that we have explained the RFM analysis, we can work on the metrics that we will use while performing the RFM analysis.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d44f80e0ac4dfc77a03ef17ed9942f8/href">https://medium.com/media/6d44f80e0ac4dfc77a03ef17ed9942f8/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07e75f3efc05bfde104d1417aa8828e6/href">https://medium.com/media/07e75f3efc05bfde104d1417aa8828e6/href</a></iframe><p>Now we will be performing some manipulations on our dataset. What we will do is to create a data set first and group this data according to <strong>CustomerID</strong>s. We will find the closeness between the most recent shopping record and today by aggregating the records grouped in <strong>CustomerID</strong> with the <strong>aggregation</strong> function. This will be represented as “<strong>Recency</strong>” in our new dataset. Likewise, each unique value in the “<strong>InvoiceNo</strong>” variable will represent the frequency of our respective customer and will be represented by the “<strong>Frequency</strong>” column name in our new dataset. Finally, we will find the size of the expenses incurred by the relevant customer by aggregating according to the “<strong>TotalPrice</strong>” variable that we have created in the above sections. This value is associated with the name of the “<strong>Monetary</strong>” column.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/778c3f99714dba18201eb408b5b4c2b0/href">https://medium.com/media/778c3f99714dba18201eb408b5b4c2b0/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*7OyZ-svuWx_TPN3n-07zOA.png" /><figcaption>New Dataset Looking</figcaption></figure><p>We created our new dataset and looked at its new look. Now we divide our customers into layers or segments as another visual. For this, we create an <strong><em>RFMScore</em></strong> variable by making use of the “<strong>Recency</strong>”,”<strong>Frequency</strong>”,”<strong>Monetary</strong>” variables in the new data set we have just created. We will also examine the volume of our customers that we have segmented into this segment with a visual.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92f204b2b70d649c8deda73eea0f4d92/href">https://medium.com/media/92f204b2b70d649c8deda73eea0f4d92/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FbqmSRf1CYowXSefr9PFQQ.png" /><figcaption>RFM Dataset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*kvCa_lRay0MjzSI5IA1exQ.png" /><figcaption>Segmentation</figcaption></figure><p>We will analyze our data set, which we have separated by segmentation, by grouping the segments within themselves.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/343a2ed4ddbb4f9343c292997588091d/href">https://medium.com/media/343a2ed4ddbb4f9343c292997588091d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KKKdqdFRIK0rGtivAD-Q4w.png" /><figcaption>Segment Analysis -1–</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77e4e677a217759255fe6dae0004effd/href">https://medium.com/media/77e4e677a217759255fe6dae0004effd/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4rUw3SMg9cPZWrzb_eTxw.png" /><figcaption>Segment Analysis</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07679a7a43757635103e9907c8be04ec/href">https://medium.com/media/07679a7a43757635103e9907c8be04ec/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mJUtb6a5LLfoNca0wQy_vQ.png" /><figcaption>Relationship Recency&amp;Frequency by Segments</figcaption></figure><p>In the segmentation study, we use the K-Means Algorithm and the Elbow method to determine the optimum number of clusters. Thus, the value of X with the most breakouts is our optimal number of clusters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfa38fff3b445b705bbc32ab79a62cd6/href">https://medium.com/media/bfa38fff3b445b705bbc32ab79a62cd6/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*AgDpGOKbZVYxWHsNfzQ9tA.png" /><figcaption>Elbow Method</figcaption></figure><blockquote>“Silhouette Score” is one of the most used measurement metrics when we do not have the basic reality. The silhouette coefficient for a data point is (bi−ai)/max(bi,ai). The average distance (ai) between a data point and all other data points in the cluster is the average distance (bi) from all other data points in the cluster closest to that data point. “Davies Bouldin Score” is also used to measure the mean similarity between clusters. Low values are preferred for this ratio and the minimum score value is 0.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f0ba8122a2ce56885b9c09edfe92800/href">https://medium.com/media/6f0ba8122a2ce56885b9c09edfe92800/href</a></iframe><h4>Segment Analysis</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8411b357239893b79565b0b3807d679/href">https://medium.com/media/d8411b357239893b79565b0b3807d679/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4NKZrJQHV54zOnBks93lGA.png" /><figcaption>Segment Analysis</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20ffb8bb7e854ce152600651b548819c/href">https://medium.com/media/20ffb8bb7e854ce152600651b548819c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yeDm3AWm9VCIz1ysJGNqYw.png" /><figcaption>Segment Analysis</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3232bd04cae0af8c797d8796645c6695/href">https://medium.com/media/3232bd04cae0af8c797d8796645c6695/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xLSGGUxpi7p67TY4-PaAQ.png" /><figcaption>K-Means Segment</figcaption></figure><h4>Customer Life Time Value (CLTV) :</h4><p>In the last part of our article, we will focus on the Customer Lifetime Value issue that we mentioned at the beginning. Afterwards, we will calculate the Customer Lifetime Values of our customers, which we have segmented in the RFM Analysis.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80ab8cfea60bd81948a6967fe2847d0b/href">https://medium.com/media/80ab8cfea60bd81948a6967fe2847d0b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*rK1YVKYZCt5XZj-qOkM0YQ.png" /><figcaption>Customer Life Time Value</figcaption></figure><p>Now we will create some new metrics. For example average order value etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7810eb88312844f1790c3f993c235c43/href">https://medium.com/media/7810eb88312844f1790c3f993c235c43/href</a></iframe><h4>BG / NBD:</h4><blockquote>BG/NBD models assume that the number of transactions made by each customer follows a Poisson process with a heterogeneity in transaction rates across customers following a gamma distribution. These assumptions give us a Negative binomial distribution (NBD) for modeling the number of transactions made by the customer while he is alive.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/608d6aeac71d9a85e56a54354e304cdc/href">https://medium.com/media/608d6aeac71d9a85e56a54354e304cdc/href</a></iframe><h4>Top 10 Expected Number of Transaction (1 Week) -&gt;</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/749e01bda6349c65d350c01906a25395/href">https://medium.com/media/749e01bda6349c65d350c01906a25395/href</a></iframe><h4>Top 10 Expected Number of Transaction (1 Month) -&gt;</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2592ee8442db70805331a7db4c22357b/href">https://medium.com/media/2592ee8442db70805331a7db4c22357b/href</a></iframe><h4>Total Expected Number of Transaction (1 Month) -&gt;</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/078f12d036d0ccfb7ede7068b8dc5b7a/href">https://medium.com/media/078f12d036d0ccfb7ede7068b8dc5b7a/href</a></iframe><h4>Frequency of Repeat Transactions -&gt;</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e318e45324f56f320d5ec0e9e93ac7d5/href">https://medium.com/media/e318e45324f56f320d5ec0e9e93ac7d5/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*jnGhMc65spsLb2yggZNi_w.png" /><figcaption>Frequency of Repeat Transactions</figcaption></figure><h4>Gamma — Gamma Submodel :</h4><p>It is a model used in estimating the amount of purchases made per transaction by the future customer.</p><blockquote>The properties of Gamma-Gamma model are:</blockquote><blockquote>Monetary value of users’ transactions is random around their mean transaction value.</blockquote><blockquote>Mean transaction value varies across users but doesn’t vary for an individual user over time.</blockquote><blockquote>Mean transaction values is Gamma distributed across customers.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dd95ce7cd61594e4cca5e3c84008fa5/href">https://medium.com/media/0dd95ce7cd61594e4cca5e3c84008fa5/href</a></iframe><h4>Top 10 Expected Average Profit -&gt;</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78a5e6bd45b313b9683e651578a69d30/href">https://medium.com/media/78a5e6bd45b313b9683e651578a69d30/href</a></iframe><h4>The Final CLTV :</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b39a91b10f018b0a05003acbd699e11/href">https://medium.com/media/5b39a91b10f018b0a05003acbd699e11/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*YnC4WlDUwCl_bFO2fqcHGA.png" /><figcaption>Customer Life Time Values(6 Months)</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6220446658fc1ad206dc1d9a99448297/href">https://medium.com/media/6220446658fc1ad206dc1d9a99448297/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*mSxoMegfH7_3fBkd999hLQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/950c4efef137d71d31c39240e6470093/href">https://medium.com/media/950c4efef137d71d31c39240e6470093/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HAsvFzYIeZkRiHXu_8l0ew.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e286aab5f55ed85dcbf71b9e4b45903/href">https://medium.com/media/8e286aab5f55ed85dcbf71b9e4b45903/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R19evytbchZKMTMywTVtag.png" /><figcaption>Average Of CLV by Segments</figcaption></figure><p>We have come to the end of one of our studies. Stay tuned until we see you in our next case.</p><h3>Source :</h3><ul><li><a href="https://www.kaggle.com/code/sercanyesiloz/crm-analytics">CRM Analytics 🛍️🛒</a></li><li><a href="https://www.kaggle.com/code/nihandincer/customer-relationship-management-crm">Customer Relationship Management (CRM)</a></li><li><a href="https://b4mind.com/marka-yonetimi/musteri-yasam-boyu-degerini-artirmak-icin-musteri-deneyimini-iyilestirmenin-onemi/">Müşteri Yaşam Boyu Değerini Artırmak İçin Müşteri Deneyimini İyileştirmenin Önemi - B4Mind Marka Danışmanlığı ve Dijital Pazarlama Ajansı</a></li><li><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1163fa6e4ae9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>