<?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 Kinanti Nabilah on Medium]]></title>
        <description><![CDATA[Stories by Kinanti Nabilah on Medium]]></description>
        <link>https://medium.com/@kinantinabilah.ichnar?source=rss-3afb7379619------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hGG_6RBq14rJngkZRmjaLw.jpeg</url>
            <title>Stories by Kinanti Nabilah on Medium</title>
            <link>https://medium.com/@kinantinabilah.ichnar?source=rss-3afb7379619------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:10:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kinantinabilah.ichnar/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[People Analytics: Employee Turnover Rate]]></title>
            <link>https://medium.com/@kinantinabilah.ichnar/people-analytics-b4f30ebfe960?source=rss-3afb7379619------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4f30ebfe960</guid>
            <category><![CDATA[people-analytics]]></category>
            <category><![CDATA[data-analyst]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Kinanti Nabilah]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 14:49:01 GMT</pubDate>
            <atom:updated>2023-04-16T14:49:28.711Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*b4XGeIoqgBL_2RFa.jpg" /><figcaption>Source: <a href="https://www.kumospace.com/blog/people-analytics">https://www.kumospace.com/blog/people-analytics</a></figcaption></figure><h3>Introduction</h3><p>People analytics is a data-driven approach to managing people at work. Employee turnover is the measurement of the number of employees who leave an organization over a certain time period. It includes those who exit voluntarily as well who are fired or laid off or involuntary turnover. Turnover is different from attrition. When calculating attrition, force reductions and terminations are not counted.</p><p>Some of the most common reasons for turnover are lack of opportunity for growth or career development, natural career progression, internal promotion or transfer, feeling overworked or burnout, negative feelings towards boss or management. toxic work environment. competitive offer, lack of work-life balance, and involuntary departure. Understanding the cause can help businesses make the necessary changes to maintain their workforce at the desired level.</p><p>Identifying and analyzing employee turnover matters for the business since turnover is expensive and can cost organizations millions every year. Employee turnover impacts organization in multiple ways:</p><ol><li>Financial and Other Resources Losses. To replace departing employess and onboard and train new employees, let alone find suitable replacement with particular skills and experience, companies has to spend money, time, and resources that otherwise could be spent pursuing the organization’s primary goals. Gallup estimates that the cost of replacing an employee is somewhere between one-half and two times the worker’s salary.</li><li>Productivity. It takes time for new employees to reach the same levels of expertise. A dip in productivity can happen while the new employee are trained up to speed.</li><li>Morale. High turnover rate can lead to a shortage of experienced workers which then make it difficult for a company to meet its goals resulting in reduced morale for the team.</li><li>Company image. High turnover rate indicates that something is wrong within the company. With voluntary turnover, it can indicate the rewards are not matching the work involved while with involuntary turnover, it can indicate that the people in charge view their staff as expendable. This can result in a negative impact on the company, potential job candidates, and sometimes the customers.</li></ol><p>Instead of keep replacing employees, the company better analyzes their employees’ underlying reasons to prevent an even higher turnover rate. This can be done by creating a people analytics dashboard that visualize relevant metrics to measure and analyze employees’ turnover.</p><h4>Problem, Goals, and Metrics</h4><p><strong>Problem<br></strong>HR Department receives compains about many employees leaving the company. Lead of people want to decrease turnover rate have data-driven approach of factors determining turnover rate and its relationship with employee performance rate, and Employee Satisfaction Index.</p><p><strong>Goals<br></strong>Providing simple people analytics dashboard of employee turnover to identify and analyze turnover rate and factors determining turnover rate.</p><p><strong>Metrics<br></strong>The factors that needed to be included are:</p><ol><li>Employee turnover rate</li><li>Performance rate</li><li>Employee satisfaction index</li><li>Monthly income</li></ol><p>The turnover rate further needs to be broken down into several conditions which are based on department, job roles, ages, and gender.</p><h4>Dataset</h4><p>The source of the dataset is from Kaggle and can be accesed <a href="https://www.kaggle.com/datasets/rishikeshkonapure/hr-analytics-prediction">https://www.kaggle.com/datasets/rishikeshkonapure/hr-analytics-prediction</a>.</p><h4>Tools</h4><p>In making the dashboard, the tools used are Google Colab (Python) for data pre-processing/data cleaning and Tableau for data processing and creating the dashboard.</p><h4>Metrics</h4><p>In this dasboard, metrics used are employee turnover rate, performace rate, employee satisfaction index, and monthly income.</p><h4>User Flow</h4><p><strong>Business problems and flow</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acV9Lw2rGVZCVRWVVctFdg.png" /></figure><p><strong>Persona</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V7MrQiTR0SrjJ85eXnVbag.png" /></figure><p><strong>Dashboard User Flow</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3OeCjDo64tTDYeSxNirUw.png" /></figure><h4>Data Pre-processing</h4><p>We will use Google Colab/Python for this step. First we import the library and read the data file.</p><pre># Mounting drive<br>from google.colab import drive<br>drive.mount(&#39;/content/drive&#39;)<br><br># Import library<br>import pandas as pd<br><br># Import the data and store into pandas dataframe<br>path = &quot;/content/drive/MyDrive/dataset HR/HR-Employee-Attrition.csv&quot;<br>df = pd.read_csv(path)</pre><p>The dataset contains 35 columns in total. However in this analysis, we only use 12 columns. The columns are selected using the following code:</p><pre># Data selection<br>data = df.loc[:,<br>             [&#39;Age&#39;,<br>              &#39;Attrition&#39;,<br>              &#39;Department&#39;,<br>              &#39;EmployeeNumber&#39;,<br>              &#39;EnvironmentSatisfaction&#39;,<br>              &#39;Gender&#39;,<br>              &#39;JobRole&#39;,<br>              &#39;JobSatisfaction&#39;,<br>              &#39;MonthlyIncome&#39;,<br>              &#39;PerformanceRating&#39;,<br>              &#39;RelationshipSatisfaction&#39;,<br>              &#39;YearsAtCompany&#39;<br>]]</pre><pre># Showing data info<br>data.info()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*DIWQvLybslFruE7FRLUs3g.png" /></figure><p>The columns that will be used are:</p><ul><li><strong>Age</strong>: &lt;int&gt; employee age</li><li><strong>Attrition</strong>: &lt;string&gt; employee attrition status (Yes/No)</li><li><strong>Department</strong>: &lt;string&gt; employee department</li><li><strong>EmployeeNumber</strong>: &lt;int&gt; unique employee number/ID</li><li><strong>EnvironmentSatisfaction</strong>: &lt;int&gt; employee satisfaction rate in work environment (range 1–4)</li><li><strong>Gender</strong>: &lt;string&gt; employee gender</li><li><strong>JobRole</strong>: &lt;int&gt; employee job role</li><li><strong>JobSatisfaction</strong>: &lt;int&gt; employee satisfaction rate in performing their job (range 1–4)</li><li><strong>MonthlyIncome</strong>: &lt;int&gt; employee montly income</li><li><strong>PerformanceRating</strong>: &lt;int&gt; employee performance rated by their manager</li><li><strong>RelationshipSatisfaction</strong>: &lt;int&gt; employee satisfaction rate in the relationship with their coworkers (range 1–4)</li><li><strong>YearsAtCompany</strong>: &lt;int&gt; number of years employee work in the company</li></ul><p>Then, we will check and identify missing valus, duplicated values, and outliers.</p><pre># Checking missing data<br>data.isna().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*NI0yAQVlmD5PLV8RkqU2Ag.png" /><figcaption>Result of checking data missing values</figcaption></figure><pre># Checking duplicated<br>data.duplicated().sum()</pre><pre>Ouput:<br>0</pre><pre># Showing statistical measurement of the data<br>data.describe().T</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*V3Det5IzYzDqIS6LBpMebA.png" /><figcaption>Statistical measurement of the data</figcaption></figure><p>We see the data does not contain any missing values nor duplicated value. From the statistical measurement, since the mean and median of the data are not different by much, we can conclude that the data has normal distribution. Therefore, the data can be processed further.</p><h4>Data Processing</h4><p>This step was done using Tableau. There are several parameters need to be added using “Create calculated field” in Tableau: Total Employee, Active Employee, Turonver Count, Turnover Rate, Employee Satisfaction Index, and Age Group.</p><pre>#Create calculated field<br>#To count turnover rate<br>TotalEmployee = COUNT([EmployeeNumber])<br>ActiveEmployee = IF[Attrition] = &quot;No&quot; THEN 1 ELSE 0 END<br>TurnoverCount = IF[Attrition] = &quot;Yes&quot; THEN 1 ELSE 0 END<br>TurnoverRate = SUM([TurnoverCount]) / [TotalEmployee]<br><br>#To count the employee satisfaction index (percentage)<br>#Since the range is from 1-4, the maximum of total values of 3 indicators will be 12. Therefore, the total value will be divided by 12<br>EmployeeSatisfactionIndex = ([Environment Satisfaction] + [Job Satisfaction] + [Relationship Satisfaction])/12<br><br><br>#To make group of employee age<br>AgeGroup =<br>IF [Age] =&gt; 18 AND [Age] &lt;= 24 THEN &quot;18-24&quot;<br>ELSEIF [Age] &gt;= 25 AND [Age] &lt;= 34 THEN &quot;25 - 34&quot;<br>ELSEIF [Age] &gt;= 35 AND [Age] &lt;= 44 THEN &quot;35 - 44&quot;<br>ELSEIF [Age] &gt;= 45 AND [Age] &lt;= 54 THEN &quot;45 - 54&quot;<br>ELSE &quot;54 and Over&quot; END</pre><h4>Dashboard Description</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*V1heg-BnxqraRdeos-cZFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mS2OJ2WMbuNS_j2HskaT3w.png" /></figure><p>This dashboard contains one table and several charts than can be used to visualize and analyze employee turnover condition. The KPI table contains several metrics such as Active Employee, Turnover Count, Turnover Rate, Performance Rating, Employee Satisfaction Index (ESI), and Average Years at Company. This table enables user to see important metrics in an instant.</p><p>The charts including turnover which breakdown into several different charts: Turnover Rate by Department, Turnover Rate by Job Role, and Turnover Rate by Age Group (which also has subcategory of Gender). We also want to see the comparation between Turnover Rate and Performance Rating and Employee Satisfaction so we put the charts side by side. The other metrics we want to compare is Turnover Rate and Monthly Income (by Job Role). Last, the Employee Satisfaction Index by Indicator, which broken down into three metrics of satisfaction we used to calculate average ESI, allows us to see the details of each Employee Satisfaction indicators which can help us determine which satisfaction indicators we should focus to improve in particular job role to improve the overall ESI.</p><p>The dashboard is also equipped with filter that can be adjusted by the user for detail analysis. There are 4 filters, including:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*-iE-aotT9UM2eaJXuzySCQ.png" /></figure><ul><li>Filters by Gender</li><li>Filters by Age Group</li><li>Filters by Department</li><li>Filters by Job Role</li></ul><p>The usage of this filter will affect the whole dashboard and will ease the user to make a detailed analysis.</p><h4>Business Insights</h4><p>Insights that can be gained from the dashboard are the following:</p><ol><li><strong>Summary Table</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BDGIhDX40ARu1o9SnshRg.png" /></figure><p>Number of active employee is 1233 employees and 237 employees who resigned from the company resulting in 16.12% in turnover rate. The baseline of turnover rate differs across industry. While organizations should aim for 10% for an employee turnover rate, but most fall into the range of 12% to 20%. We can conclude our turnover rate value still lies in an healthy boundary.</p><p>The average performance rating is 3 while the range is from 1–4. It indicates in average, employee performance is fairly good. Employee satisfaction index is 68.02% in average indicates that employee satisfaction rate is quite good but definitely could be improved. Average years at company is 7 years also a good indication because employee, in average, works for the company for quite long time.</p><p><strong>2. Turnover Rate</strong></p><p>a. Turnover Rate by Department</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*vnnCDUF-iDBjUFCU8IbSOw.png" /></figure><p>From the chart above, we can see Sales Department has the highest turnover rate and the Research &amp; Development has the lowest turnover rate. Yet, both Sales and Human Resources departments’ turnover exceeding the average Turnover Rate.</p><p>b. Turnover Rate by Job Role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*n5yUaMczURBUIIJh0jEhbA.png" /></figure><p>From the chart above, Sales Representative has the highest Turnover Rate followed by Laboratory Technician and Human Resources.</p><p>c. Turnover Rate by Age Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*yh-8gQP31rGUpbvz_tye_Q.png" /></figure><p>From the chart above, the age group 18–24 years old has the highest turnover rate followed by 25–34 years old group and 54 and Over group. This chart also allows us to see the comparison turnover rate across gender. In the group that has the highest turnover (18–24 Group), we see that female employee has higher turnover rate (48.65% from the total of female employee) compared with male employee (33.33% from the total of male employee).</p><p><strong>3. Performance Rating</strong></p><p>Performance rate can be influenced by lack of knowledge/skill sets. In order to improve it, company can conduct training programs.</p><p>a. Performance Rating by Department</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*ggPfs56WqjpvHbeEqnI6xA.png" /></figure><p>The average performance rate among departments and between gender has similar value. From this we can conclude the performance across department and gender is quite similar and that in average, employees do their jobs well. Comparing to the turnover rate, this chart give us an interesting insight which despite the employee’s good performance, the turnover rate could still be differ across department. It indicates employee can still do the job well while considering to resign from the company.</p><p>b. Performance Rating by Job Role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*El_olvUbE0DMsLUUJq5WIA.png" /></figure><p>Manager has the highest performance rating followed by Manufacturing Director then Research Scientist. Although they are ranked, the difference between the highest perfomer job role and the lowest rank is not that wide, which only has 0.10 point difference.</p><p><strong>4. Employee Satisfaction Index</strong></p><p>Employee Satisfaction Index (ESI) is the value filled by employee on one’s own. The range is between 1–4, where the higher the value, the more satisfied an employee. There are 3 aspects/indicators: Environment Satisfaction, Job Satisfaction, and Relationship Satisfaction. ESI is obtained by aggregating the three prior indicators and showing it as percentage.</p><p>a. ESI by Department</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*Bl1-s8X4sTUpcH6KKoMANQ.png" /></figure><p>From the chart above, Human Resources has the highest ESI followed by Research &amp; Development and Sales.</p><p>b. ESI by Job Role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*AIaqFejLRkoKep6JdU_zdw.png" /></figure><p>Meanwhile, if we compare across job role, Manufacturing Director has the highest satisfaction index, followed by Manager, and Healthcare Representative.</p><p>c. ESI by Indicators</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*hJ3Wf-31BfJOR_e8ECSj6g.png" /></figure><p>This chart allows us to see the detail of each satisfaction indicators. Suppose we want to improve ESI on a certain job role which is Human Resources. Compared to average line of satisfaction, the Environment Satisfaction, and Job Satisfaction, the value are fall below the average line, while the Relationship Status is already exceeds above average line. By analyzing this component, we can turn our focus to improve the Environment Satisfaction and Job Satisfaction of the HR employee to improve the overall ESI.</p><p><strong>5. Monthly Income by Job Role</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*YlI1gkB-IjJNSJgRuOSe_w.png" /></figure><p>In average, Manager role has the highest monthly income followed by Research Director and Healthcare Representative. Whereas monthly income comparison between gender does not differ much although there is slight difference between male and female employee for the same job role. In this case, HR needs to ensure that the difference in income is truly based on their qualifications and not because of their gender.</p><p><strong>6. Relationship between Turnover Rate, Performance Rate, Employee Satisfaction, and Monthly Income</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*n5yUaMczURBUIIJh0jEhbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*El_olvUbE0DMsLUUJq5WIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*SMgDghMcFlHTWe_hCHMfDQ.png" /></figure><p>From the charts above, we can see Manufacturing Director, Manager and Healthcare Representative, which has the highest ESI among other job role and has higher Performance Rate too (among the top 5), has lowest Turnover Rate (Top 4). While if we see Sales Representative, Laboratory Technician, and Human Resources which has the highest turnover rate has rather lower ESI even though their Performance Rate are considered good. We can conclude that ESI has correlation with Turnover Rate, the highest ESI, the lower the possibility of an employee to turnover, and it also works the other way. That is why it is important to address and identify also make a strategy to improve the ESI so that the turnover rate can be lowered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*YlI1gkB-IjJNSJgRuOSe_w.png" /></figure><p>Next, we want to compare the Monthly Income with ESI, Performance Rating, and Turnover Rate. We see the Manager, Research Director and Healthcare Representative have the highest Monthly Income among other job role. This has positive correlation with high ESI, high Performance Rate, and low Turnover Rate. On the other side, we see that Sales Representative Laboratory Technician has the lowest monthly income. This has positive correlation with low ESI, average performance rate, and high turnover rate. There is indication if an employee is satisfied with their job, work environment, and has good relationship with their coworkers, they tend to perform better and this could lead to promotion and even higher monthly income which drives them to perform even better resulting in more satisfaction and decreasing turnover rate. Even though, it is important to note that increment in monthly income is not the definite cause of lowering turnover, HR might want to consider whether the employee has been fairly compensated for their work.</p><p>Other things that is important to note that the data use average value. Suppose a certain job role has good average value of satisfaction, although this value could be a representation of general condition, there is possibility that there are extreme values where several employees feeling extremely dissatisfied and several employees feeling extremely satisfied. Therefore, other than considering fairly compensation for each job role, HR might want to consider to analyze whether there are inequality in salary paid to the employees whereas if there is inequality, this could in turn cause the employee to turnover.</p><p><strong>7. Data Filters</strong></p><p>Data filters enables us to filter the data based on our needs of the group we want to analyze. Suppose we want to see the group of age between 18–24 from Sales and Human Resources Department only, we can use the filter, and the data will be automatically adjusted.</p><h4>Conclusions</h4><ol><li>Number of active employee is 1233 employees and 237 employees who resigned from the company resulting in 16.12% in turnover rate. While organizations should aim for 10% for an employee turnover rate, but most fall into the range of 12% to 20%. We can conclude our turnover rate value still lies in an healthy boundary. The average performance rating is 3 while the range is from 1–4. It indicates in average, employee performance is fairly good. Employee satisfaction index is 68.02% in average indicates that employee satisfaction rate is quite good but definitely could be improved. Average years at company is 7 years also a good indication because employee, in average, works for the company for quite long time.</li><li>Sales Department has the highest turnover rate and the Research &amp; Development has the lowest turnover rate.</li><li>Manufacturing Director has the highest satisfaction index, followed by Manager, and Healthcare Representative.</li><li>Sales Department has the highest turnover rate and the Research &amp; Development has the lowest turnover rate.</li><li>Sales Representative has the highest Turnover Rate followed by Laboratory Technician and Human Resources.</li><li>The average performance rate among departments and between gender has similar value.</li><li>Manager has the highest performance rating followed by Manufacturing Director then Research Scientist. Although they are ranked, the difference between the highest perfomer job role and the lowest rank is not that wide, which only has 0.10 point difference.</li><li>Human Resources has the highest ESI followed by Research &amp; Development and Sales.</li><li>Manufacturing Director has the highest satisfaction index, followed by Manager, and Healthcare Representative.</li><li>In average, Manager role has the highest monthly income followed by Research Director and Healthcare Representative. Whereas monthly income comparison between gender does not differ much although there is slight difference between male and female employee for the same job role.</li><li>There is indication if an employee is satisfied with their job, work environment, and has good relationship with their coworkers, they tend to perform better and this could lead to promotion and even higher monthly income which drives them to perform even better resulting in more satisfaction and decreasing turnover rate.</li></ol><h4>Recommendations</h4><ol><li>Conduct surveys or interviews to deepen the understanding the cause of employee satisfaction or dissatisfaction.</li><li>Adjust ESI by their indicators based on the particular departments:<br>a. Environment satisfaction: evaluate the facility given to employees and build a culture of well-being and support<br>b. Job satisfaction: ensure the job description is suitable and does not overburden particular employee, and facilitate trainings to improve performance which resulting in improved job satisfaction<br>c. Relationship satisfaction: Strengthening the relationship by mentoring or employee bonding or by encouraging feedbacks</li></ol><p>3. Evaluate monthly income so that the employees are fairly compensated and ensure there is no salary inequality within the same job role and job level.</p><h4>Further Study</h4><p>In this dashboard, we only see the correlation based on rough numbers (average). Further study could be conducted using correlation analysis to identify the correlation of turnover rate and the probable indicators.</p><h4>References</h4><ul><li>PACMANN Academy. (2023). <em>People Analytics.</em> Jakarta</li></ul><ul><li><a href="https://www.bamboohr.com/resources/hr-glossary/employee-turnover">What is Employee Turnover? | BambooHR</a></li><li><a href="https://www.netsuite.com/portal/resource/articles/human-resources/employee-turnover.shtml">The What &amp; Why to Employee Turnover</a></li><li><a href="https://www.netsuite.com/portal/resource/articles/human-resources/employee-turnover-kpis-metrics.shtml">12 Employee Turnover and Retention KPIs to Measure in 2021</a></li></ul><p><a href="https://yoursapp.com/business/blog/employee-turnover/#:~:text=Employee%20turnover%20is%20one%20of,an%20employee%20from%20the%20team">https://yoursapp.com/business/blog/employee-turnover/#:~:text=Employee%20turnover%20is%20one%20of,an%20employee%20from%20the%20team</a>.</p><p><a href="https://www.business.com/articles/employee-turnover-rate/#:~:text=Organizations%20should%20aim%20for%2010,the%20nature%20of%20the%20job">https://www.business.com/articles/employee-turnover-rate/#:~:text=Organizations%20should%20aim%20for%2010,the%20nature%20of%20the%20job</a>.</p><p>This analytic dashboard can be accessed <a href="https://public.tableau.com/app/profile/kinan6437/viz/PeopleAnalyticsDashboardEmployeeTurnover/Dashboard12?publish=yes">here.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4f30ebfe960" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistical Analysis: BMI Level Regression]]></title>
            <link>https://medium.com/@kinantinabilah.ichnar/statistical-analysis-bmi-level-regression-6bb97147605a?source=rss-3afb7379619------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bb97147605a</guid>
            <dc:creator><![CDATA[Kinanti Nabilah]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 03:28:35 GMT</pubDate>
            <atom:updated>2023-04-16T16:51:45.032Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*LtKzBmVDiqSTAYUu" /></figure><h4>Introduction and Background</h4><p>Body mass index (BMI) is used to determine the body mass index by the body mass quotient expressed in kilograms (kg) by the square of body height expressed in square meters (m2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/0*QYfjePtEFJuS2puQ.png" /></figure><p>Body mass index is the most popular determinant of health to determine different aspects of its impact on physical, psychological, and social aspects of life. Body mass index is widely used to estimate the risk of underweight and obesity of examined person for the development of or the prevalence of several health issuses as it may be associated with the development of diseases classified as civilization diseases, such as diabetes, stroke, atherosclerosis, hypertension and nutrition disorders. The World Health Organization (WHO) has identified six ranges defining the state of the subject.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/0*eKWM3qrQT4CeMEa-.png" /></figure><p>Collectively, BMI study in the overall population can help measuring the rates of obesity in a population. As BMI is widely used by many healthcare providers and commonly works for most people, having changes in BMI levels provides an understanding of the ways overweight and obesity differ over time and in between distinct populations. This BMI information can also be a such an valuable information for health researchers to study the obesity epidemic and also policy maker to determine public health policies.</p><p>This analytical study focus on determining which predictor variablesthat significantly influence the BMI level and how much significant the predictor’s value to the BMI by conducting statistical analysis including performing statistical test and regression analysis from the given dataset.</p><p><strong>Objective Analysis</strong></p><ul><li>Which predictor variables on data that significantly influence the the level of someone’s BMI?</li><li>How is the correlation between predictor variables and the level of BMI?</li><li>How is the BMI level can be predicted and be modeled using regression model based on its predictor variables?</li></ul><h4>Dataset</h4><p>The dataset used in this study is from Kaggle titled ‘Obesity based on eating habits &amp; physical conditions’ which can be accessed here: <a href="https://www.kaggle.com/datasets/ankurbajaj9/obesity-levels">https://www.kaggle.com/datasets/ankurbajaj9/obesity-levels</a>.</p><p>This dataset contains the data of BMI level in individuals from Colombia, Peru, and Mexico. This dataset is resulted from a research to predict obesity level in indivisuals based on food intake habit and their physical conditions. This dataset contains several columns:</p><ol><li><strong>Gender</strong>: &lt;string&gt; gender of the individual</li><li><strong>Age</strong>: &lt;float&gt; age of the individual</li><li><strong>Height</strong>: &lt;float&gt; body height of the individual</li><li><strong>Weight</strong>: &lt;float&gt; body weight of the individual</li><li><strong>family_history_with_overweight</strong>: &lt;string&gt; whether there is history of other family members being overweight (Yes/No)</li><li><strong>FAVC (Frequent consumption of high caloric foods)</strong>: &lt;string&gt; whether the individual frequently consume high caloric foods (Yes/No)</li><li><strong>FCVC (Frequency of consumption of vegetables)</strong>: &lt;float&gt; the frequency of individual consume vegetables</li><li><strong>NCP (Number of main meals)</strong>: &lt;float&gt; number of main meals the individual takes in a day</li><li><strong>CAEC (Consumption of food between meals)</strong>: &lt;string&gt; how frequent the individual consume foods between meals</li><li><strong>SMOKE (Smoking habit)</strong>: &lt;string&gt; whether the individuals have smoking habit (Yes/No)</li><li><strong>CH2O (Consumption of water daily)</strong>: &lt;float&gt; how frequent the individual consume water in a day</li><li><strong>SCC (Calories consumption monitoring)</strong>: &lt;string&gt; whether the individual monitor their calories consumption (Yes/No)</li><li><strong>FAF (Physical activity frequency)</strong>: &lt;float&gt; how frequent the individuals do physical activities during the day</li><li><strong>TUE (Time using technology devices)</strong>: &lt;float&gt; how frequent the individuals use technology devices daily</li><li><strong>CALC (Consumption of alcohol)</strong>: &lt;string&gt; whether the individuals consume alcohol (Yes/No)</li><li><strong>MTRANS (Transportation used)</strong>: &lt;string&gt; means of transportation that the individual takes daily</li><li><strong>NObeyesdad (Number of Obesity Diseases)</strong>: &lt;string&gt; level of obesity by WHO</li></ol><h4><strong>Data Preprocessing</strong></h4><p>We use python (google colab) for preprocessing the data.</p><pre><br>#Import modules<br>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>import warnings<br>warnings.simplefilter(&#39;ignore&#39;)<br><br>#Import the module for the linear regression model<br>import statsmodels.formula.api as smf<br>from statsmodels.formula.api import ols<br>import statsmodels.api as sm<br>import scipy.stats as stats<br><br>pd.set_option(&#39;display.max_columns&#39;, None)<br>plt.style.use(&#39;bmh&#39;)<br>sns.set()</pre><pre>#Import data files from drive<br>from google.colab import drive<br>drive.mount(&#39;/content/drive&#39;)<br><br>#Import and read data<br>path = &quot;/content/drive/MyDrive/dataset obesity/ObesityDataSet_raw_and_data_sinthetic.csv&quot;<br>df = pd.read_csv(path)</pre><pre>#Display the data information<br>df.info()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*W3fgQtRAfKF1QD_gg_BYpA.png" /></figure><pre>#Overview the data<br>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-6PgK1cyuwx70ebRGqfNnQ.png" /></figure><p>In this analysis, we are interested in particular variables which are gender, age, family history with overweight, FAVC, Smoke, FAF, TUE, MTRANS, and Nobeyesdad so we selected these columns for our further study.</p><pre>#Feature selection<br>df = df.loc[:,[<br>            &quot;Gender&quot;,<br>            &quot;Age&quot;,<br>            &quot;family_history_with_overweight&quot;,<br>            &quot;FAVC&quot;,<br>            &quot;SMOKE&quot;,<br>            &quot;FAF&quot;,<br>            &quot;TUE&quot;,<br>            &quot;MTRANS&quot;,<br>            &quot;NObeyesdad&quot;<br>            ]]<br>df.head()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*MAcruY9WosEl4uZND_6yCg.png" /></figure><p>The name of the columns used abbreviations and different formats so it needed to be renamed for better recalling and uniformity.</p><pre>#Renaming the columns for better recalling<br>df = df.rename(columns={&quot;Gender&quot; : &quot;gender&quot;,<br>                          &quot;Age&quot; : &quot;age&quot;,<br>                          &quot;NObeyesdad&quot;: &quot;BMI&quot;, <br>                          &quot;family_history_with_overweight&quot;: &quot;overweight_family&quot;,<br>                          &quot;FAVC&quot; : &quot;high_caloric&quot;,<br>                          &quot;SMOKE&quot; :&quot;smoke&quot;,<br>                          &quot;FAF&quot; : &quot;physical_activity&quot;,<br>                          &quot;TUE&quot; : &quot;device_time&quot;,<br>                          &quot;MTRANS&quot; : &quot;transportation&quot;<br>                          })<br>df.head()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*uXNG8NRoTNzJRXEp-TaA2g.png" /></figure><pre>#Create function to check unique data<br>def CheckUnique():<br>   print(&#39;gender : &#39;, df[&#39;gender&#39;].unique())<br>   print(&#39;age : &#39;, df[&#39;age&#39;].unique())<br>   print(&#39;overweight_family :&#39;, df[&#39;overweight_family&#39;].unique()) <br>   print(&#39;high_caloric :  &#39;, df[&#39;high_caloric&#39;].unique())<br>   print(&#39;smoke :&#39;, df[&#39;smoke&#39;].unique())<br>   print(&#39;physical_activity :&#39;, df[&#39;physical_activity&#39;].unique())<br>   print(&#39;device_time :&#39;, df[&#39;device_time&#39;].unique())<br>   print(&#39;transportation :&#39;, df[&#39;transportation&#39;].unique())<br>   print(&#39;BMI :&#39;, df[&#39;BMI&#39;].unique())</pre><pre># Calling the CheckUnique function<br>CheckUnique()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*SfUzDOcGp05I5GXfmgtM9A.png" /></figure><p><strong>Checking missing values and Duplicates</strong></p><pre>#Checking missing values<br><br>print(&quot;Number of missing values:&quot;)<br>df.isna().sum()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*N9WgTRp7swG3kfpvky5Oqg.png" /></figure><pre>#Checking duplicates<br>df.duplicated().sum()</pre><p>Output: 80</p><pre># Remove duplicates<br>df.drop_duplicates(inplace = True)<br>df.duplicated().sum()</pre><p>Ouput: 0</p><pre>#Changing categorical data from string to numerical category<br>df_BMI = {&quot;Insufficient_Weight&quot;: 0,<br>          &quot;Normal_Weight&quot;: 1,<br>          &quot;Overweight_Level_I&quot;: 2,<br>          &quot;Overweight_Level_II&quot;: 3,<br>          &quot;Obesity_Type_I&quot;: 4,<br>          &quot;Obesity_Type_II&quot;: 5,<br>          &quot;Obesity_Type_III&quot;: 6}<br><br>df_overweight_family = {&quot;yes&quot; : 1,<br>                        &quot;no&quot; : 0}<br><br>df_high_caloric  = {&quot;yes&quot; : 1,<br>                    &quot;no&quot; : 0}<br><br>df_smoke = {&quot;yes&quot; : 1,<br>            &quot;no&quot; : 0}</pre><pre>df[&#39;BMI&#39;] = df[&#39;BMI&#39;].replace(df_BMI)<br>df[&#39;overweight_family&#39;] = df[&#39;overweight_family&#39;].replace(df_overweight_family)<br>df[&#39;high_caloric&#39;] = df[&#39;high_caloric&#39;].replace(df_high_caloric)<br>df[&#39;smoke&#39;] = df[&#39;smoke&#39;].replace(df_smoke)<br><br>df.head()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*H1TZCuXBtQ4KZMxX2RVD6g.png" /></figure><pre>#Reviewing the data info<br>df.info()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*lZKYlPjrSWcnDHCmgQduMg.png" /></figure><pre># Displaying data distributions<br>columns_ = [&quot;gender&quot;, &quot;age&quot;, &quot;overweight_family&quot;, &quot;high_caloric&quot;, &quot;smoke&quot;, &quot;physical_activity&quot;, &quot;device_time&quot;, &quot;BMI&quot;]<br>index_ = 0<br>fig, ax = plt.subplots(2,4, figsize = (21,10))<br>for row in range(2):<br>    for col in range(4):<br>        ax[row,col].hist(df[columns_[index_]])<br>        ax[row,col].set_title(f&quot;{columns_[index_]} distribution&quot;)<br>        index_ += 1<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ozynNl6tPt20du6cNKAApQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ChEpOWQCZ01ur22xgcI9Rg.png" /></figure><h4>Exploratory Data Analysis</h4><ol><li><strong>BMI Level based on Gender</strong></li></ol><pre># Code used to see distribution of BMI level based on gender category using boxplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>my_palette = {&#39;Male&#39;: &#39;#5F9EA0&#39;, &quot;Female&quot; : &#39;#CD5555&#39;}<br>sns.boxplot(x = &quot;BMI&quot;, y = &quot;gender&quot;, data = df, ax = ax, palette = my_palette)<br>ax.set_title(&quot;BMI Level based on Gender&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*YvW8QyQFJbdIYZH326zVPQ.png" /></figure><pre>#Code used to see means from BMI level based on gender category using point plot<br>fig, ax = plt.subplots(figsize = (8,5))<br>sns.pointplot(y = &quot;BMI&quot;, x = &quot;gender&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI Level based on Gender&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*ZxdHaMuDV0mXTTvcibXSSA.png" /></figure><p>Based on box plot and point plot, we can see there is difference of BMI level means based on gender that female is more likely to have higher BMI level than male. This condition is applicable to the samples we collected. To make inference to the population, we have to perform statistical test of T-test for the difference between two population means.</p><p><strong>2. BMI Level based on Family History of Overweight</strong></p><pre># Code used to see distribution of BMI level based on family history of overweight category using boxplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>my_palette1 = sns.color_palette(&quot;deep&quot;, n_colors=3)[::-1]<br>sns.boxplot(x = &quot;overweight_family&quot;, y = &quot;BMI&quot;, data = df, ax = ax, palette = my_palette1)<br>ax.set_title(&quot;BMI Level based on Family History of Overweight&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*GCsu6eMgskY0tB27BVlnow.png" /></figure><pre># Code used to see distribution of BMI level based on family history of overweight category using point plot<br>fig, ax = plt.subplots(figsize = (8,5))<br>sns.pointplot(y = &quot;BMI&quot;, x = &quot;overweight_family&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI Level based on Family History of Overweight&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*1HQGNgwWIf_zcvL-sGMq6w.png" /></figure><p>Based on box plot and point plot, we can see there is difference of BMI level means based on family history of overweight that someone who has family member who is overweight is more likely to have higher BMI level than someone who has no family member who is overweight. This condition is applicable to the samples we collected. To make inference to the population, we have to perform statistical test of T-test for the difference between two population means.</p><p><strong>3. BMI Level based on Frequent Consumption of High Caloric Foods</strong></p><pre># Code used to see distribution of BMI level based on Frequent Consumption of High Caloric Foods category using boxplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>my_palette1 = sns.color_palette(&quot;deep&quot;, n_colors=3)[::-1]<br>sns.boxplot(x = &quot;high_caloric&quot;, y = &quot;BMI&quot;, data = df, ax = ax, palette = my_palette1)<br>ax.set_title(&quot;BMI Level based on Frequent Consumption of High Caloric Foods&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*VLWYpNkDhJKEOCBAxF2gkQ.png" /></figure><pre># Code used to see distribution of BMI level based on Frequent Consumption of High Caloric Foods category using boxplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>sns.pointplot(y = &quot;BMI&quot;, x = &quot;high_caloric&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI Level based on Frequent Consumption of High Caloric Foods&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*DUmlWqdDK5RSIHV3l60F6g.png" /></figure><p>Based on box plot and point plot, we can see there is difference of BMI level means based on frequent consumption of high caloric foods. This means someone who frequently consume high caloric foods is more likely to have higher BMI level than someone who does not. This condition is applicable to the samples we collected. To make inference to the population, we have to perform statistical test of T-test for the difference between two population means.</p><p>4. BMI Level based on Smoking Status</p><pre># Code used to see distribution of BMI level based on Smoking Status using boxplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>my_palette1 = sns.color_palette(&quot;deep&quot;, n_colors=3)[::-1]<br>sns.boxplot(x = &quot;smoke&quot;, y = &quot;BMI&quot;, data = df, ax = ax, palette = my_palette1)<br>ax.set_title(&quot;BMI Level based on Smoking Status&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*aKPMzPqhtXQeCyMIfpthVQ.png" /></figure><pre># Code used to see distribution of BMI level based on Smoking Status using lineplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>sns.pointplot(y = &quot;BMI&quot;, x = &quot;smoke&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI Level based on Smoking Status&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*tQgWN9X6IiPkqhPpQfTVLw.png" /></figure><p>Based on box plot and point plot, we can see there is slight difference of BMI level means based on frequent consumption of high caloric foods. This means someone who does not smoke is more likely to have higher BMI level than someone smoke. However, we can see the difference is quite smalll. To see whether the difference is significant in the population and to make inference, we have to perform statistical test of T-test for the difference between two population means.</p><p><strong>5. BMI Level based on Means of Transportations</strong></p><pre># Code used to see distribution of BMI level based on Smoking Status using boxplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>sns.boxplot(x = &quot;BMI&quot;, y = &quot;transportation&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI Level based on Means of Transportation&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*Khl-RztIPPKOoAmbVBS_MA.png" /></figure><pre># Code used to see distribution of BMI level based on Smoking Status using pointplot<br>fig, ax = plt.subplots(figsize = (8,5))<br>sns.pointplot(y = &quot;BMI&quot;, x = &quot;transportation&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI Level based on Means of Transportation&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*3w31NgfVDyM2NqbWL85SCg.png" /></figure><p>Based on box plot and point plot, we can see there is differences of BMI level means among means of transportations taken by observee. Public Transportation has highest mean level of BMI meaning that someone who takes public transportation daily or more frequently is more likely to have higher BMI level among others. Meanwhile, someone who rides bike more frequently is less likely to have higher BMI and even most likely to have normal BMI leve. To see whether the differences based on means of transportation is significant in the population and to make inference, we have to perform statistical test of ANOVA.</p><p><strong>Interaction</strong></p><p><strong>1. Interaction between Gender and Frequent Consumption of High Caloric Foods</strong></p><pre># Code used to see distribution of BMI level based on Gender and Frequent Consumption of High Caloric Foods using boxplot<br>fig, ax = plt.subplots(figsize = (9,7))<br>my_palette = {&#39;Male&#39;: &#39;#5F9EA0&#39;, &quot;Female&quot; : &#39;#CD5555&#39;}<br>sns.boxplot(y = &quot;BMI&quot;, x = &quot;high_caloric&quot;, hue = &#39;gender&#39;, data = df, ax = ax, palette = my_palette)<br>ax.set_title(&quot;BMI level based on Gender and Frequent Consumption of High Caloric Foods&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*po7ouyx7fyWI0FJ_J21dPg.png" /></figure><p>Based on the boxplot we can see how interaction of gender and frequent consumption influence the BMI level. A female who frequently consume high caloric foods is more likely to have similar BMI level with male who also frequently consume high caloric foods and both of them will more likely to have higher BMI level compared to female or male who is not frequently consume high caloric foods. However, this family history of overweight affects female more greatly where the difference means of BMI level is higher (1 vs 4) compared to male (2 vs 4) meaning female are more prone to have higher BMI level if they frequently consume high caloric foods.</p><p><strong>2. Interaction between Gender and Family History of Overweight</strong></p><pre># Code used to see distribution of BMI level based on Gender and Family History of Overweight using boxplot<br>fig, ax = plt.subplots(figsize = (9,7))<br>my_palette = {&#39;Male&#39;: &#39;#5F9EA0&#39;, &quot;Female&quot; : &#39;#CD5555&#39;}<br>sns.boxplot(y = &quot;BMI&quot;, x = &quot;overweight_family&quot;, hue = &#39;gender&#39;, data = df, ax = ax, palette = my_palette)<br>ax.set_title(&quot;BMI level based on Gender and Family History of Overweight&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*XeTRzbTOTWYRFNogdknn4g.png" /></figure><p>Based on the boxplot we can see how interaction of gender and family history of overweight influence the BMI level. A female who has family member who overweight is more likely to have similar BMI level with male who also has family member who overweight and both of them will more likely to have higher BMI level compared to female or male who has no family members who is overweight. However, this family history of overweight affects female more greatly where the difference means of BMI level is higher (1 vs 4) compared to male (2 vs 4) meaning female are more prone to have higher BMI level if they have family history of overweight.</p><p><strong>3. Interaction between Frequent Consumption of High Caloric Foods and Family History of Overweight</strong></p><pre># Code used to see distribution of BMI level based on Frequent Consumption of High Caloric Foods and Family History of Overweight using boxplot<br>fig, ax = plt.subplots(figsize = (9,7))<br>sns.boxplot(y = &quot;BMI&quot;, x =&#39;overweight_family&#39;, hue = &quot;high_caloric&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI level based on Frequent Consumption of High Caloric Foods and Family History of Overweight&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*p_0my3c-HZm-U7ZWq5dDXw.png" /></figure><pre># Code used to see distribution of BMI level based on Frequent Consumption of High Caloric Foods and Family History of Overweight using boxplot<br>fig, ax = plt.subplots(figsize = (9,7))<br>sns.pointplot(x = &quot;overweight_family&quot;, y =&#39;BMI&#39;, hue = &quot;high_caloric&quot;, data = df, ax = ax)<br>ax.set_title(&quot;BMI level based on Frequent Consumption of High Caloric Foods and Family History of Overweight&quot;)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*Qvb6VVxFQO8RapvxQhsUnQ.png" /></figure><p>Based on the boxplot and lineplot above, we can see how interaction of family history of overweight and frequent consumption of high caloric foods influence the BMI level. Someone who is more frequently consume high caloric foods and has family history of overweight is more likely to have higher BMI compared to someone who also has family history of overweight but is not frequently consume high caloric food. Even so, this family history of overweight factor greatly affects the BMI level. Whether someone is frequently consume high caloric food or not, if they have family history of overweight, they are more likely to have higher BMI level.</p><h4>Statistical Test</h4><pre># Import module<br>from scipy.stats import ttest_ind,levene,kruskal<br>import statsmodels.api as sm<br>from statsmodels.formula.api import ols<br>from statsmodels.stats.multicomp import pairwise_tukeyhsd<br>from statsmodels.stats.diagnostic import normal_ad</pre><p><strong>1. T-test for the difference between two population means: Gender Category</strong></p><p>First of all, stating Null hypothesis (H0), alternative hypothesis (H1), and significance level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*Ys9tPzGiZjHSBoa7nA5c1A.png" /></figure><pre>#Determining whether the data has equal or unequal variances<br><br>#Accessing column BMI data based on condition in gender column then save it as male variable<br>male = df.loc[df[&quot;gender&quot;] == &quot;Male&quot;][[&quot;BMI&quot;]].values<br>female = df.loc[df[&quot;gender&quot;] == &quot;Female&quot;][[&quot;BMI&quot;]].values<br><br>#Calculating the ratio of variance<br>#If the ratio is less than 4, they considered as equal<br>ratio = np.var(male)/np.var(female)<br>ratio</pre><p>Output: 0.5478543062728571</p><p>Since the ratio of variances is less than 4, they are considered equal. Next, we can proceed with Student T-Test.</p><pre>#Performing T-Test<br>result = ttest_ind(female, male, equal_var = True, random_state = 42, alternative= &#39;greater&#39;) # melakukan Uji t.<br><br><br>print(&quot;Statistical Analysis Result&quot;)<br>print(&#39;-&#39;*50)<br>print(f&#39;Statistic value = {result.statistic}&#39;)<br>print(f&#39;P value = {result.pvalue}&#39;)<br>print(&#39;-&#39;*50)<br><br>#Determining rule of decision<br>print(&#39;Conclusion:&#39;)<br>if result.pvalue &lt; 0.05:<br>    print(&quot;Reject the null hypothesis&quot;)<br>else:<br>    print(&quot;Failed to reject the Null hypothesis&quot;)</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*FVABv6SbAbGv0Kn-s8gofA.png" /></figure><p>Based on statistical test, p-value is &gt; 0.05 meaning there is no sufficient evidence that there is significant difference of BMI level means between female and male. Therefore, we failed to reject the null hypothesis.</p><p><strong>2. T-test for the difference between two population means: Smoking Status</strong></p><p>First of all, stating Null hypothesis (H0), alternative hypothesis (H1), and significance level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*Rk9TI2CNBJxADSQRiqdENQ.png" /></figure><pre>#Determining whether the data has equal or unequal variances<br><br>#Accessing column BMI data based on condition in gender column then save it as male variable<br>smoker= df.loc[df[&quot;smoke&quot;] == 1][[&quot;BMI&quot;]].values<br>nonsmoker = df.loc[df[&quot;smoke&quot;] == 0][[&quot;BMI&quot;]].values<br><br>#Calculating the ratio of variance<br>#If the ratio is less than 4, they considered as equal<br>ratio = np.var(smoker)/np.var(nonsmoker)<br>ratio</pre><p>Output: 0.7922853329530194</p><p>Since the ratio of variances is less than 4, they are considered equal. Next, we can proceed with Student T-Test.</p><pre>#Performing T-Test<br>result = ttest_ind(smoker, nonsmoker, equal_var = True, random_state = 42, alternative= &#39;two-sided&#39;)<br>print(&quot;Statistical Analysis Result&quot;)<br>print(&#39;-&#39;*50)<br>print(f&#39;Statistic value = {result.statistic}&#39;)<br>print(f&#39;P value = {result.pvalue}&#39;)<br>print(&#39;-&#39;*50)<br>#Determining rule of decision<br>print(&#39;Conclusion:&#39;)<br>if result.pvalue &lt; 0.05:<br>print(&quot;Reject the null hypothesis&quot;)<br>else:<br>print(&quot;Failed to reject the Null hypothesis&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*tA4Pj7hQcmSS-XjbYVVHIA.png" /></figure><p>Based on statistical test, p-value is &gt; 0.05 meaning there is no sufficient evidence that there is significant difference of BMI level means between smoker and nonsmoker. Therefore, we failed to reject the null hypothesis.</p><p><strong>3. T-test for the difference between two population means: Frequent Consumption of High Caloric Foods</strong></p><p>First of all, stating Null hypothesis (H0), alternative hypothesis (H1), and significance level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*WWWSdL6Yd4ZjJx4eNuh2WQ.png" /></figure><pre>#Determining whether the data has equal or unequal variances<br><br>#Accessing column BMI data based on condition in gender column then save it as male variable<br>high_cal = df[df[&quot;high_caloric&quot;] == 1][[&quot;BMI&quot;]].values<br>low_cal = df[df[&quot;high_caloric&quot;] == 0][[&quot;BMI&quot;]].values<br><br>#Calculating the ratio of variance<br>#If the ratio is less than 4, they considered as equal<br>ratio = np.var(high_cal)/np.var(low_cal)<br>ratio</pre><p>Output: 2.033955892756472</p><p>Since the ratio of variances is less than 4, they are considered equal. Next, we can proceed with Student T-Test.</p><pre>#Performing T-Test<br>result = ttest_ind(high_cal, low_cal, equal_var = True, random_state = 42, alternative= &#39;greater&#39;)<br><br>print(&quot;Statistical Analysis Result&quot;)<br>print(&#39;-&#39;*50)<br>print(f&#39;Statistic value = {result.statistic}&#39;)<br>print(f&#39;P value = {result.pvalue}&#39;)<br>print(&#39;-&#39;*50)<br><br>#Determining rule of decision<br>print(&#39;Conclusion:&#39;)<br>if result.pvalue &lt; 0.05:<br>    print(&quot;Reject the null hypothesis&quot;)<br>else:<br>    print(&quot;Failed to reject the Null hypothesis&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*4Y6DbGY2Ahzs-aSJx3sRVQ.png" /></figure><p>Based on statistical test, p-value is &lt; 0.05 meaning there is sufficient evidence that there is significant difference of BMI level means between frequent and infrequent consumption of high caloric foods, where someone who is frequently consume high caloric foods will have higher BMI level than someone who is not. Therefore, we reject the null hypothesis.</p><p><strong>4. T-test for the difference between two population means: Family History of Overweight</strong></p><p>First of all, stating Null hypothesis (H0), alternative hypothesis (H1), and significance level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*HijsdNdW3ZlvuL7kJ99oRw.png" /></figure><pre>#Determining whether the data has equal or unequal variances<br><br>#Accessing column BMI data based on condition in gender column then save it as male variable<br>over_family_yes = df[df[&quot;overweight_family&quot;] == 1][[&quot;BMI&quot;]].values<br>over_family_no = df[df[&quot;overweight_family&quot;] == 0][[&quot;BMI&quot;]].values<br><br>#Calculating the ratio of variance<br>#If the ratio is less than 4, they considered as equal<br>ratio = np.var(over_family_yes)/np.var(over_family_no)<br>ratio</pre><p>Output: 3.1934055030078556</p><p>Since the ratio of variances is less than 4, they are considered equal. Next, we can proceed with Student T-Test</p><pre>#Performing T-Test<br>result = ttest_ind(over_family_yes, over_family_no, equal_var = True, random_state = 42, alternative= &#39;greater&#39;)<br><br>print(&quot;Statistical Analysis Result&quot;)<br>print(&#39;-&#39;*50)<br>print(f&#39;Statistic value = {result.statistic}&#39;)<br>print(f&#39;P value = {result.pvalue}&#39;)<br>print(&#39;-&#39;*50)<br><br>#Determining rule of decision<br>print(&#39;Conclusion:&#39;)<br>if result.pvalue &lt; 0.05:<br>    print(&quot;Reject the null hypothesis&quot;)<br>else:<br>    print(&quot;Failed to reject the Null hypothesis&quot;)</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*G_PiF8BLSIvWk9VCStVkVw.png" /></figure><p>Based on statistical test, p-value is &lt; 0.05 meaning there is sufficient evidence that there is significant difference of BMI level means between someone who has family history of overweight and someone who does not have, where someone who has family history of overweight will have higher BMI level than someone who does not have family history of overweight. Therefore, we reject the null hypothesis.</p><p><strong>5. ANOVA test for the effect of means of transportation</strong></p><p>First of all, stating Null hypothesis (H0), alternative hypothesis (H1), and significance level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*f7V2C5CQc1-iefBgFPkajg.png" /></figure><pre>#Creating Linear Equation<br>jenis_transportasi = ols(&#39;BMI ~ transportation&#39;, data = df).fit()<br><br>#Performing ANOVA test<br>aov_table_1 = sm.stats.anova_lm(jenis_transportasi)<br><br>print(&quot;ANOVA Test Result&quot;)<br>print(&#39;-&#39;*75)<br>print(aov_table_1)<br>print(&#39;-&#39;*75)<br><br><br>#Determining rule of decision<br>print(&#39;Conclusion:&#39;)<br>if result.pvalue &lt; 0.05:<br>    print(&quot;Reject the null hypothesis&quot;)<br>else:<br>    print(&quot;Failed to reject the Null hypothesis&quot;)</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*HOnbYUUG5HZ3wFVc2Ar6_A.png" /></figure><p>Based on ANOVA test, p-value is &lt; 0.05 meaning there is sufficient evidence that there is significant difference of BMI level at least one among means of transportation. This imply that difference means of transportation taken will influence the BMI level. Therefore, we reject the null hypothesis.</p><h4>Correlation among Features</h4><pre># Code used to see correlation among features<br>corr_ = df.corr()<br>plt.figure(figsize = (7,7))<br>sns.heatmap(corr_, fmt= &quot;.3f&quot;, annot= True,square= True)<br>plt.show()</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*r8vsEM6HmPST_h2fGjajng.png" /></figure><p>From the correlation plot above, we can see that smoke variables has really weak correlation with BMI. While other correlation coefficients are interpreted as follows:</p><p>a. Age has quite strong positive correlation with BMI level since the correlation coefficient is 0.267<br>b. Family history of overweight has strong positive correlation with BMI level since the correlation coefficient is 0.508<br>c. Frequent consumption of high caloric foods has quite strong positive correlation with BMI level since the correlation coefficient is 0.258<br>d. Smoke has weak negative correlation with BMI level since the correlation coefficient is 0.002<br>e. Physical activity has quite strong negative correlation with BMI level since the correlation coefficient is -0.206<br>f. Device time has quite strong negative correlation with BMI level since the correlation coefficient is 0.125</p><h4>Regression Model</h4><p>Based on hypothetical testing we have conducted, we conclude that there are several variables that significantly influence BMI level and several variables that are not. Therefore, in building regression model, we exclude the variables that has no significant influence to BMI level so that the model built will be more accurate.</p><pre>#Reviewing the data<br>df</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*FNGa98N8EW3z9HP66hCeoQ.png" /></figure><pre>#Import the module for the linear regression model<br>import statsmodels.formula.api as smf<br>from statsmodels.formula.api import ols<br>import statsmodels.api as sm<br>import scipy.stats as stats<br><br>#Use encoding to identify each means of transportation<br>encoded_df = pd.get_dummies(data = df, columns = [&#39;transportation&#39;])<br>encoded_df</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JmKdM44FZ_iFAcHnqrk2HQ.png" /></figure><pre>#Construct the model<br>lm1 = smf.ols(&#39;BMI ~  age + overweight_family + high_caloric + physical_activity + device_time + transportation_Automobile + transportation_Motorbike + transportation_Bike + transportation_Public_Transportation + transportation_Walking&#39;,<br>              data = encoded_df).fit()<br>print(lm1.summary())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*X33sQikKNXei8hioIIS59Q.png" /></figure><p>The model we get from the output is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*fgUDglKqgbe48bSOA3vZWA.png" /></figure><p>The interpretation for the categorical variables are:</p><ol><li>If someone’s <strong>age</strong> is higher by 1 unit meaning that someone is 1 year older, the BMI level will <strong>increase</strong> by <strong>0.095</strong> unit.</li><li>If someone has <strong>family history of overwight</strong> the BMI level will <strong>increase</strong> by <strong>2.2727</strong> unit than if someone does not have the history.</li><li>If someone is <strong>frequently consume high caloric value</strong>, the BMI level will <strong>increase</strong> by <strong>0.8242</strong> unit than someone who is not.</li><li>If someone does more <strong>physical activity</strong> and which its value is higher by 1 unit, the BMI level will <strong>decrease</strong> by <strong>0.2383</strong> unit.</li><li>If someone spend more <strong>time with their device</strong> which its value is higher by 1 unit, the BMI level will <strong>decrease</strong> by <strong>0.2676</strong> unit.</li></ol><p>Actually, there are 5 models that we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*7l0gG90kYLoHlZFfydypbA.png" /></figure><p>The interpretation for the categorical variables are:</p><ol><li>If someone use <strong>Automobile</strong> as their means of transportation, their BMI will <strong>decrease</strong> by <strong>0.839</strong> unit.</li><li>If someone use <strong>Motorbike</strong> as their means of transportation, their BMI will <strong>decrease</strong> by <strong>0.4689</strong> unit.</li><li>If someone use <strong>Bike</strong> as their means of transportation, their BMI will <strong>decrease</strong> by <strong>0.3374</strong> unit.</li><li>If someone use <strong>Public_Transportation</strong> as their means of transportation, their BMI will <strong>increase</strong> by <strong>0.5405</strong> unit.</li><li>If someone use <strong>Walking</strong> as their means of transportation, their BMI will <strong>decrease</strong> by <strong>0.4348</strong> unit.</li></ol><h4>Analysis</h4><p>From the EDA and modelling, we can see that the variable of family history of overweight plays a significant role influence BMI level. Because of that, it is important to pay attention to our own BMI level so we do not affect the likelihood to increase BMI level of our kids’ and generations after us since according to the research, obesity is highly associated with development of diseases. This can be done by switching our food intake from high calories foods to lower calories, do more physical activity, and riding bikes or walking.</p><p>From the model, we can see that the R-Squared of the model is 0.389. It means that only <strong>38.9%</strong> of the total variance in the data explained by the model, which is relatively really small. We can create a better model by choosing other predictors or adding more multiple predictors that have high correlation with BMI value. We can also do that by using other regression or even more sophisticated models to describe the data.</p><p>From the model, we can also see that the result is not quite what we expected to be. For example, we expected spending more time on device will result in higher BMI level yet our model shows contradiction. This can happen if the factor does not influence the model directly. Suppose someone using the device for listening to music while running or for watching yoga videos then the usage of the device could decrease the BMI level. For future research, the context of the variables we want to measure has to be clear.</p><h4>Conclusions</h4><ol><li>Predictor variables on data that significantly influence the the level of someone’s BMI are age, family history of overweight, frequent consumption of high caloric foods, physical activity, device time, and means of transportations.<br>a. Age: Someone who is older tends to have higher BMI level<br>b. Family history of overweight: Someone who has family history of overweight tends to have higher BMI level<br>c. Frequent consumption of high caloric foods: Someone who frequently consume high caloric foods tend to have higher BMI level<br>d. Physical activity: Someone who does more physical activity tends to have lower BMI level<br>e. Device time: Someone who spends more time on their device tends to have lower BMI level<br>f. Means of transportations: Someone who use public transportation tends to have the highest BMI among others</li><li>The correlation between variables and BMI:<br>a. Age has quite strong positive correlation with BMI level since the correlation coefficient is 0.267<br>b. Family history of overweight has strong positive correlation with BMI level since the correlation coefficient is 0.508<br>c. Frequent consumption of high caloric foods has quite strong positive correlation with BMI level since the correlation coefficient is 0.258<br>d. Smoke has weak negative correlation with BMI level since the correlation coefficient is 0.002<br>e. Physical activity has quite strong negative correlation with BMI level since the correlation coefficient is -0.206<br>f. Device time has quite strong negative correlation with BMI level since the correlation coefficient is 0.125</li><li>BMI level is modeled with linear regression with the result:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*fgUDglKqgbe48bSOA3vZWA.png" /></figure><h4>Further Research</h4><ol><li>Create a better model by choosing other predictors or adding more multiple predictors that have high correlation with BMI value. We can also do that by using other regression or even more sophisticated models to describe the data.</li><li>Clarify the context of each variables measured.</li></ol><h4>Reference</h4><ul><li>PACMANN Academy. (2023). <em>Business Statistics.</em> Jakarta</li></ul><p><a href="https://journals.lww.com/nutritiontodayonline/fulltext/2015/05000/body_mass_index__obesity,_bmi,_and_health__a.5.aspx">Body Mass Index: Obesity, BMI, and Health: A Critical Review : Nutrition Today</a></p><p><a href="https://biomedgrid.com/fulltext/volume4/influence-significance-and-importance-of-body-mass-index-in-scientific-research-and-various-fields-of-science.000816.php#:~:text=Body%20mass%20index%20helps%20to,atherosclerosis%2C%20hypertension%20and%20nutrition%20disorders">https://biomedgrid.com/fulltext/volume4/influence-significance-and-importance-of-body-mass-index-in-scientific-research-and-various-fields-of-science.000816.php#:~:text=Body%20mass%20index%20helps%20to,atherosclerosis%2C%20hypertension%20and%20nutrition%20disorders</a>.</p><p><a href="https://longevity.technology/lifestyle/bmi-benefits-of-knowing-proportions-its-implications-and-research/">BMI: Benefits of knowing proportions, its implications and research</a></p><p>Link github: <a href="https://github.com/kinannblh/BMI-regression">https://github.com/kinannblh/BMI-regression</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bb97147605a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Wrangling — Product Analysis on Olist Database]]></title>
            <link>https://medium.com/@kinantinabilah.ichnar/data-wrangling-product-analysis-on-olist-database-9f1983dd45a7?source=rss-3afb7379619------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f1983dd45a7</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-wrangling]]></category>
            <dc:creator><![CDATA[Kinanti Nabilah]]></dc:creator>
            <pubDate>Sun, 12 Feb 2023 15:39:12 GMT</pubDate>
            <atom:updated>2023-02-12T15:39:12.234Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Wrangling — Product Analysis on Olist Database</h3><h3>Introduction</h3><p>An E-commerce Company based in Brazil called Olist want to analyze their data on product or items they sell. The results of the analysis and visualizations can give insights to the company to plan strategic marketing to increase product sales.</p><h3>Objective Analysis</h3><p>In this analysis, there are several business objectives to be answered:</p><ol><li>Which 10 product categories are the most popular?</li><li>Which 10 product categories are the least popular?</li><li>Which 10 product categories with the highest revenue?</li><li>Which 10 product categories with the lowest revenue?</li><li>What is the most used payment type?</li></ol><h3>Data Overview</h3><p>Datasets are saved in relational database. The illustration of the relation of the data is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*gRmn4LhIilz69vSZ9mRbVw.png" /><figcaption>Relation of the datasets</figcaption></figure><p>The Complete Olist Data Description can be seen <a href="https://docs.google.com/document/d/1BdZLih-YLpJa9RoWtDenhGJAvyyGHwb60CzFHlHc2F8/edit#">here</a>.</p><p>First, we assign variable name to each dataset to make it easy for us to call the data.</p><pre>data_customer = pd.read_sql_query(&quot;SELECT * FROM olist_order_customer_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_orders = pd.read_sql_query(&quot;SELECT * FROM olist_order_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_reviews = pd.read_sql_query(&quot;SELECT * FROM olist_order_reviews_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_payments = pd.read_sql_query(&quot;SELECT * FROM olist_order_payments_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_order_items = pd.read_sql_query(&quot;SELECT * FROM olist_order_items_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_products = pd.read_sql_query(&quot;SELECT * FROM olist_products_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_sellers = pd.read_sql_query(&quot;SELECT * FROM olist_sellers_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_geolocation = pd.read_sql_query(&quot;SELECT * FROM olist_geolocation_dataset&quot;, con, index_col = &quot;index&quot;)<br>data_translation = pd.read_sql_query (&quot;SELECT * FROM product_category_name_translation&quot;, con, index_col = &quot;index&quot;)</pre><p>After that, we view top 5 data on each table to see its contents. Here, we show the customer table for example.</p><pre>data_customer.head()</pre><p>After we see the contents of each table, we align them with the objectives we want to answer. To be able to answer the question, we only need 5tables so we filtered the data beforehand and choose to work with the tables we need. The tables are data_orders, data_products, data_order_items, and data_translation, data_payments.</p><p>Here are the data overview.</p><ol><li><strong>Table Data Orders</strong></li></ol><pre>data_orders.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7jWeM7I4GaRnzo60fd5iqg.png" /><figcaption>Orders table</figcaption></figure><ul><li><strong>order_id</strong>: unique identifier of the order</li><li><strong>customer_id</strong>: key to the customer dataset. each order has a unique customer_id</li><li><strong>order_status</strong>: reference to the order status (delivered, shipped, etc)</li><li><strong>order_purchase_timestamp</strong>: shows the purchase timestamp</li><li><strong>order_approved_at</strong>: shows the payment approval timestamp</li><li><strong>order_delivered_carrier_date</strong>: shows the order posting timestamp. when it was handled to the logistic partner</li><li><strong>order_delivered_customer_date</strong>: shows the actual order delivery date to the customer</li><li><strong>order_estimated_delivery_date</strong>: shows the estimated delivery date that was informed to customer the purchase moment</li></ul><p>2. <strong>Table Data Products</strong></p><pre>data_products.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gFw98iJwxMNeUe7YTA6KjA.png" /><figcaption>Products Table</figcaption></figure><ul><li><strong>product_id</strong>: unique product identifier</li><li><strong>product_category_name</strong>: root category of product, in Portuguese</li><li><strong>product_name_lenght</strong>: number of characters extracted from the product name</li><li><strong>product_description_lenght</strong>: number of characters extracted from the product description</li><li><strong>product_photos_qty</strong>: number of product published photos</li><li><strong>product_weight_g</strong>: product weight measured in grams</li><li><strong>product_length_cm</strong>: product length measured in centimeters</li><li><strong>product_height_cm</strong>: product height measured in centimeters</li><li><strong>product_width_cm</strong>: product width measured in centimeters</li></ul><p><strong>3. Table Data Order Items</strong></p><pre>data_order_items.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaFnq_x4qjW-Qk62Mxp0yA.png" /><figcaption>Order Items Table</figcaption></figure><p>- <strong>order_id</strong>: order unique identifier<br>- <strong>order_item_id</strong>: sequential number identifying number of items included in the same order <br>- <strong>product_id</strong>: product unique identifier <br>- <strong>seller_id</strong>: seller unique identifier<br>- <strong>shipping_limit_date</strong>: shows the seller shipping limit date for handling the order over to the logistic partner<br>- <strong>price</strong>: item price<br>- <strong>freight_value</strong>: item freight value item (if an order has more than one item the freight value is splitted between items)</p><p><strong>4. Product Category Name Translation</strong></p><pre>data_translation.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*NQ6vekjqF8No-qaikvP60g.png" /><figcaption>Translation table</figcaption></figure><ul><li><strong>product_category_name</strong>: category name in Portuguese</li><li><strong>product_category_name_english</strong>: category name in English</li></ul><p>5. Product Category Payments</p><pre>data_payments.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*LnSO2xOVG9qTOkh0028ttw.png" /><figcaption>Payments Table</figcaption></figure><p>- <strong>order_id</strong>: order unique identifier<br>- <strong>payment_sequential</strong>: a customer may pay an order with more than one payment method. If he does so, a sequence will be created to accommodate all payments<br>- <strong>payment type</strong>: method of payment chosen by customer <br>- <strong>payment_installments</strong>: number of installments chosen by the customer<br>- <strong>payment_value</strong>: transaction value</p><h3>Data Checking</h3><p>For every table we use, we check null values and dropping duplicates if any. Here for example, we check the null values and duplicates on data_orders. We use the same technique with the other 4 tables.</p><p>a. Checking null</p><pre>data_orders.isna().sum()</pre><p>b. Checking duplicates</p><pre>data_orders[data_orders.duplicated(keep=False)]</pre><p><strong>Results of data checking:</strong></p><ol><li><strong>Table Orders</strong></li></ol><p>There are several missing values ranging from 160–2965 but not on the table we are going to use. No duplicates were found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*6-08GKox9RKY_ouQhBOBMA.png" /></figure><p><strong>2. Table Products</strong></p><p>There are several missing values, some data inconsistency, but no duplicates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*8J8zw9Ou099lMS-toF7VUA.png" /></figure><p><strong>3. Table Order Items</strong></p><p>There are no missing values nor duplicates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*kEOCweLLeuw18YqEL-Bmig.png" /></figure><p><strong>4. Table Translations</strong></p><p>There are no missing values nor duplicates but there are data inconsistency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*qWy_a87LAEbv_HVIAPNzQw.png" /></figure><p><strong>5. Table Payments</strong></p><p>There are no missing values nor duplicates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*TGjDFRJsiC5v3DhCdkL9nw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*BpxIInZ5od_iX4ZL7je1aQ.png" /></figure><h3>Data Processing</h3><ol><li>Data merging</li></ol><p>Here we merge the 5 tables and named it as data_final.</p><pre>orders_items = pd.merge(data_order_items, data_orders, on = &quot;order_id&quot;, how = &quot;left&quot;)<br>orders_items_products = pd.merge(orders_items, data_products , on = &quot;product_id&quot;, how = &quot;left&quot;)<br>orders_items_products_translation = pd.merge(orders_items_products, data_translation, on = &quot;product_category_name&quot;, how = &quot;left&quot;)<br>orders_items_products_translation_payments = pd.merge(orders_items_products_translation, data_payments, on = &quot;order_id&quot;, how = &quot;inner&quot;)<br><br>data_final = orders_items_products_translation_payments</pre><p>2. Checking null on merged table</p><pre>data_final.isna().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*1ltd9GIjRNPJwufq8tx-Kg.png" /></figure><p>3. Dropping Unnecessary Columns</p><pre># dropping unnecessary columns<br><br>data_final = data_final.drop(columns = [&#39;order_approved_at&#39;,&#39;order_delivered_carrier_date&#39;, &#39;order_delivered_customer_date&#39;, &#39;product_name_lenght&#39;, &#39;product_description_lenght&#39;, &#39;product_photos_qty&#39;, &#39;product_weight_g&#39;,  &#39;product_length_cm&#39;, &#39;product_height_cm&#39;, &#39;product_width_cm&#39;, &#39;payment_sequential&#39;, &#39;payment_installments&#39;, &#39;payment_value&#39;])</pre><p>Here are the columns of the data_final we are going to use</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*xWPCriYLGYnEwnmooGmepQ.png" /></figure><p>4. Checking data inconsistency</p><p>We particularly want to use product_category_name_english column for our analysis. We can see there are more missing values on the english translated column than in the Portuguese named products. So, the missing values on the translated column can be filled by refering to Portuguese named product column. But before filling in the column, we want to check the data inconsistency in product_category_name column.</p><pre>data_final[&quot;product_category_name_english&quot;].unique()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*gl_2q9TxpPvSApO097u3ww.png" /></figure><p>There are some typographical error and similar names that categorized as the same thing. So we change the data inconsistency and merge as the same categories.</p><pre>#Changing data inconsistency<br><br>df1 = {&quot;fashio_female_clothing&quot; : &quot;fashion_female_clothing&quot;,<br>       &quot;home_confort&quot;: &quot;home_comfort&quot;,<br>       &quot;home_comfort_2&quot; : &quot;home_comfort&quot;,<br>       &quot;home_appliances_2&quot;: &quot;home_appliances&quot;}<br><br>data_final[&quot;product_category_name_english&quot;] = data_final[&quot;product_category_name_english&quot;].replace(df1)<br>data_final[&quot;product_category_name_english&quot;].unique()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*WC1TP1kTnWBQKZolA_0g2w.png" /></figure><p>The data consistency were successfully handled since we don’t see similar categories anymore.</p><p>5. Filling in missing values</p><p>We made sure there is no data inconsistency in product_category_name column so now we can proceed to fill missing values on product_category_name_english column.</p><p>First, we check if there are missing values on the latter column but filled in first. To check this, we use:</p><pre>#Check missing values on one column that is filled on the other<br><br>data_final[[&quot;product_category_name&quot;,&quot;product_category_name_english&quot;]].loc[(data_final[&quot;product_category_name&quot;].notna()) <br>&amp; (data_final[&quot;product_category_name_english&quot;].isna())]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*3OQxuFLfwHbHoc4BcyQNsw.png" /></figure><p>We can see there are two categories that we can fill in:</p><ul><li>portateis_cozinha_e_preparadores_de_alimentos as portable kitchen</li><li>pc_gamer as pc_gamer</li><li>for other null values in product_category_name, we use “others” to fill the product_category_name_english</li></ul><pre># Filling missing values on product_category_name_english column based on product_category_name column<br>#df.B = df.B.fillna(df.A.map(dict))<br><br>dict1 = {&quot;portateis_cozinha_e_preparadores_de_alimentos&quot;: &quot;portable kitchen&quot;, &quot;pc_gamer&quot; : &quot;pc_gamer&quot;, None: &quot;Others&quot;}<br><br>mapping = data_final[&quot;product_category_name&quot;].map(dict1)<br><br>data_final[&quot;product_category_name_english&quot;] = data_final[&quot;product_category_name_english&quot;].fillna(mapping)<br><br>data_final[&quot;product_category_name&quot;] = data_final[&quot;product_category_name&quot;].fillna(&quot;Unknown&quot;)</pre><p>After that, we check the changing null values</p><pre>#Checking null values<br>data_final.isna().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*xvABe3pl_ZydYD7sjn20qQ.png" /></figure><p>There are no missing values on any of the columns we are going to use for analysis. We can continue proceed with the data.</p><h4>Question 1:</h4><blockquote><strong>Which 10 product categories are the most popular?</strong></blockquote><p>a. Create a summary table</p><pre># Changing column names<br>data_q1 = data_final.rename({&quot;product_category_name_english&quot; : &quot;product_category&quot;,<br>                            &quot;order_id&quot; : &quot;counts&quot;}, axis=1)<br><br># Create new table to calculate number of products sold based on product category<br>data_q1_top = data_q1[[&quot;product_category&quot;, &quot;counts&quot;]].groupby(&quot;product_category&quot;).count().sort_values(&#39;counts&#39;, ascending = False)[:10]<br>data_q1_top = data_q1_top.reset_index()<br>data_q1_top</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*nCJ_V5n9acJFRBaYnOhIYQ.png" /></figure><p>b. Create a Visualization</p><pre>plt.figure (figsize = (8,7))<br><br>sns.barplot(y=&quot;product_category&quot;, x=&quot;counts&quot;, data=data_q1_top, palette = &quot;muted&quot;)<br>sns.set_style(&quot;whitegrid&quot;)<br><br>plt.title (&quot;Most Popular Categories&quot;, fontsize = 25)<br>plt.xlabel(&quot;Number of Products Sold&quot;, fontsize = 14)<br>plt.ylabel(&quot;Product Category&quot;, fontsize = 14)<br>plt.xticks(fontsize = 12)<br>plt.yticks(fontsize = 12)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*894e1TkgEsDol-M-0fu_9A.png" /></figure><h4>Question 2:</h4><blockquote><strong>Which 10 product categories are the least popular?</strong></blockquote><p>a. Create a summary table</p><pre>data_q1_bottom = data_q1[[&quot;product_category&quot;, &quot;counts&quot;]].groupby(&quot;product_category&quot;).count().sort_values(&#39;counts&#39;, ascending = True)[:10]<br>data_q1_bottom = data_q1_bottom.reset_index()<br>data_q1_bottom</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*z2ecZPo6rw8ZzUyH5LES9Q.png" /></figure><p>b. Create a visualization</p><pre>plt.figure (figsize = (8,7))<br><br>sns.barplot(y=&quot;product_category&quot;, x=&quot;counts&quot;, data=data_q1_bottom, palette = &quot;muted&quot;)<br>sns.set_style(&quot;whitegrid&quot;)<br><br>plt.title (&quot;Least Popular Categories&quot;, fontsize = 25)<br>plt.xlabel(&quot;Number of Products Sold&quot;, fontsize = 14)<br>plt.ylabel(&quot;Product Category&quot;, fontsize = 14)<br>plt.xticks(fontsize = 12)<br>plt.yticks(fontsize = 12)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*1wslVegGlwCwaThJW9kwQw.png" /></figure><h4>Question 3:</h4><blockquote>What are the 10 products with highest revenue?</blockquote><p>a. Create a summary table</p><pre># Changing column names<br>data_q2 = data_final.rename({&quot;product_category_name_english&quot; : &quot;product_category&quot;,<br>                            &quot;price&quot; : &quot;revenue&quot;}, axis=1)<br><br># Create new table to calculate number of products sold based on product category<br>data_q2_top = data_q2[[&quot;product_category&quot;, &quot;revenue&quot;]].groupby(&quot;product_category&quot;).sum().sort_values(&quot;revenue&quot;, ascending = False)[:10]<br>data_q2_top = data_q2_top.reset_index()<br>data_q2_top</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*Pkd6ucMylPOb-YkxcKI4HQ.png" /></figure><p>b. Create a visualization</p><pre>plt.figure (figsize = (8,7))<br><br>sns.barplot(y=&quot;product_category&quot;, x=&quot;revenue&quot;, data=data_q2_top, palette = &quot;muted&quot;)<br>sns.set_style(&quot;whitegrid&quot;)<br><br>plt.title (&quot;Product Categories with Highest Revenue&quot;, fontsize = 25)<br>plt.xlabel(&quot;Total Revenue&quot;, fontsize = 14)<br>plt.ylabel(&quot;Product Category&quot;, fontsize = 14)<br>plt.xticks(fontsize = 12)<br>plt.yticks(fontsize = 12)<br>plt.show(</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*f74e14v27xhTAy3ejjsq7w.png" /></figure><h4>Question 4:</h4><blockquote>What are the 10 products with lowest revenue?</blockquote><p>a. Create a summary table</p><pre># Changing column names<br>data_q2 = data_final.rename({&quot;product_category_name_english&quot; : &quot;product_category&quot;,<br>                            &quot;price&quot; : &quot;revenue&quot;}, axis=1)<br><br># Create new table to calculate number of products sold based on product category<br>data_q2_bottom = data_q2[[&quot;product_category&quot;, &quot;revenue&quot;]].groupby(&quot;product_category&quot;).sum().sort_values(&quot;revenue&quot;, ascending = True)[:10]<br>data_q2_bottom = data_q2_bottom.reset_index()<br>data_q2_bottom</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*nrwy_dobAmSoDN2Jak8nKw.png" /></figure><p>b. Create a visualization</p><pre>plt.figure (figsize = (8,7))<br><br>sns.barplot(y=&quot;product_category&quot;, x=&quot;revenue&quot;, data=data_q2_bottom, palette = &quot;muted&quot;)<br>sns.set_style(&quot;whitegrid&quot;)<br><br>plt.title (&quot;10 Product Categories with Lowest Revenue&quot;, fontsize = 25)<br>plt.xlabel(&quot;Total Revenue&quot;, fontsize = 14)<br>plt.ylabel(&quot;Product Category&quot;, fontsize = 14)<br>plt.xticks(fontsize = 12)<br>plt.yticks(fontsize = 12)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*iPnoXMUmZcenOLwSKPiu9Q.png" /></figure><h4>Question 5:</h4><blockquote>What is the most used payment type?</blockquote><p>a. Create a summary table</p><pre>data_q3 = data_final[&quot;payment_type&quot;].value_counts()<br>data_q3.reset_index()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*LZd1NOZIos9Ladq0Vgp6XQ.png" /></figure><p>b. Create a visualization</p><pre>plt.figure (figsize = (8,7))<br><br>colors = [&#39;#9ab5b5&#39;, &#39;#9a9bb5&#39;, &#39;#9ab5a2&#39;, &#39;#b59aa4&#39;]<br>plt.pie(data_q3, labels = data_q3.index, autopct = &#39;%.1f%%&#39;, textprops={&#39;fontsize&#39;: 14}, colors = colors)<br>plt.axis(&#39;equal&#39;)<br><br>plt.title (&quot;Most Used Payment Type&quot;, fontsize = 25)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*Hp-Iitd6zHDvLJiFonHWEQ.png" /></figure><h3>Analysis</h3><h4>Summary</h4><h4>Most Popular Categories</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*894e1TkgEsDol-M-0fu_9A.png" /></figure><p>From the data processing, we can conclude the top 10 most popular categories with most number of products sold are bed_bath_table, health_beauty, sports_leisure, furniture_decor, computers_accessories, housewares, watches_gifts, telephony, garden_tools, and auto.</p><h4>Least Product Categories</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*1wslVegGlwCwaThJW9kwQw.png" /></figure><p>The least sold product is security_and_services, followed by fashion_childrens_clothes, pc_gamer, cds_dvds_musicals, portable kitchen, la_cuisine, arts_and_craftmanship, fashion_sport, flowers, and diapers_and_hygiene.</p><h4>The 10 Products with the Highest Revenue</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*f74e14v27xhTAy3ejjsq7w.png" /></figure><p>The top 10 product categories that generate the highest revenue are health_beauty, watches_gifts, bed_bath_table, sports_leisure, computers_accesories, furniture_decor, housewares, cool_stuff, auto, and garden_tools.</p><h4>The 10 Products with the Lowest Revenue</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*iPnoXMUmZcenOLwSKPiu9Q.png" /></figure><p>Meanwhile, 10 products categories that generate the lowest revenue are security_and_services, fashion_children_clothes, cds_dvds_musicals, flowers, diapers_and_hygiene, pc_gamer, art_and_craftmanship, fashion_sport, la_cuisine, and fashio_female_clothing</p><h4>Most Used Payment Type</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*Hp-Iitd6zHDvLJiFonHWEQ.png" /></figure><p>Most used payment type by Olist customers is credit card. Followed by boleto in second place, then voucher and debit card.</p><h4>Analysis</h4><p>From the data visualization, mostly the most popular categories will generate the high revenue while the least popular categories will generate less revenue since the number of products sold affect the revenue. Although, we can see some of the most popular categories did not make it into the ranks of categories with the highest revenue, e.g. telephony category. Other than that, we can also see the categories are not always in the same ranking in both graphs. For example, the bed_bath_table category is the most popular category with the highest number sold but not the first that generates the most revenue.</p><p>The business strategy that can be applied is to change the item price based on number of sales: increasing the price of the most popular categories so that it can generate more revenues and on the other hand decreasing the price of the least popular categories by giving discounts so that it can attract people to buy more of these categories.</p><p>Another business strategy is to promote the least popular categories by creating bundling package pairing the most popular categories and the least popular categories in a package. There are 2 options:<br>1. Set bundling package. The package is already set to target the customer with similar interest. For example bundling the sport_leisures (most popular) category with fashion_sport (least popular) category to target the customer with interest of sport. Another example bundling the garden_tools (most popular) category with flowers (least popular) to target the customer with interest of gardening.<br>2. Customers free to choose the bundling products as long as it’s pairing most popular categories with least popular categories.</p><p>From the most used type payment type visualization, we can gain useful insights if we want to encourage customers to use particular payment type. For example, let’s take a look at the boleto payment method. Boleto itself is a single use payment method particulary used in Brazil. Let’s say Boleto Company wants to make boleto payment method more familiar to the Brazilian, starting with the segment of our customers. By cooperating with Olist ecommerce, they want to increase the number of orders paid using boleto payment type so that the payment method will eventually become more familiar to the Brazilian. One of the many strategies is by giving additional discount or cashback if the customers use boleto as their payment method. Although this is only an example and not limited only for boleto payment method, this can be useful for deepening business strategy.</p><h3>Conclusion</h3><ol><li>The top 10 most popular categories with most number of products sold are bed_bath_table, health_beauty, sports_leisure, furniture_decor, computers_accessories, housewares, watches_gifts, telephony, garden_tools, and auto.</li><li>The least sold product is security_and_services, followed by fashion_childrens_clothes, pc_gamer, cds_dvds_musicals, portable kitchen, la_cuisine, arts_and_craftmanship, fashion_sport, flowers, and diapers_and_hygiene.</li><li>The top 10 product categories that generate the highest revenue are health_beauty, watches_gifts, bed_bath_table, sports_leisure, computers_accesories, furniture_decor, housewares, cool_stuff, auto, and garden_tools.</li><li>The 10 products categories that generate the lowest revenue are security_and_services, fashion_children_clothes, cds_dvds_musicals, flowers, diapers_and_hygiene, pc_gamer, art_and_craftmanship, fashion_sport, la_cuisine, and fashio_female_clothing</li><li>Most used payment type by Olist customers is credit card.</li></ol><h4>Link</h4><p>For this analysis, you can access the code on <a href="https://github.com/kinannblh/olist_analysis/">github.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f1983dd45a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Analytics Case Study: Global Food Loss and Food Waste]]></title>
            <link>https://medium.com/@kinantinabilah.ichnar/data-analytics-case-study-global-food-loss-and-food-waste-ea69e1930965?source=rss-3afb7379619------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea69e1930965</guid>
            <category><![CDATA[data-analyst]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[food-waste]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[sdgs]]></category>
            <dc:creator><![CDATA[Kinanti Nabilah]]></dc:creator>
            <pubDate>Sun, 04 Dec 2022 09:14:27 GMT</pubDate>
            <atom:updated>2022-12-04T16:38:21.469Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cYohAaN-ww6H9lAv.jpg" /></figure><h4>INTRODUCTION</h4><p><strong>Food loss</strong> occurs before the food reaches the consumer, discarded at the production, storage, processing, or distribution phases while <strong>food waste </strong>refers to food which condition is edible but consciously discarded at the retail or consumption phases, this could also happen to surplus food.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LEA6TQXk9a5GT7Lz.png" /><figcaption>Figure 1. Food Loss vs Food Waste (Source: <a href="https://onethird.io/food-loss-food-waste-difference/">https://onethird.io/food-loss-food-waste-difference/</a>)</figcaption></figure><p>Food loss and food waste is one of the most important issues to solve because it related to 2 bigger issues; global hunger and climate change.</p><p><strong>Hunger</strong></p><p>When we grow or produce our food, it requires energy, land, water, and labor from the production, storing, harvesting, transporting, packaging and selling phases. When we throw away our food, we are throwing away our finite and precious resources that could have been used to feed hungry people. Finally, the U.N. Food and Agriculture Organization (FAO) says that if we stopped wasting all that food, we’d <a href="https://www.fao.org/news/story/en/item/203149/icode/">save enough to feed 2 billion people</a>. That’s more than twice the number of undernourished people across the globe.</p><p><strong>Climate change</strong></p><p>When we do not consume our food that we have grown with our finite and preciuos resources that we have, the food gets thrown away and when it does, it rots and producing greenhouse gases like methane that directly contributing to climate change.</p><p>According to a <a href="https://www.wri.org/insights/whats-food-loss-and-waste-got-do-climate-change-lot-actually">study by World Resource Institute</a>, if wasted food were a country, it would be the third-largest producer of carbon dioxide in the world after the United States and China.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Z9YpZwbpZrnwdDy1.jpg" /><figcaption>Figure 2. Food loss and waste as the third larges greenhouse gases emitter (Source: <a href="https://www.wri.org/insights/whats-food-loss-and-waste-got-do-climate-change-lot-actually">https://www.wri.org/insights/whats-food-loss-and-waste-got-do-climate-change-lot-actually</a>)</figcaption></figure><p>If we stopped wasting food, we could <a href="https://www.un.org/press/en/2020/dsgsm1465.doc.htm">cut global emissions by 8 percent</a>. This could be a tremendous effect since low-income countries — where the vast majority of poor and hungry people live — have to take the brunt of food loss and food waste’s environmental impacts.</p><p>Stopped wasting our food could solve — or at least reduce the severity of hunger and climate change problems. Save two birds with one net.</p><h4>DATASET</h4><p>Dataset used for analysis is from <a href="https://www.fao.org/platform-food-loss-waste/flw-data/en/">FAO food loss and waste database</a> from year 2000 until 2021 <em>as is. </em>The dataset contains 27.773 data points from 155 countries. (Note: although, previously, we have explained the difference between food loss and food waste, in this dataset, the term we use only ‘food loss’ as it will describe both food loss and food waste.)</p><p><strong>country: </strong>the name of country<br><strong>region: </strong>the region in certain country<br><strong>cpc_code: C</strong>ustoms Procedure Codes to identify the customs and or/excise regimes which goods are being entered into and removed (for export and import use)<br><strong>commodity: </strong>any commodity that is derived from an agricultural animal or crop<br><strong>year: </strong>year of gathered data<br><strong>loss_percentage: </strong>percentage of food loss<br><strong>activity: </strong>activities included in particular food supply stages<br><strong>food_supply_stages: </strong>the stages or processes of supplying food<br><strong>cause_of_loss: </strong>the reason of food loss</p><h4>OBJECTIVES</h4><p>To tackle the problems mentioned above, in this case study we want to identify and analyze which countries, where in the food supply stages, and due to what causes we loss our food. To answer it, first we formulate the questions:<br>1. How the datapoints distribute?<br>2. Which commodities are lost the most (in certain range of years)?<br>3. Which countries experience the greatest food loss (in certain range of years)?<br>4. How much is average loss precentage from 2000 to 2021 for each country?<br>5. How is the trend of food loss in each countries from 2000 to 2021?<br>6. Which food supply stage that produce food loss the most (in certain years and certain countries)?<br>7. What are the factors that cause food loss based on certain food supply stage?</p><h4>INSIGHTS AND ANALYSIS</h4><p>Visualizations are made using Tableau, you can access the dashboard here.</p><ol><li><strong>How the datapoints distribute?</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*XpStrCmAaJu2LoYXlxm02w.jpeg" /><figcaption>Figure 3. Datapoints of Global Food Loss</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*dgt3J671D0qbO9Ggsl8L4g.png" /><figcaption>Figure 4. Datapoints of Global Food Loss (Hovered)</figcaption></figure><p>Since this is an interactive visualizations in Tableau, you can hover above a datapoint to see the details incuding the commodity, country, food supply stage, loss percentage, and year where the data is recorded.</p><p><strong>2. Which commodities are lost the most (in certain range of years)?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*YRUAEmxbZ8QP3Jvema4cpw.png" /><figcaption>Figure 5. Food Loss Percentage Ranked by Commodity</figcaption></figure><p>In this visualizations, you can see the average loss percentage ranked by commodity since it sorted by the highest loss first to the lowest. You can see the highest commodity lost on top, followed by the second highest at the second place and so on. In this visualization, you can also filter the data by a certain year range to identify the new rank. To see the details of average loss percentage value, you can hover into the certain bar you want to identify.</p><p>On the captured figure above, the data is from 2000–2021. We can see the highest commodity lost is snails, fresh, chillled, frozen, dried, salted or in brine, except sea snails followed by grapefruit juice in the second place and meat of pig with the bone, fresh or chilled in the third place. The data might change if you change the year range.</p><p><strong>3. Which countries experience the greatest food loss (in certain range of years)?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*jMW7Q6foYpX9xNfp525TTg.png" /><figcaption>Figure 6. Food Loss Rank by Country</figcaption></figure><p>In this visualizations, you can see the loss percentage ranked by country since it sorted by the highest loss first to the lowest. This visualizations will make you easier to see which country (or top countries) ranked the highest and have highest loss precentage among the globe. In this visualization, you can also filter the data by a certain year range to identify the new rank. To see the details of average loss percentage value, you can hover into the certain bar you want to identify.</p><p>On the captured figure above, the data is from 2000–2021. We can see the highest country who experience the greatest food loss is Haiti, followd by Australia and New Zealand, and Gabon. The data might change if you change the year range.</p><p><strong>4. How much is average loss precentage from 2000 to 2021 for each country?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*RDwMozwLCihnv9ariNdzmQ.jpeg" /><figcaption>Figure 7. Food Loss by Country</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*kwV1P0cZ-7jGCno6E1wKKA.png" /><figcaption>Figure 8. Food Loss by Country (Hovered)</figcaption></figure><p>While the bar graph of food loss rank by country help us to identify the loss percentage among countries, the map visualization can help us to identify the countries’ data faster by its geographical locations. In this visualization, you can also hover certain area of country, and you can see the details including name of the country, average loss percentage from 2000–2021, number of commodities that included in this analysis, and the trend of food loss from 2000 to 2021. The sequential color scheme will also help you to compare the average loss percentage value of the countries where the darker the green color, the higher average loss percentage.</p><p><strong>5. How is the trend of food loss in each countries from 2000 to 2021?<br></strong>You can also see the trend of food loss in each countries from year 2000 to 2021 at the details of the map visualizations (Figure 8.)</p><p><strong>6. Which food supply stage that produce food loss the most (in certain years and certain countries)?<br></strong>The food supply chain consists of different food distribution stages that food products pass through, starting with production and ending with consumption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T-5K4JH3QpKdsewF.jpg" /><figcaption>Figure 9. The Food Supply Chain (<a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fmoney.howstuffworks.com%2Ffood-supply-chain-pandemic.htm&amp;psig=AOvVaw2RGjwNOmW7VsHibJ1Er-5N&amp;ust=1670185216096000&amp;source=images&amp;cd=vfe&amp;ved=0CBAQjRxqFwoTCKCDnfai3vsCFQAAAAAdAAAAABAE">https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fmoney.howstuffworks.com%2Ffood-supply-chain-pandemic.htm&amp;psig=AOvVaw2RGjwNOmW7VsHibJ1Er-5N&amp;ust=1670185216096000&amp;source=images&amp;cd=vfe&amp;ved=0CBAQjRxqFwoTCKCDnfai3vsCFQAAAAAdAAAAABAE</a>)</figcaption></figure><p>There are 5 main stages:<br><strong>- Farm/Production </strong>where food is grown, cultivated, and/or developed. Producers including animal farms, farmers, and food manufacturers. The process including pra-harvest, harvest, post-harvest, farm, grading, and storage. <br>- <strong>Industry/Manufacturing </strong>where food is processed and packaged and went through quality control. The process including processing and packing.<br>- <strong>Distributions/Transporting </strong>where food is transported to wholesaler, market, retailers, or exported to other countries.<br>- <strong>Market </strong>where food are sold directly to customers. This process includes market, wholesale, retail, food services. <br>- <strong>Us </strong>as a customer</p><p>From the dataset, we can identify which food supply stage causing the most food loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*-2kMnrt_TDnVgvCo-LTpGQ.jpeg" /><figcaption>Figure 10. Food Loss Percentage by Food Supply Stage</figcaption></figure><p>This visualization using horizontal bar chart to make it easy to compare among food supply stages. The stages are sorted based on the flow of food pass through, from pre-harvest, all the way until the food reach the customers/households. In this visualizations, since the data are not sorted by rank it would be harder to compare the length of the bar so the label of percentage is added at the end to make it easier to compare.</p><p>On the captured data above, the data is for all the countries for the year 2000 until 2021. We can see the post-harvest is the stage where the food loss is the hghest followed by the households at the second place and retails at the third place. The percentage might change if you change the apply the country and/or the year filter into the data.</p><p>We can see from the previous graph (and able to compare) which food supply stage has the highest (or lowest or relatively higher or lower) food loss percentage. Then we are asking, what is the actual reasons of these food losses based on certain food supply stage?</p><p><strong>7. What are the factors that cause food loss based on certain food supply stage?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*GUTb_Ocd_8k4BR0oKlf6PA.jpeg" /><figcaption>Figure 11. Cause of Food Losses based on Food Supply Stages</figcaption></figure><p>Figure 11 potrays a graph of the causes of food losses. The grids are separated into several sections, where the sections describes a particular food supply stage. It sorted the biggest section on the first place at the tpp-left corner of the overall graph and the smallest section on the last place at the bottom-right corner. The size of the grid represent number of datapoints, the bigger the size, the bigger datapoints fall into that certain category. Each section has different color to make it easier to distinguish among sections (or among food supply stage).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*m8ZqQDqO6-JpH1xirIrqbQ.png" /><figcaption>Figure 12. Cause of Food Losess based on Food Supply Stages (Hover)</figcaption></figure><p>If you hover above the square or the grid you can see the details including cause of loss, food supply stage, and average loss percentage as potrayed in Figure 12. As an example, you want to see the top-left corner grid, the details say in farm stage, the average loss percentage is 50% (meaning from the total 100% food that could have processed into next stage, it counts as food loss instead) due to (lack of) literacy and technology exposure. This grid is the biggest since there are many datapoints (it has the most datapoints among it) that has this particular causes of food loss. The size and the display of the visualization might change if you filter the data by country and/or by year like shown below where the country chosen is Indonesia with the year range from 2000 until 2018.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*1dwnT8hZImGSVKkD5SXiJQ.png" /><figcaption>Figure 12. Cause of Food Losess based on Food Supply Stages (For Indonesia only from 2000 until 2018)</figcaption></figure><p><strong>Analysis</strong></p><p>Having filtered by year, by country, by commodity, or by cause of loss, this data can help us to identify which solutions can be effective to solve the problem. <em>Think globally, act locally. </em>Each country could have different causes of losses and this is up to the country to tackle the particular problems, although some countries could have the same problem and can work the same solutions.</p><p>Regardless, there is one thing that are doable and could be adapted by any countries: <strong>Sustainable Food Supply Chain.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jKrxb-GhhVNU7ixI.jpg" /><figcaption>Figure 13. Sustainable and Resilient Food Supply Chain</figcaption></figure><p>From the producers, manufacturers, distributors, markets, and customers have to produce, manage, and consume in a sustainable manner. For example, in producing stage, there has to be increasing of literacy and technology exposure and regenerative farming, in markets there is no need to choose the food based on its appearance as long as it is edible, in markets or in food service or in household not to oversupply (match the supply and demand). And in every phase, if it is possible, we can do composting, applying circular economy, so that it doesn’t harm the environment and we can reuse/recycle the resources.</p><h4>CONCLUSIONS</h4><p>From the data, we have processed and have made visualizations based on our questions.</p><p>1. The first visualization graph, as shown as Figure 3, shows us how the datapoints distributed if we plot the loss percentage by year.<br>2. As shown as Figure 5, we can identify the most, the least, or the relatively higher or lower rank of food commodity that loss during any stage of food supply.<br>3. Bar chart of food loss rank by country as shown as Figure 6 to identify which countries has the highest, the lowest, or relatively higher or lower rank than others.<br>4. Map visualizations as shown as Figure 7 to identify the average loss percentage for each country based on its geographical locations.<br>5. The trend of food loss in each countries from 2000 to 2021 also shown in the map visualization as shown as Figure 7. <br>6. Graph as shown as Figure 10 helps us to identify the average loss percentage based on food supply stage.<br>7. Graph as shown as Figure 11 helps us to identify what are the causes of food losses in each food supply stage and how often it happens.</p><h4>FURTHER RESEARCH</h4><p>More datapoints can be gathered to enrich the dataset and the dataset itself can be explored more by dividing food waste vs food loss percentage (using the food supply data) so we can compare which is bigger, food waste or food loss so to formulate the more effective solutions. ve</p><h4>REFERENCE</h4><ul><li><a href="https://onethird.io/food-loss-food-waste-difference/">Food Loss and Food Waste: What&#39;s the Difference?</a></li><li><a href="https://www.wri.org/insights/whats-food-loss-and-waste-got-do-climate-change-lot-actually">What&#39;s Food Loss and Waste Got to Do with Climate Change? A Lot, Actually.</a></li><li><a href="https://www.wfpusa.org/articles/how-food-waste-affects-world-hunger/">How Food Waste Affects World Hunger</a></li><li><a href="https://www.wfpusa.org/articles/food-waste-climate-change-hunger-vicious-cycle/">Food Waste, Climate Change and Hunger: A Vicious Cycle</a></li><li><a href="https://www.fao.org/news/story/en/item/203149/icode/">Monitoring food loss and waste essential to hunger fight</a></li><li><a href="https://press.un.org/en/2020/dsgsm1465.doc.htm">Food Loss, Waste Account for 8 Per Cent of All Greenhouse‑Gas Emissions, Says Deputy Secretary-General, Marking Inaugural International Awareness Day</a></li></ul><p>You can access the Tableau Dashboard <a href="https://public.tableau.com/app/profile/kinan6437/viz/Foodwasteandfoodloss/Dashboard1?publish=yes">here</a>.</p><p>Let’s Connect!<br>LinkedIn: <a href="https://www.linkedin.com/in/kinanti-nabilah-76879522a/">Kinanti Nabilah</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea69e1930965" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Final Project Probability Course Pacmann: Health Insurance Case Study]]></title>
            <link>https://medium.com/@kinantinabilah.ichnar/final-project-probability-course-pacmann-health-insurance-case-study-d622f5245941?source=rss-3afb7379619------2</link>
            <guid isPermaLink="false">https://medium.com/p/d622f5245941</guid>
            <category><![CDATA[data-analyst]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Kinanti Nabilah]]></dc:creator>
            <pubDate>Sat, 03 Dec 2022 16:55:56 GMT</pubDate>
            <atom:updated>2022-12-04T11:00:23.399Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*_RqIIdysmDlFVNJi3HFgPA.jpeg" /></figure><h4>INTRODUCTION</h4><h4>Background</h4><p>Health insurance users are regularly required to pay a certain amount of money (premium) to the health insurance company. Premium was calculated by the insurance company to pay user’s health bill. Determining the premium value can be a challenge itself for the insurance company since there are many factors that can influence and increase users’ risk profile.</p><h4><strong>Objective</strong></h4><p>Through this project, analysis is conducted to understand the relationship between some variables depicting users’ condition with health bill received by each user.</p><h4>DATASET</h4><p>Dataset is personal data of users’ of the health insurance company. It contains 1338 entries with non-null and 7 variables, including: <br>- <strong>Age: </strong>age of primary beneficiary<strong><br>- Sex: </strong>insurance contractor gender, female, male<strong><br>- BMI: </strong>body mass index, providing and understanding of body, weights that are relatively high or low relative to height, objective index of body weight (kg/m2) using the ratio of height to weight, ideally 18.5 to 24.9<strong><br>- Children</strong>:<strong> </strong>number of children covered by health insurance/ number of dependents<strong><br>- Smoker</strong>:<strong> </strong>smoking<strong><br>- Region</strong>:<strong> </strong>the beneficiary’s residential area in the US, northeast, southeast, southwest, northwest<strong><br>- Charges</strong>:<strong> </strong>individual medical cost billed by health insurance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*nr0EZDNzKOUzlqFjoiRghQ.png" /><figcaption>Figure 1. Dataset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*CGK3gzkf5aAxS5f9.jpg" /><figcaption>Figure 2. Body Mass Index Categories (Source: <a href="https://www.freepik.com/premium-vector/body-mass-index-man-silhouettes-with-different-obesity-degrees_15808216.htm">https://www.freepik.com/premium-vector/body-mass-index-man-silhouettes-with-different-obesity-degrees_15808216.htm</a>)</figcaption></figure><p>From Figure 2, according to BMI range, there are 5 distinct categories:<br>1. <strong>Underweight</strong> for BMI &lt; 18.5<br>2. <strong>Normal</strong> for 18.5 <strong>≤ </strong>BMI<strong> </strong>≤ 24.9<br>3. <strong>Overweight</strong> for 25.0 ≤ BMI ≤ 29.9<br>4. <strong>Obese</strong> for 30.0 ≤ BMI ≤ 34.9<br>5. <strong>Extremely overweight</strong> for BMI ≥ 35.0</p><h4>RESEARCH QUESTIONS</h4><h4>I. <strong>Descriptive Statistic Analysis</strong></h4><p>1. What is the users’ age average? <br> 2. Is the users’ age average the same for female and male category?<br> 3. What is the average of BMI value of users who smoke?<br> 4. Which BMI value is higher, male or female?<br> 5. Which BMI value is higher, smoker or nonsmoker?<br> 6. Is the variance of charges value the same for smoker and nonsmoker?<br> 7. Which average charge is higher, smoker or nonsmoker?<br> 8. Which average charge is higher, a smoker whose BMI above 25 or nonsmoker whose BMI above 25?</p><h4>II. Categorical Variable Analysis</h4><p>1. Which proportion is higher, smoker or nonsmoker?<br> 2. Which gender has the highest charge?<br> 3. What is the probability of a female given the user is a smoker?<br> 4. What is the probability of a male given the user is a smoker?<br> 5. How is the probability distribution of charge in each region?<br> 6. Does each region have users’ proportion equal to each other?</p><h4>III. Continuous Variable Analysis</h4><ol><li>Which one is more likely to happen?<br>a. A user has BMI above 25 if they receive charges above 16.7k,<br>or<br>b. A user has BMI below 25 they receive charges above 16.7k</li><li>Which one is more likely to happen?<br>a. A user whose BMI below 25 will receive charges above 16.7k,<br>or<br>b. A user whose BMI below 25 will receive charges below 16.7k</li><li>Which one is more likely to happen?<br>a. A smoker whose BMI above 25 receives charges above 16.7k,<br>or<br>b. A nonsmoker whose BMI above 25 receives charges above 16.7k</li></ol><h4>IV. Variable Correlation Analysis</h4><p>1. How is the correlation of BMI, age, and number of children with charges?<br> 2. How is distribution of charge each based on smoker, sex, BMI and region category?</p><h4>V. Hypothesis Testing</h4><p>Is the hypothesis true for these claims?<br>1. Smoker users have higher charges than nonsmoker<br>2. Users whose BMI above 25 have higher charges than users whose BMI below 25<br>3. Male users have higher charges than female</p><h4>FINDINGS AND ANALYSIS</h4><p>The tools used for analyzing is Microsoft Excel for calculations and Tableau for visualizations.</p><h4>I. Descriptive Statistic Analysis</h4><p>First, we want to analyze the descriptive statistic of the data. Below is the summary table of the descriptive statistic we have calculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*F1s1DhLHqAI78ftbknKDzQ.png" /><figcaption>Figure 3. Summary Table of Descriptive Statistics</figcaption></figure><p>From the Figure 3 above, we can extract the values to answer the mentioned research questions explained below.</p><p><strong>Total users<br></strong>From the data, we can see the total number of users is 1338 where 662 are females and 676 are males and there are 1064 nonsmokers and 274 smokers from the total users.</p><p><strong>Age<br></strong>The average age of users is 39 years old with age range between 18 and 64 years old. Comparing the average age between female and male as well as smoker and no smoker, there is not much difference of the average age, which is around 38–39 years old.</p><p><strong>BMI<br></strong>As for average BMI value for all users is 30.66. While specifically, average BMI value for female is 30.38 and for male is 30.94 which has no big difference as well as the average BMI value for smoker is 30.71 and nonsmoker is 30.65. According to Figure 2 of categorization of BMI value, in average, users, whether male or female or whether smoker and nonsmoker fell into Obesity category (with BMI value between 30 and 34.)</p><p><strong>Charges</strong><br>Looking at the charges received or has to be paid by users regularly, female has slightly lower charges (12,570 USD) than male (13,957 USD). While, the difference of average charges are quite significant between nonsmoker (8,434 USD) and smoker (32,050 USD) since it is believed there is higher probability of increase risk profile both for male (compared to female), and smoker (compared to nonsmoker). If we aggregate the sex and smoker column hence comparing the average mean for smoker who is male to smoker who is female we also get the average mean higher for male smoker (33,042 USD compared to 30,679)</p><p>Comparing the variance or standard deviation value (the square root of variance) of charges for smoker and nonsmoker, we can see there is a quite significant difference. While nonsmoker only have standard deviation as much as 5,994 USD, the smoker category can have standard deviation up to 11,542 USD meaning the smoker category has wider range of charges with the maximum charge is 63,770 USD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*9K6RrzsVMqXDNnTPMP5BmA.png" /><figcaption>Figure 4: Comparison of Average Charge between Sex/Smoker</figcaption></figure><p>Then, comparing the average charges for smoker with BMI above 25 and nonsmoker with BMI above 25, there is a significant difference where the average charge of smoker can be up to almost 4.5 times more compared to nonsmoker’s (35,117 USD compared to 8,630 USD).</p><p><strong>Key takeaways:<br></strong>1. Average age of users is 39 years old<br>2. There is not much average age difference between female and male category, both around 38–39 years old.<br>3. The average of BMI value of users who smoke is 30.71<br>4. Comparing male and female, in average, male has slightly higher BMI (30.94) than female (30.38)<br>5. Comparing smoker and nonsmoker, in average, smoker has slightly higher BMI (30.71) than nonsmoker (30.65)<br>6. The variance of charges value is not the same same for smoker and nonsmoker, where smoker has higher variance (11,542 USD) compared to nonsmoker (5,994 USD). <br>7. Comparing smoker and nonsmoker, smoker has higher average of charge (32,050 USD) than nonsmoker (8,434 USD)<br>8. Comparing a smoker whose BMI above 25 or nonsmoker whose BMI above 25, a smoker whose BMI above 25 has higher average of charge (35,117 USD) which is almost 4.5 times higher than a nonsmoker whose BMI above 25 (8,630 USD).</p><h4>II. Categorical Variable Analysis</h4><p>Next, probability of certain conditions that has potential to increase the charge will be identified.</p><p><strong>Comparison of Sex Category and Smoker Category</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*JoYDDWYeDDLjbzJDbFvxcQ.jpeg" /><figcaption>Figure 5. Number of Users based on Smoker Category</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*HYrily6Y1REatk8uHi8uLQ.jpeg" /><figcaption>Figure 6. Number of Users based on Sex/Smoker Category</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*AvmP4Vvnw2xXDtJpSrmdUw.png" /><figcaption>Figure 7. Summary Table of Smoker and Nonsmoker Proportions</figcaption></figure><p>From total users, 80% are nonsmoker while 20% are smoker. Then, we want to compare the probability of female who is smoker and male who is smoker. We calculate this using conditional probability using the formula below:</p><p>p (A | B) = p (A ∩ B) / p (B)</p><p>Then from the data we calculate:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*t394wCJxNaTcvcvGCgMaog.png" /><figcaption>Figure 8. Conditional Probability for Female and Male Given The User Is Smoker</figcaption></figure><p>From this calculations, we can conclude that it is more likely the smoker to be a male than female. We can also conclude that from the 20% of total users who is a smoker, number of male who is smoker is higher than female who is a smoker. From the previous table, we know that smoker has higher charges than nonsmoker. So, we can infer, comparing the gender, male category has higher probability to pay more charge than female category. (Even though, from the data, the maximum charge is from female user, we want to compare between the gender category, not the user who has maximum charge).</p><p><strong>Comparison among Region</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*qkEL_81Ffmr-IIyZD3kccQ.png" /><figcaption>Figure 9. Comparison of Number of Users among Regions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*T68WHDGqEfPy18OPdH90LA.png" /><figcaption>Figure 9. Comparison of Number of Users among Regions based on Smoker Category</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*j4rNmui_2qaXzpzQzxeSAA.jpeg" /><figcaption>Figure 10. Comparison among Regions</figcaption></figure><p>Based on the data, the number of users among regions are similar, except Southeast which has most users in total and most smokers in total. Southeast region also has the highest mean charge among all regions. The two aspects, number of smokers and mean charge probably has correlations and since Southeast region has high number of smokers, it probably drive the mean charges value higher too.</p><p><strong>Key takeaways:</strong></p><p>1. Nonsmoker users has higher proportion (80%) than smoker users (20%)<br>2. Male has higher probability to have highest charge<br>3. The probability of a female given the user is a smoker is 42%<br>4. The probability of a male given the user is a smoker is 58%<br>5. The probability distribution of charge in Southeast is the highest (28%), followed by Northeast (25%), and Northwest and Southwest (23%)<br>6. Each region have users’ proportion equal to each other, except Southeast has the highest proportion (27%)</p><h4>III. Continuous Variable Analysis</h4><p>In this continuous variable analysis, we want to analyze and compare 3 comparisons as mentioned in the research question section above.</p><p>First, we want to analyze which one is more likely to happen:<br>a. A user has BMI above 25 if they receive charges above 16.7k,<br>or<br>b. A user has BMI below 25 they receive charges above 16.7k</p><p>From the data, we summarize into the BMI and charges category then we got Figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*l2WsIGBfm93IBmYEu8mEYw.png" /><figcaption>Figure 11. Number of Users based on BMI and Charges Category</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*3u_IajUN-bxC96y-0VSM-A.png" /><figcaption>Figure 12. Number of Users based on BMI/Charges</figcaption></figure><p>Then, we calculate the probability of a user whose BMI above 25 receives a charges above 16.7k using conditional probability, here’s the summary of the calculations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*nS0sHSX1f6EYKU9-BJjPcw.png" /><figcaption>Figure 13. Conditional Probability of a User whose BMI above or below 25 Given the Charges above 16700 USD</figcaption></figure><p>From the calculations, the probability of someone will have BMI above 25 given they receive charges above 16,700 is 0.85, meanwhile the probability of someone have BMI below 25 given they receive charges above 16,700 is 0.15. From this, we can see, if there is a user who receive charges above 16,700, it is more likely that the user will have BMI above 25 (the probability is 85%) than have BMI below 25 (the probability is only 15%).</p><p>For the second question, we want to know which one is more likely to happen:<br>a. A user whose BMI below 25 will receive charges above 16.7k,<br>or<br>b. A user whose BMI below 25 will receive charges below 16.7k</p><p>Using the same data from Figure 12, we can calculate using conditional probability. Here is the summary of the calculation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*qevWTUhEcBEkwnnsFgGUGQ.png" /><figcaption>Figure 14. Conditional Probability of User who has Charges above or below 16700 USD given the user’s BMI below 25</figcaption></figure><p>From the calculation above, the probability of a user will receive charge below 16700 given the user’s BMI is below 25 is more likely (the probability of 79%) than the probability of a user will receive charge above 16700 given the same BMI condition (probability is 21%).</p><p>For the third question, we want to compare which one is more likely to happen between:<br>a. A smoker whose BMI above 25 receives charges above 16.7k,<br>or<br>b. A nonsmoker whose BMI above 25 receives charges above 16.7k</p><p>First, we summarize the number of users based on the variable we will be calculating:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*vq4Yc02SLALS15ZTvOrxaA.png" /><figcaption>Figure 15. Number of Users based on Smoker/BMI/Charge Category</figcaption></figure><p>Then, we calculate the probability of a smoker whose BMI above 25 will receives charges above 16.7k and anonsmoker whose BMI above 25 receives charges above 16.7k. Here’s the summary of the calculations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*HOFA2H_l6PA9ei9gs9KiDA.png" /><figcaption>Figure 16. Conditional Probability of a User has Charges above or below 16700 USD given the User is Smoker and has BMI above 25</figcaption></figure><p>From the table above, we can compare, smoker whose BMI above 25 will be more likely to be charged above 16700 (the probability is 98%).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*n7jKfOqYaqXJTg0fzUkjFQ.png" /><figcaption>Figure 17. Conditional Probability of a User has Charges above 16700 USD given the User is a Nonsmoker and has BMI above 25</figcaption></figure><p>From the table above, a nonsmoker whose BMI above 25 will be more likely to be charged below 16700 (the probability is 92%).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*ZG7qfWOa4lgC6Qqjp-59Zw.png" /><figcaption>Figure 18. Conditional Probability of a User has Charges above 16700 USD given the User is Smoker and has BMI above 25 or given the User is Nonsmoker and has BMI above 25</figcaption></figure><p>If we compare the smoker and nonsmoker whose both BMI above 25, it is more likely that the smoker with BMI above 25 will have charge above 16700 (the probability is 98%) than the nonsmoker with BMI above 25 will have charge above 16700 (the probability is 8%). We can infer if a user has the same BMI category (above 25), the smoker status will have tremendous influence to determine whether the user will have charge above 16700 or not.</p><p><strong>Key Takeaways:</strong></p><ol><li>A user has BMI above 25 if they receive charges above 16.7k is more likely to happen (the probability is 85%) compared to a user has BMI below 25 they receive charges above 16.7k (probability is 15%). It means a user who receive charges above 16.7k is more likely to have BMI above 25 than to have BMI below 25.</li><li>A user whose BMI below 25 is more likely will receive charges below 16.7k (the probability is 79%) than receive charges above 16.7k (the probability is 21%). It means if a user’s BMI below 25, they are more likely to receive charges below 16.7k than above 16.7k.</li><li>A smoker whose BMI above 25 is more likely to receive charges above 16.7k (the probability is 98%) than a nonsmoker whose BMI above 25 (the probability is 8%). It means if a user has BMI above 25, their smoker/nonsmoker status will have tremendous influence to determine whether the user will have charge above 16700 or not.</li></ol><h4>IV. Variable Correlation Analysis</h4><p>Next, we want to know the correlation of variable of BMI, age, and number of children with charges. Below is the correlation graphs and correlation values of the mentioned variables with charges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNb7tzeFGeDtZJpC1dzRHA.jpeg" /><figcaption>Figure 19. Correlation Graph and Value between BMI and Charges</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xl2EdKk76fakIHWH8PfZgA.jpeg" /><figcaption>Figure 20. Correlation Graph and Value between Age and Charges</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XhYfJNKXD2CdBMAonYKUrg.jpeg" /><figcaption>Figure 21. Correlation Graph and Value between Number of Children and Charges</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*Vnn5WwW8ZLtrKqAEs5DB0w.png" /><figcaption>Figure 22. Summary Table of Correlation Value</figcaption></figure><p>From the processed data above, we can conclude that there is a positive correlation between BMI and charges, age and charges, and number of children and charges. Positive correlation means in correlated data, the change in the magnitude of one variable is associated with a change in the magnitude of another variable, in the same direction (where one increases, the other will also increase or where one decreases, the other will also decrease). In other words, if the value of BMI, age, and number of children increasing, it will followed by the increasing value of charges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yde1qVj7T9KU9wQsgz2KYw.jpeg" /><figcaption>Figure 23. The Interpretation of Correlation Coefficient (Source: <a href="https://journals.lww.com/anesthesia-analgesia/fulltext/2018/05000/correlation_coefficients__appropriate_use_and.50.aspx">https://journals.lww.com/anesthesia-analgesia/fulltext/2018/05000/correlation_coefficients__appropriate_use_and.50.aspx</a>)</figcaption></figure><p>However, although the correlation is positive, according to the reference, the correlation between BMI and charge and between age and charge is weak, whereas the correlation between number of children and charge is negligible. It means, in the most data points we have, where one variable increases, the other variable will increse but not necessarily with the same increment rate or in other word, in a weak and unreliable manner.</p><p>Next, we want to analyze how is distribution of charge each based on smoker, sex, bmi and region category.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*7GikLeLF_XA0NCozxySI3Q.jpeg" /><figcaption>Figure 24. Charge Distribution based on Smoker Category</figcaption></figure><p>Based on the Figure 24 above, we can compare the charge distribution based on smoker category. Smoker has higher median meaning charges received by users who smoke is, in average, higher than nonsmoker. Smoker also has wider variance meaning the range difference of charge value is wider. Both category has right-skewed shape of distribution. In nonsmoker category we can see several data as outliers (outside the interquartile range) higher than 1.5 times of Q2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*S3bT_0dhYuNFr-0gZhcpEQ.jpeg" /><figcaption>Figure 25. Charge Distribution based on Sex Category</figcaption></figure><p>Based on the Figure 25 above, we can compare the charge distribution based on sex category. We can see both female and male category have right-skewed distributions. The median of both female and male are similar with male having wider variance of charge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*2XuKKX-PKm5yreyWW_G0hw.jpeg" /><figcaption>Figure 26. Charge Distribution based on Region</figcaption></figure><p>Based on the Figure 26, we can see every region has right-skewed distributions. The median is similar among region. The variance are similar except the Southeast region which variance are the most wide.</p><p><strong>Key takeaways:</strong></p><p>1. The correlation value between BMI and charges is 0.198, between age and charges is 0.298 and number of children and charges is 0.067. The correlation is positive but the value is so low that it is considered to have a weak correlation (for BMI — charges and age — charges relationship) and even negligible (for children — charges relationship).<br> 2. The distribution of charge based on smoker, sex, BMI and region category is different for each. Smoker has higher median and higher variance than nonsmoker. Male has similar median but slightly higher variance than female. Each region has similar median but Southeast region has the highest variance.</p><h4>V. Hypothesis Testing</h4><p>Hypothesis testing in statistics is a way for you to test the results of a survey or experiment to see if you have meaningful results. You’re basically testing whether your results are valid by figuring out the odds that your results have happened by chance. If your results may have happened by chance, the experiment won’t be repeatable and so has little use.</p><p>In this section, we want to analyze 3 hypothesis.</p><p>First, we want to analyze whether or not smoker users have higher charges than nonsmoker.</p><p>Step one, we state the H0 and H1.</p><p>H0: μ smoker <strong>≤ </strong>μ nonsmoker<br>H1: μ smoker &gt; μ nonsmoker</p><p>Then, using Data Analysis Tools in Excel, we compare the data of charges between smoker and nonsmoker. The test we use is t-Test and since we already knew that the variance between smoker and nonsmoker variable is different, we chose t-Test: Two- Sample Assuming Unequal Variances. Since we are looking for the value that is “greater than” other value, we will use one-tail test. The result table shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*I2Sy9Lepn2AHSlR0O_bAtg.jpeg" /><figcaption>Figure 27. Hypothesis Testing for Case 1</figcaption></figure><p>From the table above, we can see the Pvalue (2.79E-103) is less than 0.05. Therefore, it is significant enough to reject the null hypothesis and it is sufficient evidence to state that the charge of smokers is higher than nonsmokers.</p><p>Second, we want to analyze whether or not users whose BMI above 25 have higher charges than users whose BMI below 25.</p><p>We state the H0 and H1.</p><p>H0: μ BMI&gt;25 <strong>≤ </strong>μ BMI≤25<br>H1: μ BMI&gt;25 &gt; μ BMI≤25</p><p>Using the same methods like the previous case above, the result table shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*KYeULv1Cedw6XJCih6z8OA.jpeg" /><figcaption>Figure 28. Hypothesis Testing for Case 2</figcaption></figure><p>From the table above, we can see the Pvalue (4.3245E-272) is also less than 0.05. Therefore, it is significant enough to reject the null hypothesis and it is sufficient evidence to state that users whose BMI above 25 have higher charges than users whose BMI below 25.</p><p>Last, we want to analyze whether or not male users have higher charges than female.</p><p>We state the H0 and H1.</p><p>H0: μ male <strong>≤ </strong>μ female<br>H1: μ male &gt; μ female</p><p>Using the same methods like the previous case above, the result table shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*AZlovi-Z-I9tyzLIBoJyQg.jpeg" /><figcaption>Figure 29. Hypothesis Testing for Case 3</figcaption></figure><p>From the table above, we can see the Pvalue (0.0358) is also less than 0.05. Therefore, it is significant enough to reject the null hypothesis and it is sufficient evidence to state that male users has higher charge than female.</p><p><strong>Key takeaways:</strong></p><p>From the hypothesis testing using Data Analysis Tool in Excel and by using one-tail t-test assuming unequal variances, we can conclude:<br>1. Smoker users have higher charges than nonsmoker<br>2. Users whose BMI above 25 have higher charges than users whose BMI below 25<br>3. Male users have higher charges than female</p><h4>CONCLUSION</h4><p>Here are the conclusion we get from the analysis:</p><p><strong>I. Descriptive Statistic Analysis<br></strong>1. Average age of users is 39 years old<br>2. There is not much average age difference between female and male category, both around 38–39 years old.<br>3. The average of BMI value of users who smoke is 30.71<br>4. Comparing male and female, in average, male has slightly higher BMI (30.94) than female (30.38)<br>5. Comparing smoker and nonsmoker, in average, smoker has slightly higher BMI (30.71) than nonsmoker (30.65)<br>6. The variance of charges value is not the same same for smoker and nonsmoker, where smoker has higher variance (11,542 USD) compared to nonsmoker (5,994 USD). <br>7. Comparing smoker and nonsmoker, smoker has higher average of charge (32,050 USD) than nonsmoker (8,434 USD)<br>8. Comparing a smoker whose BMI above 25 or nonsmoker whose BMI above 25, a smoker whose BMI above 25 has higher average of charge (35,117 USD) which is almost 4.5 times higher than a nonsmoker whose BMI above 25 (8,630 USD).</p><p><strong>II. Categorical Variable Analysis<br></strong>1. Nonsmoker users has higher proportion (80%) than smoker users (20%)<br>2. Male has higher probability to have highest charge<br>3. The probability of a female given the user is a smoker is 42%<br>4. The probability of a male given the user is a smoker is 58%<br>5. The probability distribution of charge in Southeast is the highest (28%), followed by Northeast (25%), and Northwest and Southwest (23%)<br>6. Each region have users’ proportion equal to each other, except Southeast has the highest proportion (27%)</p><p><strong>III. Continuous Variable Analysis</strong></p><ol><li>A user has BMI above 25 if they receive charges above 16.7k is more likely to happen (the probability is 85%) compared to a user has BMI below 25 they receive charges above 16.7k (probability is 15%). It means a user who receive charges above 16.7k is more likely to have BMI above 25 than to have BMI below 25.</li><li>A user whose BMI below 25 is more likely will receive charges below 16.7k (the probability is 79%) than receive charges above 16.7k (the probability is 21%). It means if a user’s BMI below 25, they are more likely to receive charges below 16.7k than above 16.7k.</li><li>A smoker whose BMI above 25 is more likely to receive charges above 16.7k (the probability is 98%) than a nonsmoker whose BMI above 25 (the probability is 8%). It means if a user has BMI above 25, their smoker/nonsmoker status will have tremendous influence to determine whether the user will have charge above 16700 or not.</li></ol><p><strong>IV. Variable Correlation Analysis</strong></p><ol><li>The correlation value between BMI and charges is 0.198, between age and charges is 0.298 and number of children and charges is 0.067. The correlation is positive but the value is so low that it is considered to have a weak correlation (for BMI — charges and age — charges relationship) and even negligible (for children — charges relationship).</li><li>The distribution of charge based on smoker, sex, BMI and region category is different for each. Smoker has higher median and higher variance than nonsmoker. Male has similar median but slightly higher variance than female. Each region has similar median but Southeast region has the highest variance.</li></ol><p><strong>IV. Hypothesis Testing</strong></p><p>From the hypothesis testing using Data Analysis Tool in Excel and by using one-tail t-test assuming unequal variances, we can conclude:<br>1. Smoker users have higher charges than nonsmoker<br>2. Users whose BMI above 25 have higher charges than users whose BMI below 25<br>3. Male users have higher charges than female</p><h4>FURTHER RESEARCH</h4><p>Further research can be conducted to understand the relationship between charges and other variables that are not included here but could also be important to determine the users’ charges, such as pre-existing illness, medical history, users’ lifestyle, and other similar variables.</p><h4>REFERENCE</h4><ul><li><a href="https://journals.lww.com/anesthesia-analgesia/fulltext/2018/05000/correlation_coefficients__appropriate_use_and.50.aspx">Correlation Coefficients: Appropriate Use and Interpretation : Anesthesia &amp; Analgesia</a></li><li><a href="https://www.statology.org/what-is-a-weak-correlation/">What is Considered to Be a &quot;Weak&quot; Correlation?</a></li></ul><p><a href="https://statisticsbyjim.com/basics/skewed-distribution/">https://statisticsbyjim.com/basics/skewed-distribution/</a></p><ul><li><a href="https://www.statology.org/hypothesis-testing-excel/">The Complete Guide: Hypothesis Testing in Excel - Statology</a></li><li><a href="https://www.statology.org/two-sample-t-test-excel/">How to Conduct a Two Sample t-Test in Excel - Statology</a></li><li><a href="https://www.statisticshowto.com/probability-and-statistics/hypothesis-testing/">Hypothesis Testing</a></li><li><a href="https://stats.oarc.ucla.edu/other/mult-pkg/faq/general/faq-what-are-the-differences-between-one-tailed-and-two-tailed-tests/">FAQ: What are the differences between one-tailed and two-tailed tests?</a></li></ul><p>For this case study, you can access the Excel File <a href="https://drive.google.com/drive/u/2/folders/1AgyhWq5eOYZ3Ckhh5A98Ua-b5jNwI3Vv">here</a> and explore the Tableau dashboard <a href="https://public.tableau.com/app/profile/kinan6437/viz/HealthInsuranceCaseStudy/Dashboard1">here</a>.</p><p>Let’s connect!</p><p>LinkedIn: <a href="https://www.linkedin.com/in/kinanti-nabilah-76879522a/">Kinanti Nabilah</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d622f5245941" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Case Study: Survival and Cohort Analysis]]></title>
            <link>https://medium.com/@kinantinabilah.ichnar/case-study-survival-and-cohort-analysis-c5fef5dcddb3?source=rss-3afb7379619------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5fef5dcddb3</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[survival-analysis]]></category>
            <category><![CDATA[cohort-analysis]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Kinanti Nabilah]]></dc:creator>
            <pubDate>Sun, 30 Oct 2022 16:01:50 GMT</pubDate>
            <atom:updated>2022-10-30T16:01:50.125Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Survival analysis</strong> is a branch of statistics for analyzing the expected duration of time until one event occurs or also known as time to event analysis. While <strong>cohort analysis is</strong> comparison of survival analysis between two groups.</p><p>In this post, I will explain step by step and result analysis from survival and cohort case study of SaaS (Software as a Service) customers. The dataset used is from Pacmann Course Intro to Data &amp; Analytics: Cohort Analysis with format as CSV titled Customer Subscription Data and can be accesed from <a href="https://drive.google.com/drive/folders/12Rjub0tSKOC9vET8PkhVshU-BFcYki0o">here</a>.</p><p>The goal of doing survival analysis is that we want to know the company software’s capabilities to retain customer and to be able to present an analysis whether the campaign is effective or whether the effort can be improved to engange more customers. Meanwhile, the goal of doing cohort analysis is that we want to know the comparison between two groups so we might understand whether the apps or the campaign engange or affect one particular group more or not.</p><h3><strong>Survival Analysis</strong></h3><p>This dataset contains 10.000 rows. Below is the data we will be working on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*U3J95itf5mMLYyI_mzuREg.jpeg" /><figcaption>Customer Subscription Data Dataset</figcaption></figure><p>The dataset consists of the following columns:</p><p><strong>case_id</strong> = unique case id<br><strong>date_time</strong> = time when the data was captured (format month/date/year)<br><strong>customer_id</strong> = unique customer id<br><strong>channel</strong> = media used to subscribe, whether by phone or email<br><strong>reason</strong> = customer subscription status. sign up for new customer and support is for recurring customer or the customer who continue their subscription from the previous month<br><strong>age</strong> = age of customer<br><strong>gender</strong> = gender of customer<br><strong>product</strong> = type of product. in this case we only use prd_2 where it is a product that paid monthly<br><strong>signup_date_time</strong> = registration date<br><strong>cancel_date_time</strong> = cancel/unsubscribe date<br><strong>price</strong> = fee paid monthly by customer</p><p>Based on that initial data, we then add several columns for calculation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*0uOSygbsN27TCmvOusEavA.png" /><figcaption>Additional Column for Calculation</figcaption></figure><p><strong>cohort_group</strong> = to extract month and year from date_time for categorizing customers<br><strong>censored</strong> = conditional variable to compare cohort_group (or date_time) vs cancel_date_time. This variable is used because we want to know whether the customer cancel their subscription before our study ends (as date_time) or if they still continue their subscription even after our study ends. If date_time ≥ cancel_date_time then censored is true hence value of censored = 1 else censored = 0. The value of date_time ≥ cancel_date_time can happen if:<br> 1. case 1: the cancel_date_time value is smaller meaning it happened before we captured the data which means the particular customer is no longer subscribing (already cancel the subscription.) or<br> 2. case 2: the value of cancel_date_time is null meaning we do not have sufficient information whether the customer still subscribing or already canceled. This counts as data customer loss or customer drop out. Both case categorized as censored data (censored = 1).<br><strong>age_from_signup</strong> = gap between signup_date_time to date_time<br><strong>age_to_canceled</strong> = conditional variable to determine whether the customer cancel their subscription before date_time captured or counted as data loss. The formula used is: IF(AND(M2=1,B2≥J2,J2&gt;0),ROUND((J2-I2)/30,0),N2). From previous variable (<strong>censored</strong>)<strong> </strong>we know that there are two explanation if the censored value is equal 1.<br> 1. case 1: The customer already unsubscribed or<br> 2. case 2: the data is loss.<br>In this age_to_canceled variable/column we would like to distinguish customers based on those 2 cases.<br> 1. If censored = 1 <em>and</em> date_time ≥ cancel_date_time <em>where</em> cancel_date_time &gt; 0 (the data is not null or categorized as case 2) then we calculate age_to_canceled as cancel_date_time minus signup_date_time.<br> 2.If that conditions is not met which is where the censored = 1 but the data is null (case 1) then age_to_canceled = age_from_sign_up which means the age is from sign_up_date_time to date_time where the data is captured hence the customer considered still subscribing until the data is captured.<br><strong>cohort_age</strong> = to take the minimum value between age_from_signup and age_to_canceled</p><p>After completing all the columns, we summarize the data by making a pivot table where cohort_group as rows, cohort_age as column, with the values of count customer_id. Then, displaying data as months and years. We also set the table display by clicking “Do not show subtotals” then “Show in Tabular form”. Here’s the result of our pivot table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*21GOKhzeW8grXZnSXrUS0w.jpeg" /><figcaption>Pivot table</figcaption></figure><p>We copied the value of the pivot table into different sheet titled “survival” then added column “obs_group” defined as ‘=Years&amp;” : “ &amp;cohort_group’ so the result will be Years : month. This column made it easier to read the data. Then we proceed to count the survival analysis.</p><p>In the “survival” sheet, the copied pivot table is our <em>Number of user loss table</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*xTm0HYaZCosJLIXTls8oLQ.png" /><figcaption>Number of loss table</figcaption></figure><p>We calculate the user profile by calculating the difference between initial number of user and user on month 0 put it in the respective cell, then the difference between user on month 0 and month 1, and so on so we get the <em>User profile table</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*7S5c8fvsyYM22_UWl05rgg.png" /><figcaption>User profile table</figcaption></figure><p>As you can see, as it goes to the right, the numbers keep decreasing because we calculated the cumulative number of users that still using the apps service. After that, we calculate <em>retention rate per month</em>. Basically, this calcuations turning the user profile table into percentage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*3WvZi73YgI6MWvvszT8oBw.jpeg" /><figcaption>Retention rate per month</figcaption></figure><p>Since we want to know the cumulative retention rate (retention rate from the previous month’s customers), we then calculate <em>retention rate through period</em> by multiplying percentage on particular cell (percentage of retention rate on particular month) with the previous cell (percentage of retention rate on previous month). Then adding conditional formatting so that we can see the pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5uFgSfLQet4T-iQQFEJUEg.jpeg" /><figcaption>Retention rate through period</figcaption></figure><p>We can also calculate the <em>incremental churn per period</em> to know the reduction of number of customer per month. This basically calculating the difference between cumulative this month customer and last month customer as percentage. We can get incremental churn value by processing the data from <em>Retention rate per month </em>table. Then we get <em>Incremental churn per period table</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ab8rollzRGck2ayYfWtNyw.png" /><figcaption>Incremental churn per period</figcaption></figure><p>From the data we can also calculate total, average, and net revenue per user using percentage of retention rate through period. In this case, we assume the monthly fee is $10 per user and marketing acquisition that the company spends per user is $2. Knowing that, we can calculate the net revenue per user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*iDADPSMLdlCYedZY11S7aQ.jpeg" /><figcaption>Net revenue per user</figcaption></figure><h3><strong>Analysis on Survival Analysis Calculations</strong></h3><p>Based on the data above, we can conclude that churn percentage is the highest on month 0. This could mean that the campaign is actually working as it attracted many customers as seen from the high number of customer subscribing to the apps at the first place. But on the other side, the campaign only last for a short time and the campaign can no longer retain that many customers.</p><p>When the campaign is no longer used (such as free trial for a month campaign), the customer did not want to extend their subscription anymore. There could be many things influencing the customer’s decision such as they are not really accustomed to the apps, or it could be because they are not sure whether the benefit they gain is worth it despite the paid fee, or it could be that they only want to try the free trial at the first place, or it could be they feel the fee that has to be paid is expensive, and many other possible reasons. To really understand the reason, further study through survey or FGD might have to be conducted.</p><p>But on the other hand, when we get the customer using our apps pass the trial period, we can see that the decrease is not as steep as month 0, which means when the customer is already comfortable and accustomed to the apps and can gain benefit of using the apps, they relatively tend to keep subscribing.</p><h3>Cohort Analysis</h3><p>In this cohort analysis, we want to understand whether there is difference between male customers and female customers. To calculate this, we first use the pivot table to filter the data by gender then extract the data. Once the particular data based on gender are extracted, we can repeat the steps above to calculate survival analysis (<em>retention rate through period</em>) for each gender then compare both results.</p><p>From the calculations we get these two tables</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ew6ZKwS2jfrk2-OgbkQwdg.jpeg" /><figcaption>Retention rate through period for male category</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KI1S-m29GL1bW_KEzSex4Q.png" /><figcaption>Retention rate through period for female category</figcaption></figure><p>From both tables, we summarize the average rate value into one <em>comparison table</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WC8rrBNGp9uLnV-yK0U-7Q.jpeg" /><figcaption>Comparison table of retention rate through period for male and female category</figcaption></figure><p>We then make cohort graph from comparison table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*EzhmLbZdc5GSSvXFIgnRmg.jpeg" /><figcaption>Cohort Graph between Female Group and Male Group</figcaption></figure><p>From the cohort graph above, the difference is not that significant so for analysis it’s best to analyze based on percentage number on the table. From the <em>comparison table</em> above, we can see that the male category in total is more in favor of using the apps than female category. This can be seen by comparing the values between the age from month 0 to month 7. Although, after month 7, we can see the retention rate difference is not that significant. Keep in mind that we also might have to pay attention to the difference number of user (not just comparing the percentage but their true numbers) to avoid bias but since the number difference is also not much different (total female is 4403 users and total male is 5597 users), we can compare the percentage as shown on the table above.</p><p>From the data we can also calculate and compare the revenue from each gender category. Using the same method as above, we get the result of revenue calculations for both genders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*2GckLittwoBLZ6wfWwAoJw.jpeg" /><figcaption>Net revenue per user for female category</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*zAfK_KU9_kvWzVcRUJwhBQ.jpeg" /><figcaption>Net revenue per user for male category</figcaption></figure><p>As we can see, the male category generate more revenue than female category since the retention rate is higher than female. From this insights, it can also helps the company to decide whether they want to focus the campaign more on the male category to make the retention rate even higher or creating a campaign to attract more female customers.</p><h3>Conclusions</h3><p>Using survival analysis we can calculate customer retention rate then using cohort analysis we can compare survival analysis between two categories. In this case study, we use survival analysis to calculate then see the pattern of customer retention then we use cohort analysis to compare retention rate between female group and male group. If the data is available, we can also calculate revenue and compare the revenue generated by each customer category.</p><p>For this case study, you can download the file and explore more <a href="https://drive.google.com/drive/folders/1nKDxpsUtq1WFgGv-O0MrAbIGybfoabs8?hl=id">here.</a></p><p>Let’s Connect!</p><p>Linkedin: <a href="https://www.linkedin.com/in/kinanti-nabilah-76879522a/">Kinanti Nabilah</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5fef5dcddb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>