<?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 Jammal Adeyemi on Medium]]></title>
        <description><![CDATA[Stories by Jammal Adeyemi on Medium]]></description>
        <link>https://medium.com/@Jammaladeyemi?source=rss-dd7d2ad11f3b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Efj1V5H5cXFKsX-0QEx9WQ.jpeg</url>
            <title>Stories by Jammal Adeyemi on Medium</title>
            <link>https://medium.com/@Jammaladeyemi?source=rss-dd7d2ad11f3b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:17:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Jammaladeyemi/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[Unveiling Insights from Amazon Employee Reviews: A Deep Dive into Sentiment Analysis and Topic…]]></title>
            <link>https://medium.com/@Jammaladeyemi/unveiling-insights-from-amazon-employee-reviews-a-deep-dive-into-sentiment-analysis-and-topic-8526770b240f?source=rss-dd7d2ad11f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8526770b240f</guid>
            <category><![CDATA[employee-engagement]]></category>
            <category><![CDATA[hr]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[topic-modeling]]></category>
            <dc:creator><![CDATA[Jammal Adeyemi]]></dc:creator>
            <pubDate>Tue, 05 Sep 2023 12:15:45 GMT</pubDate>
            <atom:updated>2023-09-05T12:15:45.833Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unveiling Insights from Amazon Employee Reviews: A Deep Dive into Sentiment Analysis and Topic Modeling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nh1kO-7lXqLh7sTdgBUm_A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jasongoodman_youxventures?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jason Goodman</a> on <a href="https://unsplash.com/photos/Oalh2MojUuk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In the age of e-commerce giants, understanding employee sentiments can be as crucial as deciphering customer preferences. With vast datasets at our disposal, we stand at the brink of a data-driven revolution. Today, we embark on a journey into the world of Amazon Employee Reviews, armed with the task of developing a system that can unravel the intricate tapestry of emotions and topics hidden within.</p><h4><strong>A Brief Overview of the Task: Working on Amazon Employee Reviews Dataset</strong></h4><p>At the heart of this mission lies a dataset, “Amazon Jan 2023.csv,” waiting to reveal its tales of employee experiences, opinions, and perspectives. Our task is clear: to develop a system that can discern not only the positive, neutral and negative sentiments lurking within these comments but also to untangle the web of topics that occupy the thoughts and discussions of Amazon’s dedicated workforce.</p><h4>The Significance of Sentiment Analysis and Topic Modeling in the Corporate World</h4><p>Before we dive into the specifics of our endeavor, let’s pause to reflect on the broader significance of sentiment analysis and topic modeling in today’s corporate world. These two powerful tools have transformed the way organizations perceive and engage with their employees.</p><p><strong>Sentiment analysis </strong>is the art of decoding emotions from text, provides invaluable insights into employee morale, job satisfaction, and overall sentiment. It allows organizations to address concerns, boost employee engagement, and ultimately foster a more positive work environment.</p><p><strong>Topic modeling</strong>, on the other hand, goes beyond sentiment, helping organizations identify the key subjects that occupy the minds of their workforce. By understanding these topics, companies can tailor their strategies, policies, and communication to align with employee interests and concerns.</p><p>In the pages that follow, I will unravel the techniques and methodologies employed in sentiment analysis and topic modeling. We will witness firsthand the transformation of raw data into actionable insights, with each comment serving as a window into the collective consciousness of Amazon’s employees.</p><p>Join me on this enlightening journey as I navigate the Amazon Employee Reviews dataset, decode sentiments, and unveil the topics that shape the experiences of those who power one of the world’s leading e-commerce giants. Welcome to the intersection of data and corporate understanding.</p><h3>Data Understanding</h3><ol><li><strong>Installing Dependencies: </strong>To embark on this analytical journey, we first needed to ensure we had the necessary tools in our toolbox. We installed key dependencies, including bertopic and transformers, to facilitate our data analysis.</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fd4a623ab9d8a47109bf4f40f1a8f940e%3Fheight%3D119&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fd4a623ab9d8a47109bf4f40f1a8f940e%3Fheight%3D119&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="119" frameborder="0" scrolling="no"><a href="https://medium.com/media/5643fc14ff71a21e49bd79492d323450/href">https://medium.com/media/5643fc14ff71a21e49bd79492d323450/href</a></iframe><p>2. <strong>Importing Dependencies: </strong>Our analytical toolkit comprised an array of libraries, from data manipulation to natural language processing (NLP) and machine learning. Here’s a glimpse of some of the critical dependencies we imported:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F638afb7fd3bc4f64825b7524a16874be%3Fheight%3D605&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F638afb7fd3bc4f64825b7524a16874be%3Fheight%3D605&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="605" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9aef711012de155dfe402415514a80f/href">https://medium.com/media/b9aef711012de155dfe402415514a80f/href</a></iframe><p>3. <strong>Reading the Data</strong>: The cornerstone of our analysis was the Amazon Employee Reviews dataset, aptly named “Amazon Jan 2023.csv.” We loaded the dataset into our working environment for exploration:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F05f57044b0814879be3a1aeab08aa5b7%3Fheight%3D246&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F05f57044b0814879be3a1aeab08aa5b7%3Fheight%3D246&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/af21698bba0ab7ea40624e387f8a71e6/href">https://medium.com/media/af21698bba0ab7ea40624e387f8a71e6/href</a></iframe><p>4. <strong>Data Overview: </strong>Before delving into the data itself, we conducted a quick review to understand its structure:</p><ul><li>df.info(): This revealed that our dataset consisted of a single column, &quot;Comment,&quot; with data stored as objects and also shows that we have 99 rows.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fad75d3da04ce42c4a92a8f5603675466%3Fheight%3D266.5625&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fad75d3da04ce42c4a92a8f5603675466%3Fheight%3D266.5625&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="266" frameborder="0" scrolling="no"><a href="https://medium.com/media/3db39c49d3208b7ed61d80f1b00000e0/href">https://medium.com/media/3db39c49d3208b7ed61d80f1b00000e0/href</a></iframe><ul><li>No missing values were detected in our dataset, making it ready for analysis:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F65e4d09bccc94860b5f939ea0e7c9f68%3Fheight%3D171.390625&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F65e4d09bccc94860b5f939ea0e7c9f68%3Fheight%3D171.390625&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="171" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d2b9c4ab3ee145fa7360caab52785a0/href">https://medium.com/media/3d2b9c4ab3ee145fa7360caab52785a0/href</a></iframe><ul><li>Exploring a Data sample: To get a feel for the data, we peeked at random comments:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F10087a98f2ec4aee90bcd4363e5a89e2%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F10087a98f2ec4aee90bcd4363e5a89e2%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/deba1a57250f56f2c816ee95aec201e3/href">https://medium.com/media/deba1a57250f56f2c816ee95aec201e3/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Ff47e41c86eb7403d8ad82788fb1b23c5%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Ff47e41c86eb7403d8ad82788fb1b23c5%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6aae5465e450937829f43c4da6c8f0a/href">https://medium.com/media/b6aae5465e450937829f43c4da6c8f0a/href</a></iframe><p>With a firm foundation laid for our analysis, we were ready to dive into the world of sentiment analysis and topic modeling. Stay tuned as we unravel the hidden insights buried within Amazon Employee Reviews.</p><h3>Sentiment Analysis</h3><p>In our quest to decode the Amazon Employee Reviews dataset, we begin with the foundational concept of “sentiment analysis.” This powerful technique, also known as opinion mining, plays a pivotal role in understanding the emotional tone and context of text data. Let’s dive into the heart of sentiment analysis and explore why it’s a crucial component of our analysis.</p><p><strong>Understanding Sentiment Analysis<br></strong>Sentiment analysis is the art of harnessing the power of language to uncover the emotions, opinions, and attitudes expressed in text. At its core, it seeks to answer a fundamental question: Is the text expressing a positive, negative, or neutral sentiment?</p><ul><li><strong>Positive Sentiment</strong>: When a comment exudes positivity, it typically reflects satisfaction, contentment, or enthusiasm. In the context of Amazon Employee Reviews, positive sentiments could signal a happy and fulfilling work experience.</li><li><strong>Neutral Sentiment</strong>: A neutral sentiment implies a lack of strong emotion or opinion. These comments often fall into the realm of objective statements or straightforward descriptions, without leaning heavily towards positivity or negativity.</li><li><strong>Negative Sentiment</strong>: Conversely, negative sentiments convey dissatisfaction, disappointment, or criticism. In the dataset, these comments might highlight areas of concern or dissatisfaction with Amazon&#39;s work environment or policies.</li></ul><p><strong>The Importance of Sentiment Analysis<br></strong>Why is sentiment analysis so crucial, especially in the corporate world? Here are a few key reasons:</p><ol><li>Employee Engagement: Sentiment analysis can be a powerful tool for gauging employee engagement and job satisfaction. By analyzing employee feedback, organizations can identify areas for improvement and take proactive measures to enhance workplace conditions.</li><li>Customer-Centric Approach: For customer-centric businesses like Amazon, employee sentiment can have a direct impact on customer experiences. Satisfied employees are more likely to deliver exceptional service, which in turn benefits customers.</li><li>Risk Mitigation: Early detection of negative sentiments can help organizations address potential issues before they escalate. This proactive approach minimizes risks associated with employee turnover and disengagement.</li></ol><p>As we move forward in our analysis of Amazon Employee Reviews, sentiment analysis will serve as our compass, guiding us through the emotional landscape of employee feedback. With each comment, we’ll uncover the underlying sentiments that shape the narratives within the dataset.</p><h4><strong>Sentiment Analysis with RoBERTa: Unveiling Employee Sentiments</strong></h4><p>In the realm of Natural Language Processing (NLP), RoBERTa stands as a powerful ally, enabling us to extract sentiment insights from Amazon Employee Reviews with precision. Let’s dissect the code step by step to understand how this process unfolds.</p><ul><li><strong>Load Model and Tokenizer</strong>: Our journey begins by tapping into the capabilities of the “cardiffnlp/twitter-roberta-base-sentiment” model. To do this, we load both the model and its corresponding tokenizer, which will help us preprocess and analyze the text data:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F08f53a99cab74c87bdb35715d68d2904%3Fheight%3D261.4765625&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F08f53a99cab74c87bdb35715d68d2904%3Fheight%3D261.4765625&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="261" frameborder="0" scrolling="no"><a href="https://medium.com/media/73a9ace48f1921731470bb322951534a/href">https://medium.com/media/73a9ace48f1921731470bb322951534a/href</a></iframe><ul><li><strong>Generating Sentiment Scores</strong>: Now, we’re ready to dive into the heart of sentiment analysis. We define a function, polarity_scores_roberta(comment), which takes a comment as input and returns sentiment scores. These scores represent the likelihood of the comment falling into each sentiment category (Negative, Neutral, Positive).</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fe710b5fb71f3471d94d7a8610d166369%3Fheight%3D448&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fe710b5fb71f3471d94d7a8610d166369%3Fheight%3D448&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="448" frameborder="0" scrolling="no"><a href="https://medium.com/media/6eacd8fee16c99b7d8bfd7abaebbee21/href">https://medium.com/media/6eacd8fee16c99b7d8bfd7abaebbee21/href</a></iframe><blockquote>The code defines a function called ‘<strong>polarity_scores_roberta’</strong> that takes a comment as input. Within the function, the <strong>`tokenizer`</strong> is used to encode the <strong>`comment`</strong> and return the encoded tensor.<br>The <strong>`model` </strong>is then used to generate sentiment scores based on the encoded tensor. The function uses the model to get outputs, applies <strong>`softmax`</strong> function to the outputs along the specified axis, and then detaches the outputs as numpy array.</blockquote><ul><li><strong>Mapping Sentiment Labels</strong>: Next, we define a function, analyze_sentiment(comment), which takes a comment as input and returns the corresponding sentiment label (Negative, Neutral, Positive). Here&#39;s how it works:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fc2f8e03b2bc94a7fb388c6f9ba0c3dbb%3Fheight%3D592&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fc2f8e03b2bc94a7fb388c6f9ba0c3dbb%3Fheight%3D592&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="592" frameborder="0" scrolling="no"><a href="https://medium.com/media/56cd22758eba0f428bdff6efd78e5fd9/href">https://medium.com/media/56cd22758eba0f428bdff6efd78e5fd9/href</a></iframe><blockquote>The code first defines a function called <strong>`analyze_sentiment` </strong>that takes in a single comment as input. Inside the function, the comment is passed to a tokenizer along with some additional parameters. The tokenizer returns tokenized inputs that are suitable for input to the model.<br>Next, the model is called with the tokenized inputs and the <strong>`.logits`</strong> attribute is used to obtain the raw output scores. These scores are then used to determine the sentiment by comparing the index of the highest score with a condition. If the index is 1, the sentiment is considered <strong>`Neutral`</strong>. Otherwise, it is considered <strong>`Positive`</strong>.<br>The <strong>`analyze_sentiment`</strong> function returns the sentiment as the variable scores.</blockquote><p>With these functions in place, we’ve harnessed the power of RoBERTa to analyze employee sentiments in the Amazon Employee Reviews dataset. The “Sentiment” column in our data now provides clear insights into whether each comment expresses a Negative, Neutral, or Positive sentiment.</p><h4>Results</h4><p>After applying RoBERTa-based sentiment analysis to the Amazon Employee Reviews dataset, we were able to uncover the emotions and sentiments hidden within the comments. Let’s take a closer look at some of the results to gain a deeper understanding of our findings.</p><ul><li><strong>Positive Sentiment: </strong>In the world of employee reviews, positivity often reflects job satisfaction and contentment. Let’s examine a comment that was classified as “Positive” and explore the sentiment scores associated with it:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F3991efd9d41941098644ac376a8d57ec%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F3991efd9d41941098644ac376a8d57ec%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9fb3cd783a4d4052a3b89613eff2b19/href">https://medium.com/media/a9fb3cd783a4d4052a3b89613eff2b19/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F549c1ed306d742029a84fb12726987d8%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F549c1ed306d742029a84fb12726987d8%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/c006b2007c0b4a9cfbeef5bc04044d80/href">https://medium.com/media/c006b2007c0b4a9cfbeef5bc04044d80/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F56531d5c31ce40aa8f84052482d6af5b%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F56531d5c31ce40aa8f84052482d6af5b%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/877ba4fcda37508aa4a9020541acbb68/href">https://medium.com/media/877ba4fcda37508aa4a9020541acbb68/href</a></iframe><ul><li><strong>Neutral Sentiment</strong>: In the realm of employee feedback, neutrality often indicates a balanced and objective perspective. Let’s explore a comment classified as “Neutral” and delve into the sentiment scores associated with it:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fa58b1c510f6c474eacbd069f16f665f3%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fa58b1c510f6c474eacbd069f16f665f3%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/3800b46d4daaa4597cbc2f24cca13c71/href">https://medium.com/media/3800b46d4daaa4597cbc2f24cca13c71/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F8bfdfb3e211f4f4eac325f6bb6079e2c%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F8bfdfb3e211f4f4eac325f6bb6079e2c%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/5aecf8cba1b80d83c0bebbd26789f544/href">https://medium.com/media/5aecf8cba1b80d83c0bebbd26789f544/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F3ea78fe7c23646cf87f030237238fc18%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F3ea78fe7c23646cf87f030237238fc18%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/76c5d04667db4a66dc5a0bdcdacf2bbf/href">https://medium.com/media/76c5d04667db4a66dc5a0bdcdacf2bbf/href</a></iframe><ul><li><strong>Overall Sentiment Distribution</strong>: To gain a comprehensive overview of the sentiments expressed in the entire dataset, let’s take a glance at the sentiment distribution:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fc8c0a5acdd884e70ac8fd3bd25e52155%3Fheight%3D191.78125&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fc8c0a5acdd884e70ac8fd3bd25e52155%3Fheight%3D191.78125&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="191" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b8d27daf52126942b6ddc8ae9166add/href">https://medium.com/media/2b8d27daf52126942b6ddc8ae9166add/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F3ee7cb04510545c59ff6d69687a8925a%3Fheight%3D662&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F3ee7cb04510545c59ff6d69687a8925a%3Fheight%3D662&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="662" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b6e19486fc5624898e5349e9e442357/href">https://medium.com/media/7b6e19486fc5624898e5349e9e442357/href</a></iframe><p>One observation that stands out prominently is the significant volume of negative sentiments. As we delved into the dataset, we encountered a substantial number of comments expressing discontent and criticism. While Amazon’s reputation as an e-commerce giant is well-established, these negative sentiments serve as a reminder that even industry leaders must continuously strive to address concerns and create a supportive work environment.<br>The presence of negative sentiments should not be seen solely as a challenge but as an opportunity for growth and improvement. They provide organizations like Amazon with valuable feedback, highlighting areas that require attention. It’s essential to view these sentiments as constructive criticism, an invaluable resource for shaping a brighter future for both the company and its employees.</p><p>Our journey doesn’t end here. Armed with sentiment analysis, we’ll now venture into the realm of topic modeling, where we unravel the subjects that occupy the minds of Amazon’s dedicated employees. Stay tuned for the next chapter in our data-driven exploration.</p><h3>Topic Modeling</h3><p>In our quest to delve deeper into the Amazon Employee Reviews dataset, we&#39;ve ventured into the fascinating world of topic modeling. This technique allows us to uncover the underlying themes and subjects that occupy the minds of Amazon&#39;s dedicated employees. We explored two distinct approaches: Latent Semantic Analysis (LSA) and BERTopic, each offering unique insights into the dataset.</p><h4>What is Topic Modeling?</h4><p>At its core, topic modeling is a machine learning technique designed to uncover the underlying themes, subjects, or topics within a collection of text documents. It’s a data-driven approach that goes beyond simple keyword analysis, delving into the nuances of language to identify patterns and group related words and phrases into coherent themes.<br>Think of topic modeling as a magnifying glass for text data. It helps us unearth the latent structures within a corpus of documents, revealing the key discussions, ideas, or subjects that people are talking about. These topics are not predefined; they emerge organically from the data, making topic modeling a versatile tool for uncovering hidden insights.</p><h4>Why is it Valuable in Understanding Employee Feedback?</h4><p>Understanding employee feedback is a vital aspect of organizational development and growth. Employee sentiments and opinions can provide a treasure trove of insights that help companies enhance their work environment, policies, and overall employee satisfaction. This is where topic modeling steps in as an invaluable ally:</p><ul><li><strong>Uncovering Themes</strong>: Employee feedback is often a diverse mix of thoughts, concerns, and suggestions. Topic modeling helps us categorize this feedback into meaningful themes or topics. For example, it can reveal whether employees are discussing work-life balance, compensation, management, or other critical aspects of their experience.</li><li><strong>Quantifying Sentiments</strong>: Beyond identifying topics, topic modeling allows us to quantify the prevalence of each theme within the dataset. We can gauge the frequency and distribution of positive, negative, or neutral sentiments associated with each topic. This quantitative insight aids in prioritizing areas of improvement.</li><li><strong>Actionable Insights</strong>: By understanding the prevalent topics and sentiments, organizations can take concrete actions to address concerns and enhance positive aspects of the workplace. Whether it’s optimizing work hours, improving management practices, or enhancing benefits, topic modeling guides strategic decision-making.</li></ul><p>As we embark on our journey through topic modeling, we will witness firsthand how this technique transforms raw text data into structured insights, enabling us to navigate the intricate landscape of employee feedback within the Amazon Employee Reviews dataset.</p><h4>Preparing Text Data for Topic Modeling</h4><p>Before we can embark on our journey of uncovering topics within employee feedback, we need to ensure that our text data is in optimal shape for analysis. This entails a series of crucial preprocessing steps to clean and tokenize the text, making it ready for topic modeling.</p><p><strong>Cleaning and Tokenizing Text Data<br></strong>To prepare the text data, we’ve developed a comprehensive preprocessing function that performs the following key tasks:<br>1. <strong>Lowercasing</strong>: The text is converted to lowercase to ensure consistency and avoid case-related variations.<br>2. <strong>Punctuation Removal</strong>: Punctuation marks, which do not typically carry meaningful information, are removed. This step streamlines the text and ensures that punctuation doesn’t interfere with topic modeling.<br>3. <strong>Tokenization</strong>: We employ the TweetTokenizer, a specialized tokenizer, to split the text into individual words or tokens. Unlike standard tokenization methods, this tokenizer is well-suited for social media and informal text, capturing the nuances of language effectively.<br>4. <strong>Stopword Removal</strong>: Common stopwords such as “the,” “and,” “is,” and more are often filtered out. These words are frequently used but contribute little to the overall meaning of the text. We also extend this list with custom stopwords that are specific to our analysis.<br>5. <strong>Lemmatization</strong>: Lemmatization is applied to reduce words to their base forms. This ensures that words with different inflections (e.g., “running” and “ran”) are treated as the same word, reducing redundancy and aiding in topic identification.<br>6. <strong>Rejoining Tokens</strong>: After the cleaning and processing steps, the tokens are joined back together to form coherent, preprocessed text.</p><p>Now, let’s take a look at the code that implements these text preparation steps:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fe9b146478a224432bec4a636333695a0%3Fheight%3D713&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fe9b146478a224432bec4a636333695a0%3Fheight%3D713&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="713" frameborder="0" scrolling="no"><a href="https://medium.com/media/3af0344402add46b544aea2c0f77248f/href">https://medium.com/media/3af0344402add46b544aea2c0f77248f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F81cb99db38ec4dfa853ddc134dc28b26%3Fheight%3D322&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F81cb99db38ec4dfa853ddc134dc28b26%3Fheight%3D322&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="322" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc5616eceb1887e12ec6e271e12b9717/href">https://medium.com/media/dc5616eceb1887e12ec6e271e12b9717/href</a></iframe><p>With our text data now cleaned and tokenized into a more structured and coherent format, we’re well-equipped to proceed with our topic modeling endeavors. In the next sections, we’ll explore the intricacies of Latent Semantic Analysis (LSA) and BERTopic, which will help us unveil the thematic threads woven within Amazon’s employee reviews.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Ff56c4e27a41b4922b9da5b57b934f6df%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Ff56c4e27a41b4922b9da5b57b934f6df%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa7a08bc4064caaab64b9dee3eaa66ef/href">https://medium.com/media/aa7a08bc4064caaab64b9dee3eaa66ef/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F4c96ede6f75642e489a500c210f9ed70%3Fheight%3D134.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F4c96ede6f75642e489a500c210f9ed70%3Fheight%3D134.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="134" frameborder="0" scrolling="no"><a href="https://medium.com/media/3dd251f6eb09284680bc7fac2233f16a/href">https://medium.com/media/3dd251f6eb09284680bc7fac2233f16a/href</a></iframe><h4>Implementing Topic Modeling</h4><p>In this section, we will dive into the practical aspects of implementing topic modeling, a crucial step in unveiling the underlying themes and subjects within Amazon employee reviews. We’ll explore two powerful techniques: Latent Semantic Analysis (LSA) and BERTopic. Let’s get started.</p><p><strong>Topic Modeling using Latent Semantic Analysis (LSA)</strong></p><p><strong>Step 1: TF-IDF Vectorization<br></strong>Our journey begins with transforming the preprocessed text data into a numerical format suitable for LSA. We use TF-IDF (Term Frequency-Inverse Document Frequency) vectorization, a common choice for text analysis. Here’s how we did it:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fd19332a9c92a420e838bd86fc248c7c4%3Fheight%3D209&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fd19332a9c92a420e838bd86fc248c7c4%3Fheight%3D209&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="209" frameborder="0" scrolling="no"><a href="https://medium.com/media/88a294e2671a422223fd5f63d7d7d0c7/href">https://medium.com/media/88a294e2671a422223fd5f63d7d7d0c7/href</a></iframe><p><strong>Step 2: Finding Optimal K (Number of Topics)</strong><br>To determine the optimal number of topics (n_components), we employ the &quot;Explained Variance&quot; method. This involves calculating explained variances for a range of n_components values and plotting the results. The ideal n_components value is where the explained variance starts to level off or reaches a point of diminishing returns:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F15c33af5d39c4372a55c74f63089466a%3Fheight%3D876&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F15c33af5d39c4372a55c74f63089466a%3Fheight%3D876&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="876" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e9d3043ebfdea0f4512edd0c07a42ec/href">https://medium.com/media/4e9d3043ebfdea0f4512edd0c07a42ec/href</a></iframe><p>The graph helps us decide the optimal number of topics for LSA. The graph was kinda hard to decipher so we would tried different n_components to see what works</p><p><strong>Step 3: Applying LSA</strong><br>Now, we apply LSA with the chosen n_components to extract topics from the TF-IDF matrix. We also print the generated topics and their associated keywords:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F6360adf2c292465982620d9256991052%3Fheight%3D631.6484375&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F6360adf2c292465982620d9256991052%3Fheight%3D631.6484375&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="631" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ce6ab176499ee8195426bc507af1b12/href">https://medium.com/media/7ce6ab176499ee8195426bc507af1b12/href</a></iframe><p><strong>Step 4: Organizing Topic Assignments and Labeling</strong><br>To make the topic assignments more comprehensible and informative, we create a structured DataFrame that labels each review with its assigned topics based on the highest weight. Here’s how we achieve this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F9873bb0807e94004ab842815fd04f291%3Fheight%3D803&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F9873bb0807e94004ab842815fd04f291%3Fheight%3D803&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="803" frameborder="0" scrolling="no"><a href="https://medium.com/media/6590fd0c32736a7da03f82e7fd598168/href">https://medium.com/media/6590fd0c32736a7da03f82e7fd598168/href</a></iframe><p>While LSA has provided us with valuable insights by generating topics based on our initial assumption of the number of components, it’s essential to confirm and validate these topics using an alternative approach. To achieve this, we will turn to BERTopic.</p><p>In the next section, we will explore BERTopic, another robust topic modeling technique, to verify and potentially refine our topic assignments. This additional step will ensure the accuracy and reliability of our topic modeling results.</p><p><strong>Topic Modeling using BERTopic</strong></p><p>BERTopic leverages BERT (Bidirectional Encoder Representations from Transformers), a state-of-the-art language model, to generate rich contextual embeddings for words and documents. This enables BERTopic to capture intricate relationships and meanings within the text, resulting in more accurate topic assignments.<br>It integrates `UMAP` for dimensionality reduction, further enhancing its ability to visualize and interpret high-dimensional data. This combination of BERT-based embeddings and UMAP-driven visualization makes BERTopic a powerful choice for topic modeling tasks involving text data like comments, reviews, and articles.</p><p><strong>Step 1: UMAP Dimensionality Reduction and BERTopic<br></strong>For BERTopic, we begin by reducing the dimensionality of the text data using UMAP. Then, we apply the BERTopic model. Here’s how it’s done:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fa3b9347b096c458e8d55324ebce2161f%3Fheight%3D384.0859375&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fa3b9347b096c458e8d55324ebce2161f%3Fheight%3D384.0859375&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="384" frameborder="0" scrolling="no"><a href="https://medium.com/media/e54a069cbad9283d78ebc27ca18e0d51/href">https://medium.com/media/e54a069cbad9283d78ebc27ca18e0d51/href</a></iframe><p><strong>UMAP(Uniform Manifold Approximation and Projection)</strong> is a dimensionality reduction technique that’s often used in combination with `BERTopic` for visualization purposes. It’s used to reduce the high-dimensional vector representations generated by BERT embeddings into a lower-dimensional space while preserving the underlying structure of the data as much as possible.</p><p><strong>Step 2: Exploring Topics<br></strong>After applying BERTopic, we explore the extracted topics. We can visualize the top keywords for each topic and gain insights into the thematic content:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F8eebaf67f9e84007b2bb08d92733e747%3Fheight%3D257&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F8eebaf67f9e84007b2bb08d92733e747%3Fheight%3D257&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="257" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1dbe85ec2ddcb76c30922cb25d1a412/href">https://medium.com/media/e1dbe85ec2ddcb76c30922cb25d1a412/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F1a0976c6f335436bb36a9d028f3b5b8a%3Fheight%3D324.953125&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F1a0976c6f335436bb36a9d028f3b5b8a%3Fheight%3D324.953125&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="324" frameborder="0" scrolling="no"><a href="https://medium.com/media/59110d3c8a94751ddd63d4c900ae9c4e/href">https://medium.com/media/59110d3c8a94751ddd63d4c900ae9c4e/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F31ef4347f42947eaa2087f3b55b10831%3Fheight%3D324.953125&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2F31ef4347f42947eaa2087f3b55b10831%3Fheight%3D324.953125&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="324" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fb997d920d9bfc4a7c3b8c56abd5d3c/href">https://medium.com/media/9fb997d920d9bfc4a7c3b8c56abd5d3c/href</a></iframe><p><strong>Step 4: Topic Assignments and Selection</strong><br>After successfully applying BERTopic, we proceed to assign topics to each review and select the most relevant columns for analysis. Here’s how it’s done:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fb78bf1d7fee64b4b9126f522f6b58d00%3Fheight%3D443&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F20de2741-beb2-48d8-acef-371284901242%2F07e882766ccd425abc99954431d05953%2Fb78bf1d7fee64b4b9126f522f6b58d00%3Fheight%3D443&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="443" frameborder="0" scrolling="no"><a href="https://medium.com/media/813f00c9da39cc9de805f7830fd2d556/href">https://medium.com/media/813f00c9da39cc9de805f7830fd2d556/href</a></iframe><p>With these final steps, we have successfully assigned topics to each review using BERTopic. The selected columns now offer a more detailed insight into the nature of these topics, making it easier to analyze and interpret the results.</p><h4>Choosing the Right Model: LSA vs. BERTopic</h4><p>When it comes to topic modeling, selecting the right technique is crucial for obtaining meaningful insights from your data. In your analysis of Amazon employee reviews, you explored two prominent approaches: Latent Semantic Analysis (LSA) and BERTopic. Each of these methods has its own set of advantages and drawbacks, and understanding their pros and cons can help you make an informed choice.</p><p><strong>Latent Semantic Analysis (LSA)</strong></p><p><strong>Pros:<br></strong>1. <strong>Simplicity:</strong> LSA is relatively straightforward to implement. It involves techniques such as TF-IDF vectorization and Singular Value Decomposition (SVD), making it accessible to those new to topic modeling.<br>2. <strong>Interpretability:</strong> LSA provides easily interpretable results. Each topic consists of a list of words that are strongly associated with that topic, allowing for straightforward topic labeling and interpretation.<br>3. <strong>Scalability:</strong> LSA can handle large datasets with ease, making it suitable for analyzing extensive collections of text documents.</p><p><strong>Cons:<br></strong>1. <strong>Limited Context:</strong> LSA’s ability to capture the context and semantics of words and phrases is limited. It primarily relies on term-frequency statistics and may not capture more complex linguistic relationships.<br>2. <strong>Topic Overlap</strong>: LSA topics can overlap, resulting in less distinct and clear-cut topics. This can make it challenging to assign unique interpretations to each topic.<br>3. <strong>Hyperparameter Tuning:</strong> Determining the optimal number of topics (n_components) in LSA can be challenging and often involves manual tuning or heuristic approaches.</p><p><strong>BERTopic</strong></p><p><strong>Pros:<br></strong>1. <strong>Contextual Understanding:</strong> BERTopic leverages BERT embeddings, a state-of-the-art language model. This enables it to capture rich contextual information and intricate relationships between words, resulting in more accurate and context-aware topics.<br>2. <strong>Distinct Topics</strong>: BERTopic tends to produce more distinct and semantically meaningful topics. It can identify subtle differences in the meaning of words and phrases, leading to clearer topic assignments.<br>3. <strong>Dimensionality Reduction</strong>: BERTopic incorporates dimensionality reduction techniques like UMAP, which helps visualize high-dimensional data in a lower-dimensional space while preserving important patterns.</p><p><strong>Cons:<br></strong>1. <strong>Complexity:</strong> BERTopic is more complex to implement compared to LSA. It requires pre-trained models, such as BERT, and may involve hyperparameter tuning for UMAP.</p><p><strong>Choosing the Right Model<br></strong>The choice between LSA and BERTopic ultimately depends on one’s specific objectives, dataset characteristics, and the level of interpretability you require. If you prioritize simplicity, scalability, and a basic understanding of topics, LSA may be a suitable choice. However, if you aim for more nuanced, context-aware topics with the ability to handle complex language patterns, BERTopic is the way to go.</p><p>In our analysis, we wisely combined both techniques to cross-validate results and ensure the robustness of our findings. This approach showcases the commitment to rigor and dedication to extracting valuable insights from the Amazon employee reviews dataset.</p><p>In the world of topic modeling, there’s no one-size-fits-all solution. The right choice depends on the specific nuances of your data and research goals. By leveraging the strengths of both LSA and BERTopic, we’ve demonstrated a comprehensive and insightful approach to understanding employee feedback.</p><h4>Interpreting Topic Results</h4><p>Interpreting and labeling the identified topics in topic modeling is a critical step to make sense of the underlying themes within employee feedback. Here, we’ll examine the topics generated by both LSA and BERTopic and provide interpretations for each one. Assigning topics to employee feedback can help you understand the predominant concerns and sentiments expressed by Amazon employees.</p><p><strong>LSA Generated Topics:</strong></p><p><strong>Topic 1: Work-Life Balance<br></strong>Keywords: work, good, hour, great, time, working, Amazon, job, life, place<br>Interpretation: This topic reflects positive sentiments related to the work environment at Amazon. Employees in this category seem to appreciate the overall atmosphere, work hours, and the company as a workplace.</p><p><strong>Topic 2: Long Hours and Draining Work<br></strong>Keywords: long, hour, draining, break, become, day, personally, gap, short, week<br>Interpretation: Employees in this topic express concerns about long and draining working hours, emphasizing the need for breaks and work-life balance improvements.</p><p><strong>Topic 3: Balanced Work-Life Culture<br></strong>Keywords: life, culture, work, good, great, place, balance, balanced, overtime, everything<br>Interpretation: This topic highlights a positive work-life culture, where employees appreciate the balance between work and personal life, as well as the overall positive aspects of the workplace.</p><p><strong>Topic 4: Salary and Pay Concerns<br></strong>Keywords: salary, good, low, little, competitive, manager, culture, pay, peer, day<br>Interpretation: Employees in this category raise concerns about salary and pay, indicating a mix of positive and negative sentiments regarding compensation and management.</p><p><strong>Topic 5: Employee Well-being and Satisfaction<br></strong>Keywords: care, long, job, dont, salary, low, great, draining, everything, employee<br>Interpretation: This topic focuses on employee well-being and satisfaction, with mentions of concerns related to long hours, salary, and the overall work experience.</p><p><strong>Topic 6: Overtime and Work-Life Balance<br></strong>Keywords: balance, life, overtime, mandatory, people, time, salary, led, enjoy, excellent<br>Interpretation: Employees in this topic discuss the balance between overtime and work-life, highlighting both positive and negative aspects, including mandatory overtime.</p><p><strong>Topic 7: Pay and Job Satisfaction<br></strong>Keywords: job, pay, care, amount, good, week, one, manager, time, worst<br>Interpretation: This topic centers around pay and job satisfaction, with mentions of pay amounts, managerial aspects, and overall job experiences.</p><p><strong>Topic 8: Employee Benefits and Paid Leave<br></strong>Keywords: employee, break, care, day, paid, place, week, salary, low, would<br>Interpretation: Employees in this category discuss employee benefits, paid leave, and their experiences in the workplace, including salary-related concerns.</p><p><strong>Topic 9: Shifts and Work Culture<br></strong>Keywords: time, great, shift, everything, low, people, pay, culture, feel, perk<br>Interpretation: This topic explores shift-related aspects, work culture, and employee perceptions, including mentions of low pay and perks.</p><p><strong>Topic 10: Learning and Development Opportunities<br></strong>Keywords: learn, management, place, fun, employee, run, flexible, awful, opportunity, work<br>Interpretation: This topic focuses on opportunities for learning and development, including management, workplace culture, and the overall work experience.</p><p><strong>Interpreting BERTopic Results:</strong></p><p><strong>BERTopic 0: Work Environment and Management<br></strong>Keywords: work, time, management, good, day, hour, job, break, place, like<br>Interpretation: This topic appears to revolve around aspects related to the work environment, time management, and daily job experiences. Employees in this category discuss the quality of work, time-related concerns, and the overall atmosphere at Amazon.</p><p><strong>BERTopic 1: Team and Company Experience<br></strong>Keywords: amazon, working, work, team, loved, ive, thing, ppl, great, people<br>Interpretation: This topic seems to focus on employees’ experiences working with teams and their overall impressions of the company. It includes mentions of teamwork, positive sentiments, and people-related aspects.</p><h4>The Correlation Between LSA Generated Topics and BERTopic</h4><p>Analyzing the correlation between the topics generated by Latent Semantic Analysis (LSA) and BERTopic can provide valuable insights into the differences in their approaches and outcomes.</p><p><strong>Why BERTopic Generated Fewer Topics Than LSA</strong></p><ol><li>Model Complexity: BERTopic is based on state-of-the-art language models like BERT (Bidirectional Encoder Representations from Transformers). These models are highly complex and capture intricate relationships within the text. However, their complexity can sometimes result in a more consolidated representation of topics. In contrast, LSA is a simpler technique that relies on matrix factorization and may lead to a finer-grained division of topics.</li><li>Dimensionality Reduction: BERTopic uses Uniform Manifold Approximation and Projection (UMAP) for dimensionality reduction. UMAP aims to preserve the overall structure of data while reducing its dimensionality. Depending on the UMAP parameters chosen, it may prioritize maintaining global structure over local variations, resulting in fewer, more consolidated topics.</li><li>Text Embeddings: BERTopic leverages BERT embeddings, which capture the context and semantics of words and phrases exceptionally well. These embeddings tend to group similar words and concepts together, which can result in fewer distinct topics.</li></ol><p>In summary, the difference in the number of topics generated by BERTopic and LSA is primarily due to the adaptability and data-driven nature of BERTopic, which can result in a variable number of topics based on the characteristics of the dataset. It’s essential to choose a topic modeling approach that aligns with the goals and nature of the data analysis.</p><h3>Utilizing the Results: Improving Employee Satisfaction and Engagement at Amazon</h3><p>The insights gained from sentiment analysis and topic modeling of employee reviews on Amazon can be invaluable for Amazon in several ways. Leveraging these findings can lead to substantial improvements in employee satisfaction and engagement, ultimately benefiting both the company and its workforce. Here are some practical applications:</p><ol><li>Identifying Pain Points: By analyzing the sentiments expressed in employee reviews, Amazon can pinpoint specific areas where employees are dissatisfied or facing challenges. These pain points can range from work-related issues to concerns about work-life balance, compensation, or management.</li><li>Topic-Based Action Plans: With the results of topic modeling, Amazon can categorize employee feedback into distinct topics. For example, topics related to work-life balance, compensation, and company culture can be identified. This allows Amazon to create targeted action plans for each topic.</li><li>Tailored Interventions: Armed with a deeper understanding of the concerns and sentiments of different employee segments, Amazon can develop tailored interventions. For instance, if certain groups of employees express dissatisfaction with work hours, Amazon can explore flexible scheduling options.</li><li>Employee Wellness Initiatives: Understanding sentiments related to work-life balance and stress can inform Amazon’s initiatives related to employee well-being. Offering wellness programs, mental health support, and stress management resources can help improve the overall employee experience.</li><li>Feedback Loops: Establishing continuous feedback loops with employees based on the findings can foster a culture of open communication. Amazon can encourage employees to provide feedback regularly and use this input for ongoing improvements.</li><li>Measurement and Evaluation: Regularly measuring sentiment and tracking progress on identified action plans is crucial. Amazon can use key performance indicators (KPIs) to evaluate the effectiveness of its initiatives and make data-driven adjustments as needed.</li></ol><p>In conclusion, the results obtained from analyzing employee reviews using sentiment analysis and topic modeling can serve as a roadmap for Amazon to enhance its workplace environment, address employee concerns, and ultimately boost employee satisfaction and engagement. By actively listening to its employees and taking meaningful actions based on their feedback, Amazon can create a more positive and fulfilling work experience for its workforce, leading to increased productivity and long-term success.</p><h3>Conclusion</h3><p>In conclusion, our journey through sentiment analysis and topic modeling has provided valuable insights into understanding employee feedback using the Amazon Employee Reviews dataset. We’ve explored two powerful techniques: Latent Semantic Analysis (LSA) and BERTopic, each offering its own set of advantages and limitations. Here are the key takeaways from our exploration:</p><ol><li><strong>Understanding Employee Feedback</strong>: Employee feedback is a crucial component of HR management. Sentiment analysis and topic modeling offer effective ways to process and derive meaningful insights from this data.</li><li><strong>Sentiment Analysis</strong>: We used sentiment analysis to classify comments as positive, neutral, or negative. This technique allows organizations to gauge overall employee sentiment, identify areas of concern, and take proactive measures to improve workplace satisfaction.</li><li><strong>LSA vs. BERTopic</strong>: We compared two topic modeling approaches. LSA is effective at uncovering topics within the data but requires manual selection of the number of topics. BERTopic, on the other hand, automatically identifies topics but may generate fewer topics due to its complexity.</li><li><strong>Topic Interpretation</strong>: Both LSA and BERTopic generated topics that reflect various aspects of employee experiences, including work-life balance, work hours, company culture, salary, and job satisfaction. These topics provide valuable insights into the factors that influence employee sentiment.</li><li><strong>Potential Impact in HR</strong>: Sentiment analysis and topic modeling have immense potential in HR management. By analyzing employee feedback, organizations can enhance employee engagement, address pain points, and make data-driven decisions to create a more positive and productive workplace.</li></ol><p>In today’s competitive business landscape, understanding and acting upon employee feedback are essential for maintaining a motivated and productive workforce. Sentiment analysis and topic modeling empower organizations to gain deeper insights into employee sentiments and perceptions, leading to more informed HR strategies and a stronger, more engaged workforce.</p><p>As we conclude this journey, we encourage organizations to embrace the power of sentiment analysis and topic modeling in HR to foster a workplace culture where employees feel valued, heard, and motivated to excel. By doing so, organizations can not only improve their bottom line but also create a more positive and fulfilling work environment for their most valuable asset: their employees.</p><h3>References</h3><ul><li>BERTopic Github repo[<a href="https://github.com/MaartenGr/BERTopic">MaartenGr/BERTopic: Leveraging BERT and c-TF-IDF to create easily interpretable topics. (github.com)</a>]</li><li>Analytics Vidhya [<a href="https://www.analyticsvidhya.com/blog/2018/10/stepwise-guide-topic-modeling-latent-semantic-analysis/">https://www.analyticsvidhya.com/blog/2018/10/stepwise-guide-topic-modeling-latent-semantic-analysis/</a>]</li><li>Topic Modeling with Latent Semantic Analysis by Aashish Nair [<a href="https://towardsdatascience.com/topic-modeling-with-latent-semantic-analysis-58aeab6ab2f2">https://towardsdatascience.com/topic-modeling-with-latent-semantic-analysis-58aeab6ab2f2</a>]</li><li>Egger, R. and Yu, J. (2022). A Topic Modeling Comparison Between LDA, NMF, Top2Vec, and BERTopic to Demystify Twitter Posts. <em>Frontiers in Sociology</em>, 7. doi:https://doi.org/10.3389/fsoc.2022.886498.</li><li>Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., &amp; Sutskever, I. (2019). Language models are unsupervised multitask learners. OpenAI Blog, 1(8), 9.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8526770b240f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Covid-19 Patient Risk Evaluation: End-to-End Machine Learning Project (To Deployment)]]></title>
            <link>https://medium.com/@Jammaladeyemi/covid-19-patient-risk-evaluation-end-to-end-machine-learning-project-to-deployment-becc15896e79?source=rss-dd7d2ad11f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/becc15896e79</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Jammal Adeyemi]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 16:53:22 GMT</pubDate>
            <atom:updated>2023-01-17T16:53:22.310Z</atom:updated>
            <content:encoded><![CDATA[<p>At the end of lectures for my first-semester course in cloud AI, we were told to demonstrate the capability of AI and cloud environments in solving real-life problems. I chose to focus on the healthcare sector, specifically on the problem of “Covid-19 Patient Risk Evaluation.” The main goal of this project is to build a machine-learning model that, given a Covid-19 patient’s current symptoms, status, and medical history, will predict whether the patient is at high risk or not.</p><p>To complete this project, I selected a relevant benchmarked data resource from Kaggle and investigated the dataset, gaining a basic understanding of its significance and meaning. I then explored the data using well-established, high-quality references and statistical functions.</p><p>I also proposed a cloud AI system or framework that could be implemented for my chosen dataset. I described and critically assessed AI services on the cloud, showing the spectrum of Cloud computing capabilities used to deploy them. Finally, I discussed my findings, making recommendations for further investigation and improved implementation.</p><p>Overall, this project allowed me to apply my knowledge of AI and cloud environments to a real-life problem in the healthcare sector and has given me a better understanding of how these technologies can be used to improve patient outcomes. I am looking forward to applying this knowledge in future coursework or my final dissertation which I intend to focus on something in the finance sector.</p><p>For the sake of good order, this publication will follow the under-listed subtitles:</p><p>· Understanding Problem Case</p><p>· Descriptions of Data</p><p>· Data Preparation</p><p>· Exploratory Data Analysis</p><p>· Model Building</p><p>· Evaluation of Model</p><p>· Model Deployment</p><h4><strong>Understanding Problem Case</strong></h4><p>The coronavirus disease 2019 (Covid-19) is an infectious disease caused by the severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). It has become a global pandemic, affecting millions of people worldwide and causing severe illness and death, particularly in older adults or those with underlying health conditions. One of the main challenges in managing the Covid-19 pandemic is identifying individuals at high risk and ensuring that they receive appropriate care. This requires the ability to accurately predict the risk of severe illness in individual patients based on their current symptoms, status, and medical history. Early identification of high-risk patients can help prioritize resources and interventions, and reduce the overall burden on the healthcare system. This project aims to construct a machine learning model that, by analyzing a Covid-19 patient’s present symptoms, condition and medical history, will predict the patient&#39;s risk level.</p><h4>Descriptions of Data</h4><p>The Mexican government provided the dataset. This dataset contains an enormous number of anonymized patient-related information including pre-conditions. The raw dataset consists of 21 unique features and 1,048,576 unique patients. <strong>In the Boolean features, 1 means “yes” and 2 means “no”. values 97 and 99 are missing data</strong>.</p><h4>Data Preparation</h4><p>The data was downloaded from <a href="https://www.kaggle.com/datasets/meirnizri/covid19-dataset">Kaggle</a>, and a lot of preprocessing and transformations were required to be performed on the dataset.</p><ol><li>Checking missing values: It was shown that we don’t have any missing values.</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2F8d01ae7e53c9471eb99c21e297c6c0ed%3Fheight%3D555.3875122070312&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2F8d01ae7e53c9471eb99c21e297c6c0ed%3Fheight%3D555.3875122070312&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="555" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0854f5db54038187e571a05fa68ebbe/href">https://medium.com/media/b0854f5db54038187e571a05fa68ebbe/href</a></iframe><p>2. Checking for unique values by columns: Since we had no missing values, I decided to check for unique values in each column.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2F60770f2405fb48a5ad4212c3c814b923%3Fheight%3D565&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2F60770f2405fb48a5ad4212c3c814b923%3Fheight%3D565&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="565" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef12ce280275ecfafb76211f76d2fbb7/href">https://medium.com/media/ef12ce280275ecfafb76211f76d2fbb7/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2Fa3a2c03a185b4b79bfba82c2ff18a33a%3Fheight%3D191.7874984741211&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2Fa3a2c03a185b4b79bfba82c2ff18a33a%3Fheight%3D191.7874984741211&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="191" frameborder="0" scrolling="no"><a href="https://medium.com/media/46bf34228cad34c31168724b66b3a903/href">https://medium.com/media/46bf34228cad34c31168724b66b3a903/href</a></iframe><p>We have some features that we expect them to have just 2 unique values but we see that these features have 3 or 4 unique values. For example, the feature “PNEUMONIA” has 3 unique values (1, 2, 99) 99 represents NaN values. Hence we will just take the rows that include 1 and 2 values.</p><p>3. Feature Engineering</p><p>I. Date_Died Column:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2Fa1d6a76ae13145fb8754c5b5d1472896%3Fheight%3D230.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2Fa1d6a76ae13145fb8754c5b5d1472896%3Fheight%3D230.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="230" frameborder="0" scrolling="no"><a href="https://medium.com/media/eecc94011109c45d45905db029711057/href">https://medium.com/media/eecc94011109c45d45905db029711057/href</a></iframe><p>In the “DATE_DIED” column, we have 971633 “9999–99–99” values which represent <strong>alive patients</strong> so I will take this feature and create a new column called “DEATH” that includes whether the patient died or not.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2F1c5ec2a922e443efb3510d42646500d7%3Fheight%3D101&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F79588ac90f8a43d5b8b6cb537212620a%2F1c5ec2a922e443efb3510d42646500d7%3Fheight%3D101&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="101" frameborder="0" scrolling="no"><a href="https://medium.com/media/8372bd510b0fca01a2f7ad1d5da2f1d8/href">https://medium.com/media/8372bd510b0fca01a2f7ad1d5da2f1d8/href</a></iframe><p>II. Classification_Final column: Values ​​between 1 and 3 in the CLASIFFICATION_FINAL future are people infected with the covid virus. Those that are greater than these values ​​are people who have been tested and have negative results or whose results are unknown.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F55d89bfc8b504faeb1dda77cf05aa857%3Fheight%3D101&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F55d89bfc8b504faeb1dda77cf05aa857%3Fheight%3D101&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="101" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb3846abe57b6941f953c48b2d2170e1/href">https://medium.com/media/bb3846abe57b6941f953c48b2d2170e1/href</a></iframe><p>We create a new column called “INFECTED” and we assign a value of 1 to our data for people who have previously been infected with the coronavirus, and 2 to people who have not been infected with this virus or whose result is unknown. Then we drop the “CLASIFFICATION_FINAL” column.</p><p>III. Pregnancies — Sex: 1 for female and 2 for male. We plot a barplot to visualize our data and to understand it best.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F309165eff13948d39495e9e7fcfa2ace%3Fheight%3D483&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F309165eff13948d39495e9e7fcfa2ace%3Fheight%3D483&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="483" frameborder="0" scrolling="no"><a href="https://medium.com/media/a215bf190d89b0a717777aa7954ef455/href">https://medium.com/media/a215bf190d89b0a717777aa7954ef455/href</a></iframe><p>We see that all “97” values are for males and males can not be pregnant so we will convert 97 to 2 and we got rid of any missing values.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fe267ed5f979e4f5488b2904063757291%3Fheight%3D155&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fe267ed5f979e4f5488b2904063757291%3Fheight%3D155&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="155" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab6380e7f2e442daee3da3abcf5deea8/href">https://medium.com/media/ab6380e7f2e442daee3da3abcf5deea8/href</a></iframe><p>IV. INTUBED &amp; ICU: We plot a barplot to visualize our data and to understand it best.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fa20e719035a64dd1ad832be005f9cfd4%3Fheight%3D447&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fa20e719035a64dd1ad832be005f9cfd4%3Fheight%3D447&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="447" frameborder="0" scrolling="no"><a href="https://medium.com/media/d674a0467953304a5e7bf72fe63b2ef4/href">https://medium.com/media/d674a0467953304a5e7bf72fe63b2ef4/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fa1f77c144fe841f194aa82dfaae113ee%3Fheight%3D447&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fa1f77c144fe841f194aa82dfaae113ee%3Fheight%3D447&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="447" frameborder="0" scrolling="no"><a href="https://medium.com/media/200cb745ab4751853f95f5d04f5d1c35/href">https://medium.com/media/200cb745ab4751853f95f5d04f5d1c35/href</a></iframe><p>In the “INTUBED” and “ICU” features there are too many missing values so I will drop them.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F57d0066fcf6d43259ab2692db9a143cf%3Fheight%3D83&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F57d0066fcf6d43259ab2692db9a143cf%3Fheight%3D83&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="83" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb6b65e2fbfdaf6def1ee1d01b76f7c1/href">https://medium.com/media/eb6b65e2fbfdaf6def1ee1d01b76f7c1/href</a></iframe><p>V. Filtering Data for Relevant Features</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fb4b2a88d26e94c63a36e9ce2fdc46a88%3Fheight%3D263&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fb4b2a88d26e94c63a36e9ce2fdc46a88%3Fheight%3D263&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="263" frameborder="0" scrolling="no"><a href="https://medium.com/media/c86581cc3279ca5655ebf221d372724a/href">https://medium.com/media/c86581cc3279ca5655ebf221d372724a/href</a></iframe><h4>Exploratory Data Analysis</h4><p>The datasets had lots of columns to be checked to make us better understand. Each column was checked to draw out insights and make us understand what the dataset is about.</p><p>I. AGE:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F1d85c34c47f24d04890a1963ef96fede%3Fheight%3D433&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F1d85c34c47f24d04890a1963ef96fede%3Fheight%3D433&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="433" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f37284a182c049881ba1a2f3dcc0d0a/href">https://medium.com/media/4f37284a182c049881ba1a2f3dcc0d0a/href</a></iframe><p>Patients are roughly between 20–60 years old.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Ff8dbe67d03af4f91bf0b762ce8965a76%3Fheight%3D433&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Ff8dbe67d03af4f91bf0b762ce8965a76%3Fheight%3D433&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="433" frameborder="0" scrolling="no"><a href="https://medium.com/media/f179fb9e953636083a7e41e8274c06a7/href">https://medium.com/media/f179fb9e953636083a7e41e8274c06a7/href</a></iframe><p>Older patients are more likely to die compared to younger ones.</p><p>II. MEDICAL UNIT: This is the type of institution of the National Health System that provided cars can be seen from the patients who went to medical units 4 and 12, as the medical unit improves, survival rates increase and deaths decrease. (eg. 4 = Cottage hospital, 12 = Hospital).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F6e32461e41ac4398b56eb0e558860a2a%3Fheight%3D503&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F6e32461e41ac4398b56eb0e558860a2a%3Fheight%3D503&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="503" frameborder="0" scrolling="no"><a href="https://medium.com/media/4730b7ad911eae5e1f4f588eba5ac634/href">https://medium.com/media/4730b7ad911eae5e1f4f588eba5ac634/href</a></iframe><p>III. PATIENT_TYPE: This is the type of care the patient received in the unit. 1 for returned home and 2 for hospitalization. From the graph, we can see that people who are hospitalized have a higher chance of survival.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fc9e1584730724990a8fb9a9f6ff3c7aa%3Fheight%3D448&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2Fc9e1584730724990a8fb9a9f6ff3c7aa%3Fheight%3D448&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="448" frameborder="0" scrolling="no"><a href="https://medium.com/media/72f23fef8415b91763843530ca3a91ce/href">https://medium.com/media/72f23fef8415b91763843530ca3a91ce/href</a></iframe><p>IV. SEX: From the graph below, Males are more likely to die of covid compared to females.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F7131a8a3cae44a9aafe9948662f2ef37%3Fheight%3D469&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F9a82c6608a43428f86be48ccdd889076%2F7131a8a3cae44a9aafe9948662f2ef37%3Fheight%3D469&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="469" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b7b9e7f886401e1b44996a8a92d7a2b/href">https://medium.com/media/3b7b9e7f886401e1b44996a8a92d7a2b/href</a></iframe><h4>Model Building</h4><p>For this project, 2 machine learning estimators were prioritised for our analysis. They are AdaBoost Classifier and logistic regression with hyperparameter tuning using GridsearchCV. Both algorithms were applied to the down-sampled data and the confusion matrix was highly adhered to.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F81a630284bbf4a659e9e30e3237d6e38%3Fheight%3D155&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F81a630284bbf4a659e9e30e3237d6e38%3Fheight%3D155&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="155" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7587fa21404e0e6b099ca99a8bdc585/href">https://medium.com/media/c7587fa21404e0e6b099ca99a8bdc585/href</a></iframe><p>The SelectKBest class from the sklearn.feature_selection library is used to select the top k features based on a scoring function. In this case, k=14 features are selected and the scoring function used is f_classif which stands for ANOVA F-value between label/feature for classification tasks.</p><p>The fit_transform method is used to fit the selector to the dataset and then transform the dataset by selecting the top k features. In this case, the dataset is stored in the Dataframe &#39;df&#39;, and the feature we want to predict &#39;DEATH&#39; is dropped using the drop function and stored in the variable &#39;x&#39;. And the &#39;y&#39; variable is assigned to the &#39;DEATH&#39; column in the &#39;df&#39; dataframe.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F3403732f086d454d89bf9288c16c394a%3Fheight%3D119&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F3403732f086d454d89bf9288c16c394a%3Fheight%3D119&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="119" frameborder="0" scrolling="no"><a href="https://medium.com/media/bae6d7640dc0ff0705f8d2dd17fddbc1/href">https://medium.com/media/bae6d7640dc0ff0705f8d2dd17fddbc1/href</a></iframe><p>The code snippet shown here is a data preprocessing step known as feature scaling. It is applied to the features selected in the previous step. The purpose of feature scaling is to ensure that all features are on a similar scale, this helps to prevent some features from dominating others during the model training process.</p><p>In this case, the RobustScaler class from the sklearn.preprocessing library is used to scale the numeric features in the dataset. The fit_transform method is used to fit the scaler to the dataset and then transform the dataset by scaling the numeric features. The transformed dataset is stored in the same variable &#39;X&#39;.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F871ec8959fc842bfaa2be67222a44775%3Fheight%3D315&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F871ec8959fc842bfaa2be67222a44775%3Fheight%3D315&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="315" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed68b7015bd6c941edf8c033a5d6e537/href">https://medium.com/media/ed68b7015bd6c941edf8c033a5d6e537/href</a></iframe><p>After selecting the top 14 features and scaling the ‘X’ column, the RandomUnderSampler class from the imblearn.under_sampling library is used to undersample the majority class. The fit_resample method is used to fit and resample the dataset, this method takes the X and y variables which are the features and target variables respectively.</p><p>Then the data is split into train and test sets, with the train_test_split function from sklearn.model_selection library is used for the split, the test size is set to 20%.</p><h4>Model Evaluation</h4><p>The evaluation metric used was theAccuracy and roc_auc_score . The ROC-AUC score is a commonly used metric for evaluating the performance of machine learning models for binary classification problems. The ROC-AUC score is a value between 0 and 1, with a score of 1 indicating perfect classification and a score of 0.5 indicating random classification. A higher ROC-AUC score indicates that the model is able to correctly classify the positive and negative examples with a high degree of accuracy.</p><p>I. Adaboost classifier</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2Fd22c2588170e4631a912aeed12d8a718%3Fheight%3D165&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2Fd22c2588170e4631a912aeed12d8a718%3Fheight%3D165&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="165" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5d6e61be38319b8ee02aa287e449adc/href">https://medium.com/media/f5d6e61be38319b8ee02aa287e449adc/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F97c32009ef084924911acdf8df052508%3Fheight%3D152.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F97c32009ef084924911acdf8df052508%3Fheight%3D152.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/0046f493d4bed0338cd0ed5afb01385e/href">https://medium.com/media/0046f493d4bed0338cd0ed5afb01385e/href</a></iframe><p>the ROC-AUC score is 0.955 which is considered to be very good. It indicates that the model is able to correctly classify the positive and negative examples with a high degree of accuracy. A score of 0.955 implies that the model is able to identify 95.5% of the positive cases and also has a 5.5% chance of identifying a negative case as a positive.</p><p>II. Logistic Regression</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F180cb0d82c6c4d02a7bda180295d2a9a%3Fheight%3D367&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F180cb0d82c6c4d02a7bda180295d2a9a%3Fheight%3D367&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="367" frameborder="0" scrolling="no"><a href="https://medium.com/media/648e49e1f150d76214657b3c7cd65bf6/href">https://medium.com/media/648e49e1f150d76214657b3c7cd65bf6/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2Ff3974888a38249219ec191aea409afcb%3Fheight%3D152.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2Ff3974888a38249219ec191aea409afcb%3Fheight%3D152.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/d087819c84bbdec2573320474973d5ee/href">https://medium.com/media/d087819c84bbdec2573320474973d5ee/href</a></iframe><p>the ROC-AUC score is 0.953 which is considered to be very good. It indicates that the model is able to correctly classify the positive and negative examples with a high degree of accuracy. A score of 0.953 implies that the model is able to identify 95.3% of the positive cases and also has a 4.7% chance of identifying a negative case as a positive.</p><p>III. Voting Classifier: A Voting Classifier is an ensemble method in machine learning where multiple models are combined to make a single prediction. The idea behind this method is that by combining different models, the final predictions will be more accurate and robust than any individual model.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F8320743ac9754248bf6489bb74866f47%3Fheight%3D155&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F8320743ac9754248bf6489bb74866f47%3Fheight%3D155&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="155" frameborder="0" scrolling="no"><a href="https://medium.com/media/b612fe05258d919eb4b2522a16f02d2c/href">https://medium.com/media/b612fe05258d919eb4b2522a16f02d2c/href</a></iframe><p>There are two main types of voting classifiers: hard voting and soft voting. In hard voting, the classifier takes the majority vote of all the models’ predictions. In soft voting, the classifier takes the weighted average of all the models’ predicted probabilities.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F26f06943cc884ce19df61ef0cccdd63d%3Fheight%3D101&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2F4509a0a3944e4f87af483365f50e1b62%2F26f06943cc884ce19df61ef0cccdd63d%3Fheight%3D101&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="101" frameborder="0" scrolling="no"><a href="https://medium.com/media/e830a309d3f63c8e7cc5c34903f96e93/href">https://medium.com/media/e830a309d3f63c8e7cc5c34903f96e93/href</a></iframe><p>With this final model, we are ready to deploy it on AWS and make it available to users. The deployment on the cloud will allow us to scale the model and handle a large number of predictions without having to worry about the infrastructure.</p><h4>Model Deployment</h4><p>The final step in any machine learning project is the deployment of the model. This is where the trained model is made available for use in a production environment, where it can be integrated into an application or system to make predictions. Without this step, the model remains a theoretical construct that cannot be used to solve real-world problems. Deploying a model on a cloud platform like AWS (Amazon Web Services) is a popular choice because it offers various services that make it easy to deploy, manage, and monitor models in production. By deploying on AWS, you can take advantage of the scalability and reliability that the cloud provides, making it easy to handle a large number of predictions without having to worry about the infrastructure.</p><p>AWS SageMaker is one of the most popular services for deploying machine learning models on AWS. It provides pre-built environments and tools for building, training, and deploying models, making it easy for developers to get their models up and running in no time. Additionally, it also offers monitoring and management features that can help you to keep track of your model’s performance and improve it over time.</p><p>The following steps were taken in the deployment process:</p><p>I. Prepare SageMaker model: We converted our final model into a SageMaker-ready model which is the<em>model.tar.gz</em>format. This was done using the tar and gzip utilities in Windows.</p><p>II. Host the model: In order to host the model on Amazon SageMaker using the SageMaker <em>Scikit-learn Model Server</em>, we had to override four functions in the inference entry-point script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtC04oo21hs_S6gTCrCi9g.jpeg" /><figcaption>Fig 27. Risk Predictor</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WGP_MGnyilfOIOoZBLa2ZA.jpeg" /><figcaption>Fig 27b. Risk Predictor</figcaption></figure><p>III. Create AWS S3 Bucket: Next, we created an Amazon S3 bucket and uploaded the ‘<em>model.tar.gz</em>’ file to it. We then copy the file URI and paste it into the <em>model_artifact_ur</em>i variables which is in our inference script to access the model.</p><p>IV. Create a VPC and Subnets</p><p>V. Create a Sagemaker Studio Domain: Afterwards, we went to the Amazon SageMaker console and created a Domain Studio, which is a workspace where we would make predictions and deploy the model for end users to interact with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ppMLC_uYdbpe-Xt5HHkyw.jpeg" /><figcaption>Fig 28. Sagemaker Domain</figcaption></figure><p>VI. Develop an Inference Script: We developed an inference handler script and deployed it on Amazon SageMaker Studio to create a model endpoint and get predictions.</p><p>VII. Deploy an endpoint from model data: Finally, we created a SKLearnModel object in Amazon SageMaker and used it to deploy an endpoint for the model. We specified the location of the model data in the S3 bucket, the IAM role to use, the entry point script, and the framework version. We then deployed the model to an ml.m5.large instance and specified the initial instance count as 1.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Fdfc176bf1ceb40ac8c3a3b74ee074424%3Fheight%3D137&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Fdfc176bf1ceb40ac8c3a3b74ee074424%3Fheight%3D137&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="137" frameborder="0" scrolling="no"><a href="https://medium.com/media/178f995f675f4f3cc2542f7399df6973/href">https://medium.com/media/178f995f675f4f3cc2542f7399df6973/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Fee9cb4f785d444db85542bfdcce11a15%3Fheight%3D191&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Fee9cb4f785d444db85542bfdcce11a15%3Fheight%3D191&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="191" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0994103b3c88a60b40ac4a0bb8c1d20/href">https://medium.com/media/a0994103b3c88a60b40ac4a0bb8c1d20/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Ff753c80a74cc4cdb967e77909d7fe209%3Fheight%3D281&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Ff753c80a74cc4cdb967e77909d7fe209%3Fheight%3D281&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb6099dffb474cd23e3f45e1e6425306/href">https://medium.com/media/fb6099dffb474cd23e3f45e1e6425306/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Fb16e6d1b48b342549edb3e50fd6f84b9%3Fheight%3D155&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Fb16e6d1b48b342549edb3e50fd6f84b9%3Fheight%3D155&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="155" frameborder="0" scrolling="no"><a href="https://medium.com/media/73bcaf74e28fd383502bea2c5b5a1b49/href">https://medium.com/media/73bcaf74e28fd383502bea2c5b5a1b49/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Ff107825d56024758a51793c978c0a7b8%3Fheight%3D461&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2Ff107825d56024758a51793c978c0a7b8%3Fheight%3D461&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="461" frameborder="0" scrolling="no"><a href="https://medium.com/media/17679445555118adf59b90e864c4bc8a/href">https://medium.com/media/17679445555118adf59b90e864c4bc8a/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2F6f223a649023499ab8739e9828010c80%3Fheight%3D101&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2F6f223a649023499ab8739e9828010c80%3Fheight%3D101&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="101" frameborder="0" scrolling="no"><a href="https://medium.com/media/65c7da84e6c56d0dec043a564be3dda2/href">https://medium.com/media/65c7da84e6c56d0dec043a564be3dda2/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2F3eb2a332f24d4f1d96ca8e1f60ec1ac5%3Fheight%3D281&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2Fd73c19fc-98fc-4501-9be8-60edb6231eac%2Ff14937767aa54ffd992042d99a02b3f6%2F3eb2a332f24d4f1d96ca8e1f60ec1ac5%3Fheight%3D281&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/15a6d2d72db07f239242a5d7fc5f8bae/href">https://medium.com/media/15a6d2d72db07f239242a5d7fc5f8bae/href</a></iframe><p>Following this step, I was able to successfully deploy my model and make predictions by hitting the endpoint.</p><h4><strong>LEGAL AND ETHICAL ASPECTS OF THE CLOUD AI FRAMEWORK</strong></h4><p>The deployment of a machine learning model on a cloud platform such as Amazon SageMaker brings with it a number of legal and ethical considerations. In this report, we will outline some of these considerations and discuss how they were addressed in the deployment process.</p><ol><li>Data privacy and security: One of the key legal and ethical considerations in the deployment of a machine learning model on the cloud is the protection of sensitive data. To address this concern, we took several measures to ensure the security and privacy of the data used in the model. These measures included encoding the data before training, using reputable serverless cloud service providers like AWS, and implementing post-training encoding during inferencing.</li><li>Data ownership and access: Another important legal and ethical consideration is ownership and access to data. To ensure that access to the data is properly controlled, we implemented appropriate access controls and permissions on the S3 bucket where the data was stored. We also ensured that data access was only granted to authorized users who needed it for the purpose of model training and evaluation.</li><li>AI bias and fairness: Another important ethical consideration in the deployment of a machine learning model is the potential for bias and unfairness in the model’s predictions. To mitigate these risks, we implemented several strategies to ensure that the model was fair and unbiased. These strategies included training the model on a diverse and representative dataset and using techniques such as data preprocessing and balancing to reduce bias.</li></ol><h4>Conclusion</h4><p>This project, specifically the deployment stage, presented a valuable learning experience, despite the challenges that we faced. It is clear that in order to deliver a complete project, data scientists must be able to overcome the obstacles that come with deploying models and be able to perform real-time tests on them. It is an important aspect of a data scientist’s skill set and this project allowed for valuable growth in that area.</p><p>A bientôt.</p><p>Jammal Adeyemi</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=becc15896e79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Probabilistic Sales Forecasting using Discrete Distribution Models Pt. 1]]></title>
            <link>https://medium.com/@Jammaladeyemi/probabilistic-sales-forecasting-using-discrete-distribution-models-pt-1-75c3440d08bc?source=rss-dd7d2ad11f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/75c3440d08bc</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[sales]]></category>
            <dc:creator><![CDATA[Jammal Adeyemi]]></dc:creator>
            <pubDate>Thu, 01 Sep 2022 14:47:14 GMT</pubDate>
            <atom:updated>2022-09-01T14:50:37.202Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60HVO3FP_I0Tvxg1rxSmkQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@tamiminaser?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Naser Tamimi</a> on <a href="https://unsplash.com/s/photos/probability?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This article will be in two-part, <strong>Part 1</strong> being the <strong>Exploratory Data Analysis</strong> and <strong>Part 2</strong> being the <strong>Probability Sales Forecasting</strong>.</p><h4>PROBLEM STATEMENTS</h4><p>The business objective is to understand consumer behaviour and purchasing patterns of the store’s customers in the 1st quarter and forecast sales outcomes throughout the 2nd quarter. We’ve been provided with sales records from Q1. Our objective is to work with the team to create reliable forecasts of sales performance in Q2 and report our findings and recommendations to the stakeholders in terms of quantifiable metrics and actionable insights.</p><h4>SCOPE, ASSUMPTIONS &amp; CONSTRAINTS</h4><p>This project focuses on simulating future outcomes using discrete probability distributions. As a result, only the discrete and categorical variables would be taken into account when fitting probabilistic models to the data. The target business variable of primary focus for this project is Quantity.<br>In this project, the modelling procedure and probabilistic simulations assume that the relevant variables’ time series are (approximately) stationary. By assuming stationarity, one can use past outcomes to predict uniformly-shifted future times.<br>To test this hypothesis, we would run our simulations and make our predictions over the same amount of time (as measured in days) as each day in the actual records. Thus, predictions for each future time 𝑡 + ∆𝑡 would be based on each specific time t in the data, where ∆𝑡 is uniform across all future outcome predictions. The probabilistic models can still learn various statistical properties of the data over time and include them in each prediction at 𝑡 + ∆𝑡.</p><h4>DATA INGESTION &amp; INITIAL ANALYSIS</h4><p>Here, we are going to load the data into our workspace, perform an initial inspection of the data, and carry out any necessary treatment required.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2Fe1803fe0-c0fd-4b94-bf78-5d39fec742ce%3Fheight%3D314&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2Fe1803fe0-c0fd-4b94-bf78-5d39fec742ce%3Fheight%3D314&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="314" frameborder="0" scrolling="no"><a href="https://medium.com/media/799b154a4f45d536a619c28b62434b6e/href">https://medium.com/media/799b154a4f45d536a619c28b62434b6e/href</a></iframe><p><strong>THE DATA</strong></p><p>The supermarket’s IT department provided the following link for us to access the database containing the sales records for Q1.</p><p><a href="https://github.com/gamesconsort/cga-internship-projects/blob/main/probabilistic-sales-forecasting/data/supermarket_sales_data">https://github.com/gamesconsort/cga-internship-projects/blob/main/probabilistic-sales-forecasting/data/supermarket_sales_data</a></p><p>Instead of downloading the data, we are going to ingest the data directly into our workspace and work with it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00001-ce398ddc-0593-4cec-8fcc-e50804c86b81%3Fheight%3D482.8000183105469&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00001-ce398ddc-0593-4cec-8fcc-e50804c86b81%3Fheight%3D482.8000183105469&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="482" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f25dcf8eef200af05018a29c838f069/href">https://medium.com/media/2f25dcf8eef200af05018a29c838f069/href</a></iframe><ul><li><strong>Get Dataset Info</strong></li></ul><p>We use the info() function to identify the data types and some basic information on the content of the DataFrame<em>.</em>df.info()<em> </em>should return a list of all the columns in our dataset, and the data type of each column.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00005-70b9a942-f390-4ea0-a1ff-c13019963431%3Fheight%3D589&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00005-70b9a942-f390-4ea0-a1ff-c13019963431%3Fheight%3D589&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="589" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2b894e7a0a5766d795abca1e36b4e23/href">https://medium.com/media/b2b894e7a0a5766d795abca1e36b4e23/href</a></iframe><ul><li><strong>Check for Missing Values</strong></li></ul><p>Missing values (also known as NaN) are a frequent issue that can result in inaccurate analysis and have a substantial impact on results. This can be the result of incorrect data being inputted, unavailable data, or a programming error.<br>The isnull() function returns false if we do not have missing values and true<em> </em>otherwise. The sum() function returns the sum of those missing values in each column. We could also use the .sort_values() function with the ascending=False parameter to sort the output in descending order as we can see below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00003-7c4e828e-80b2-43d7-b0ed-b9fc56d5548e%3Fheight%3D367&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00003-7c4e828e-80b2-43d7-b0ed-b9fc56d5548e%3Fheight%3D367&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="367" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9c768ca628745e394bcfb145d381f0f/href">https://medium.com/media/a9c768ca628745e394bcfb145d381f0f/href</a></iframe><p>We have no missing values in all our columns.</p><ul><li><strong>Check for Unique Values</strong></li></ul><p>We use the Unique() function to identify the Unique values of each column of the Data. For example, Branch has 3 unique values i.e they are 3 different branches in the datasets.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00006-6975e6d9-e6f9-4cec-95d1-fd1b5d7896f3%3Fheight%3D503&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00006-6975e6d9-e6f9-4cec-95d1-fd1b5d7896f3%3Fheight%3D503&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="503" frameborder="0" scrolling="no"><a href="https://medium.com/media/d31e7224ba53ce181c673a86f5f2f951/href">https://medium.com/media/d31e7224ba53ce181c673a86f5f2f951/href</a></iframe><p><strong>Observations:</strong><br>The data appears to be fairly clean, based on my observations. Something to look into:</p><ul><li>Data has 1000 samples without missing any information</li><li>We may need to convert the date and time later</li><li>The <em>Invoice ID</em> need to be excluded so so as not to cause overfitting</li><li>The <em>gross margin percentage</em> has only 1 value, which does not give us any meaning</li></ul><p>So we drop Invoice ID and gross margin percentage columns using the drop()function</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00008-dd8f3d06-7826-432a-a327-86f6eb4f01c6%3Fheight%3D446.8000183105469&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00008-dd8f3d06-7826-432a-a327-86f6eb4f01c6%3Fheight%3D446.8000183105469&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="446" frameborder="0" scrolling="no"><a href="https://medium.com/media/7098029a6c5a7c4cfe293927372026b9/href">https://medium.com/media/7098029a6c5a7c4cfe293927372026b9/href</a></iframe><h4>EDA &amp; BUSINESS INSIGHTS</h4><p>We are going to carry out a comprehensive exploratory data analysis to understand the distributions that underlie the observations in the data, the patterns and dependencies that exist in the data, and extract any useful business insight from the data.</p><p>First, we remove the space in the column title and replace them with an ‘_’ just to make it easier when we try calling a column name. Since we are in 2022, we update the Date column from 2019 to 2022 so that the rest of the project will be a study of the outlook for Q2, 2022.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00010-01758b8d-192e-4c6f-9127-711ec250012c%3Fheight%3D454.8000183105469&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00010-01758b8d-192e-4c6f-9127-711ec250012c%3Fheight%3D454.8000183105469&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="454" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab0a8f50ea48b6ac479679a83ae318ea/href">https://medium.com/media/ab0a8f50ea48b6ac479679a83ae318ea/href</a></iframe><p>Let’s Explore each Column</p><ol><li><strong>Branch</strong></li></ol><ul><li>Checking for the different branches we have in our datasets</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00014-37fe749e-ec16-4e2d-a618-657f74d29e55%3Fheight%3D189&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00014-37fe749e-ec16-4e2d-a618-657f74d29e55%3Fheight%3D189&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="189" frameborder="0" scrolling="no"><a href="https://medium.com/media/56b516b580e2f0d6c9c898403465658a/href">https://medium.com/media/56b516b580e2f0d6c9c898403465658a/href</a></iframe><p>We have 3 different branches in our datasets. <strong>Branch A</strong> is highly represented in our datasets. This can be visualized with the code below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00015-294eb934-11d4-4630-914c-f5fe7fe5291e%3Fheight%3D758.7000122070312&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00015-294eb934-11d4-4630-914c-f5fe7fe5291e%3Fheight%3D758.7000122070312&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="758" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9f40953376ff3015f0aef925c80c7f8/href">https://medium.com/media/d9f40953376ff3015f0aef925c80c7f8/href</a></iframe><ul><li>Comparing the customer gender that goes into the different branches to purchase an item.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00016-6a727a86-e71e-4c90-b3d2-616bd185225a%3Fheight%3D440.375&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00016-6a727a86-e71e-4c90-b3d2-616bd185225a%3Fheight%3D440.375&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="440" frameborder="0" scrolling="no"><a href="https://medium.com/media/e713d7aa44d98af4c3aa79bc26d23c8c/href">https://medium.com/media/e713d7aa44d98af4c3aa79bc26d23c8c/href</a></iframe><p>From the graph above, we can see that for <strong>Branch A &amp; B</strong> we have more Male consumers than Female Consumers while for <strong>Branch C</strong> we have more Female consumers than Male consumers.</p><ul><li>The most successful Branch in terms of Total(revenue) and Ratings</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00018-f4349a6f-faed-45cb-a080-c93960609bd5%3Fheight%3D209&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00018-f4349a6f-faed-45cb-a080-c93960609bd5%3Fheight%3D209&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="209" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca2b92df053abb977a66d596d27a5ea3/href">https://medium.com/media/ca2b92df053abb977a66d596d27a5ea3/href</a></iframe><p>In terms of <strong>Total Spent</strong> across the Branch, Branch C generated the highest total revenue across the 3 branches.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00019-272e75b8-743f-4855-b35b-199bea4a9576%3Fheight%3D209&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00019-272e75b8-743f-4855-b35b-199bea4a9576%3Fheight%3D209&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="209" frameborder="0" scrolling="no"><a href="https://medium.com/media/388fd8e44dfe79bb858a4334e003c09d/href">https://medium.com/media/388fd8e44dfe79bb858a4334e003c09d/href</a></iframe><p>In terms of <strong>Ratings</strong>, Branch C has the highest rating amongst the customers.</p><ul><li>Branch with the highest ratings amongst the different Customer types</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00020-bd1e6df7-606e-4ba0-9ce3-dbb7a20dc8ad%3Fheight%3D227&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00020-bd1e6df7-606e-4ba0-9ce3-dbb7a20dc8ad%3Fheight%3D227&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="227" frameborder="0" scrolling="no"><a href="https://medium.com/media/362c5709c2b8699562051d5b0e08cdfd/href">https://medium.com/media/362c5709c2b8699562051d5b0e08cdfd/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F64f9075d65d041f880b0d477f5e9c304%3Fheight%3D227&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F64f9075d65d041f880b0d477f5e9c304%3Fheight%3D227&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="227" frameborder="0" scrolling="no"><a href="https://medium.com/media/13e02887349500ba8c101b1e7fc97433/href">https://medium.com/media/13e02887349500ba8c101b1e7fc97433/href</a></iframe><p>We can see that when it comes to the different Customer types, <strong>Branch C</strong> still had the highest Ratings.</p><ul><li>Average spend on each branch</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00021-bc0dd6e1-9681-4eb0-b9df-da398e8af133%3Fheight%3D377&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00021-bc0dd6e1-9681-4eb0-b9df-da398e8af133%3Fheight%3D377&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="377" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd56153bcd44d0cf7dd9f1880f69f6ea/href">https://medium.com/media/bd56153bcd44d0cf7dd9f1880f69f6ea/href</a></iframe><p>From this graph, we can see that <strong><em>Branch C</em></strong> generate more average spending than <strong><em>Branch A</em></strong> /<strong><em>Branch B.</em></strong></p><p>2.<strong> City</strong></p><ul><li>Checking for the different Cities we have in our datasets</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00024-94bdf133-db41-4212-b930-859d4d92d4f7%3Fheight%3D189&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00024-94bdf133-db41-4212-b930-859d4d92d4f7%3Fheight%3D189&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="189" frameborder="0" scrolling="no"><a href="https://medium.com/media/ece4f3b464a25d9a6fc96c949536aef2/href">https://medium.com/media/ece4f3b464a25d9a6fc96c949536aef2/href</a></iframe><ul><li>Calculating the supermarket&#39;s gross income based on the city it’s in</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00025-d13c87bd-d264-464b-94dd-a893af817e13%3Fheight%3D784&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00025-d13c87bd-d264-464b-94dd-a893af817e13%3Fheight%3D784&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="784" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f560db848dbd218923e0d1c3d6dc041/href">https://medium.com/media/4f560db848dbd218923e0d1c3d6dc041/href</a></iframe><p>The supermarket in Yangon city had the highest gross income followed by the one in Mandalay city and Naypytaw city respectively.</p><ul><li>Prefered Payment Method across the 3 Cities</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00027-415019a4-da9f-4860-b4b2-d9d34517a57f%3Fheight%3D326.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00027-415019a4-da9f-4860-b4b2-d9d34517a57f%3Fheight%3D326.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b031587d9ace96b331b701aaf0657be/href">https://medium.com/media/0b031587d9ace96b331b701aaf0657be/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00028-843297c2-1cc2-49b0-b216-a96364ffc7c8%3Fheight%3D450&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00028-843297c2-1cc2-49b0-b216-a96364ffc7c8%3Fheight%3D450&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="450" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d6f8dcd87bd31fcffac6a38641af082/href">https://medium.com/media/5d6f8dcd87bd31fcffac6a38641af082/href</a></iframe><p>When it comes to the prefered method of payment across the 3 branches, the branch in the largest city being <strong>Yangon</strong> as well as the second largest city <strong>Mandalay</strong>, it shows that <strong><em>Ewallet</em></strong> is the most prefered payment method. <strong><em>Cash</em></strong> is the most prefered payment method in the less populated city of <strong>Napyitaw</strong>.</p><p><strong><em>Credit card</em></strong> ranked third as a prefered payment method in the 3 cities.</p><p>3.<strong> Customer Type</strong></p><ul><li>Checking for the different Customers we have in our datasets</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00031-9cacbbb9-bbd4-48e7-9276-eb7ff533e6ab%3Fheight%3D169&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00031-9cacbbb9-bbd4-48e7-9276-eb7ff533e6ab%3Fheight%3D169&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="169" frameborder="0" scrolling="no"><a href="https://medium.com/media/d078b4da8eaf93431ac3a872f5c2aabc/href">https://medium.com/media/d078b4da8eaf93431ac3a872f5c2aabc/href</a></iframe><ul><li>Distribution of payment preference on Customer type</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00032-977135d3-6fe2-4750-8b57-d3ed629d7143%3Fheight%3D416.6875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00032-977135d3-6fe2-4750-8b57-d3ed629d7143%3Fheight%3D416.6875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="416" frameborder="0" scrolling="no"><a href="https://medium.com/media/27f3b3a25b58435dbda471fd1f7fe187/href">https://medium.com/media/27f3b3a25b58435dbda471fd1f7fe187/href</a></iframe><ul><li>Comparing the supermarket customer type based on their gender</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00033-25eb7dfd-9f76-4227-9679-ec5758c13fe0%3Fheight%3D229&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00033-25eb7dfd-9f76-4227-9679-ec5758c13fe0%3Fheight%3D229&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="229" frameborder="0" scrolling="no"><a href="https://medium.com/media/de0ca06b4deedaa3a9f7b543da669eaa/href">https://medium.com/media/de0ca06b4deedaa3a9f7b543da669eaa/href</a></iframe><p>Most of the female customers are <strong>Members</strong> at 261 compared to male customers at 240, while most of the male customers are <strong>Normal</strong> at 259 with female <strong>Normal </strong>customers at 240.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00036-a67af106-5ad1-4ed8-bd78-d7e141400510%3Fheight%3D269&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%3A443%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00036-a67af106-5ad1-4ed8-bd78-d7e141400510%3Fheight%3D269&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="269" frameborder="0" scrolling="no"><a href="https://medium.com/media/786195ad77b90e9136cc9d5908bc370f/href">https://medium.com/media/786195ad77b90e9136cc9d5908bc370f/href</a></iframe><p>When comparing the customer type with their branch we find out that supermarkets in <strong>Branch A &amp; B</strong> have the highest customer number who are <strong><em>Normal, </em></strong>while <strong>Branch C</strong> has the highest in <strong><em>Member</em></strong> customer type.</p><p>4.<strong> Gender</strong></p><ul><li>Checking for the gender type value counts we have in our datasets</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00039-832a5b05-1338-4695-a96a-5fb29d8b38e5%3Fheight%3D169&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00039-832a5b05-1338-4695-a96a-5fb29d8b38e5%3Fheight%3D169&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="169" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e68491d33ae0ceb2b8983c2cf58da20/href">https://medium.com/media/7e68491d33ae0ceb2b8983c2cf58da20/href</a></iframe><p>The spread is evenly distributed amongst the male and female gender categories.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00044-2da31b6c-4ddb-4314-84f9-730c4c19ba95%3Fheight%3D389&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00044-2da31b6c-4ddb-4314-84f9-730c4c19ba95%3Fheight%3D389&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="389" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1c2004ec4f348465f04e87bdae52eb3/href">https://medium.com/media/f1c2004ec4f348465f04e87bdae52eb3/href</a></iframe><p>Female customers have the most purchases in Product lines (Fashion accessories, Food and beverage, sports and travel). While the male customers have the most purchases in Health and beauty, Electronic accessories.</p><p>5.<strong> Product Line</strong></p><ul><li>Checking for the different product lines we have in our datasets</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00047-cc83e825-8115-47d7-934c-3d700909a5d9%3Fheight%3D249&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00047-cc83e825-8115-47d7-934c-3d700909a5d9%3Fheight%3D249&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="249" frameborder="0" scrolling="no"><a href="https://medium.com/media/992da72fc2a78566350183dccf8cd734/href">https://medium.com/media/992da72fc2a78566350183dccf8cd734/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00048-70054f9b-dbe3-4878-a142-3bf353c899b3%3Fheight%3D730&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00048-70054f9b-dbe3-4878-a142-3bf353c899b3%3Fheight%3D730&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="730" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d9d0a62601b3d501f22eb00e9c8a6bf/href">https://medium.com/media/1d9d0a62601b3d501f22eb00e9c8a6bf/href</a></iframe><p>When it comes to sales based on Product Line Categories across all branches, <em>Fashion accessories</em> were the most sold at 17.8%(178) followed by <em>Food and beverages</em> at 17.4%(174) then <em>Electronic accessories</em> at 17%(170). <em>Sports and travel</em> items came in at fourth position with 16.6%(166) followed by <em>Health and lifestyle</em> products at 16%(160) and the product that had the lowest sales among the other categories was <em>Health and beauty</em> at 15.2% (152).</p><p>Worth noting is how the distribution of these products fell between 17% as the most sold and 15% as the least sold.</p><ul><li>The city with the highest sold product line</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00050-f7df0100-4dbf-4c17-895c-927138205aef%3Fheight%3D509&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00050-f7df0100-4dbf-4c17-895c-927138205aef%3Fheight%3D509&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="509" frameborder="0" scrolling="no"><a href="https://medium.com/media/777240c15dbba86d74aa5dd52b2bd819/href">https://medium.com/media/777240c15dbba86d74aa5dd52b2bd819/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00051-ce0d18b7-791e-460d-ace6-2cc31148ae4a%3Fheight%3D443.4375&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00051-ce0d18b7-791e-460d-ace6-2cc31148ae4a%3Fheight%3D443.4375&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="443" frameborder="0" scrolling="no"><a href="https://medium.com/media/d500b36f5b859294fdd13bd5efb01b4d/href">https://medium.com/media/d500b36f5b859294fdd13bd5efb01b4d/href</a></iframe><ul><li>Food &amp; beverages, and Fashion accessories were the most sold product in <strong>Naypyitaw City</strong>.</li><li>Electronic accessories, and Home &amp; Lifestyle were the most sold product in <strong>Yangon City</strong>.</li><li>Sport &amp; Travel, and Health &amp; beauty were the most sold product in <strong>Mandalay City</strong>.</li></ul><p>The plot helps in finding out how the specific product line sells per branch an example is how sports and travel, home and lifestyle sales are below 50 in <strong>Napyitaw</strong> compared to other branches while in <strong>Yangon</strong> branch health and beauty products sell below 50 compared to other branches.</p><p>6.<strong> Payment</strong></p><ul><li>Checking for the different payment options we have in our datasets</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00054-3674df90-3cfe-4c42-80e2-9f19a7e16357%3Fheight%3D189&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00054-3674df90-3cfe-4c42-80e2-9f19a7e16357%3Fheight%3D189&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="189" frameborder="0" scrolling="no"><a href="https://medium.com/media/234da9e86b9d4fb2027307e446e6f8f3/href">https://medium.com/media/234da9e86b9d4fb2027307e446e6f8f3/href</a></iframe><ul><li>Payment preference types based on Gender</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00055-ebcdee4e-b3f3-4b20-a7e6-19fa7e1f5fab%3Fheight%3D133.79999923706055&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00055-ebcdee4e-b3f3-4b20-a7e6-19fa7e1f5fab%3Fheight%3D133.79999923706055&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="133" frameborder="0" scrolling="no"><a href="https://medium.com/media/73a848e1f6bad603cc5c8bdd92a5ed2c/href">https://medium.com/media/73a848e1f6bad603cc5c8bdd92a5ed2c/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00056-bda46c6e-918a-4b4b-8bb1-0a00d4327ae4%3Fheight%3D712&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00056-bda46c6e-918a-4b4b-8bb1-0a00d4327ae4%3Fheight%3D712&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="712" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb6b6d9348e27b5d931f51e028824f47/href">https://medium.com/media/cb6b6d9348e27b5d931f51e028824f47/href</a></iframe><p>When we compare the payment type used across the genders we find out that <strong>Ewallet</strong> use among male customers at 18.5% was the prefered payment type, then <strong>Cash</strong> with 16.6%. For the female customers, <strong>**Cash**</strong> was the most prefered payment option at 17.8%, followed by Credit card with 16.3%.</p><p>7.<strong> Correlation</strong></p><p>We use the corr() function to display the correlation coefficients for different variables in our dataset<em>.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00066-b62beb42-62be-4867-a324-32d7aa5af597%3Fheight%3D778&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00066-b62beb42-62be-4867-a324-32d7aa5af597%3Fheight%3D778&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="778" frameborder="0" scrolling="no"><a href="https://medium.com/media/0af6ad374a0390eff84fa615c3ca296c/href">https://medium.com/media/0af6ad374a0390eff84fa615c3ca296c/href</a></iframe><p>From the heatmap above, we can see that the Total, cogs, Tax 5% , gross income are perfectly correlated. This is very considerable, so let&#39;s drop 3 of 4 columns (I choose cogs, gross income and Tax 5%).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00068-ce4c5e9f-3689-4e76-bfa9-971d53698c37%3Fheight%3D152.1875&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00068-ce4c5e9f-3689-4e76-bfa9-971d53698c37%3Fheight%3D152.1875&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="152" frameborder="0" scrolling="no"><a href="https://medium.com/media/71e9fc32f77ef0f0ed7d554ffac10b65/href">https://medium.com/media/71e9fc32f77ef0f0ed7d554ffac10b65/href</a></iframe><ul><li>Relationship between cities and branches</li></ul><p>Correlation only works on int &amp; float data types. So, we have to use scatterplot() to find the relationship for object data types.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00070-31235d79-26d5-45dc-bc55-67ede2fb1f7e%3Fheight%3D631&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00070-31235d79-26d5-45dc-bc55-67ede2fb1f7e%3Fheight%3D631&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="631" frameborder="0" scrolling="no"><a href="https://medium.com/media/66c95e58beec94a08096c80ba489f135/href">https://medium.com/media/66c95e58beec94a08096c80ba489f135/href</a></iframe><p>There is a relationship between <strong><em>City</em></strong> and <strong><em>Branch</em></strong>. Each branch is located in a specific city. So, we can also remove 1 of the columns (I removed <strong><em>City</em></strong> in this case).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00072-50682e60-8fdd-41eb-8c73-a918b2b3d64f%3Fheight%3D446.8000183105469&amp;display_name=Deepnote&amp;url=https%3A%2F%2Fembed.deepnote.com%2F39a8b93d-bec3-460e-bb8a-865b18e0ee52%2F1262c51e-8f4b-4de2-a14a-976680da0a1c%2F00072-50682e60-8fdd-41eb-8c73-a918b2b3d64f%3Fheight%3D446.8000183105469&amp;image=https%3A%2F%2Fdeepnote.com%2Fstatic%2Fthumbnails%2Fmain.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=deepnote" width="700" height="446" frameborder="0" scrolling="no"><a href="https://medium.com/media/67e8e7c74db61a8465993edc2acd2a67/href">https://medium.com/media/67e8e7c74db61a8465993edc2acd2a67/href</a></iframe><h4>SUMMARY BUSINESS INSIGHTS</h4><ol><li>From the dataset of a total of 1000 customers, we see that there is an equal percentage distribution between its male and female customers at 50% each. The dataset has an even distribution.</li><li>The most preferred payment type is Ewallet at 34.5% followed by Cash at 34.4% and Credit card at 31.1%. These differences are close to each other ranging between 30% and 34%.</li><li>Ewallet use among male customers at 18.5% was the preferred payment type compared to its female use at 16%.</li><li>When it comes to sales based on Product Line Categories across all branches, Fashion accessories were the most sold at 17.8% followed by Food and beverages at 17.4% then Electronic accessories at 17%. Sports and travel items came in at fourth position with 16.6% followed by Health and lifestyle products at 16% and the product that had its sales lowest among the other categories was the product line under Health and beauty at 15.2%.</li><li>The supermarket in Yangon city had the highest gross income followed by the one in Mandalay city and Naypytaw city respectively. This is because it is the largest city and Yangon is also a trade and logistics hub. Home to the country’s main air and sea ports.</li><li>There is a relation to high gross income with customer type being a member at 50.1% while a Normal customer at 49.9%.</li><li>Ewallet and Credit card have more Member and Normal customer types contributing above 40 gross income compared to both Member and normal customer types using cash.</li><li>Female customers have the most purchases in product lines (Fashion accessories, Food and beverage, sports and travel) while the male customers have the most purchases in Health and beauty with slight purchase differences in Home and lifestyle, electronic accessories.</li></ol><h4>CONCLUSION</h4><p>This is the end of the <strong>Exploratory Data Analysis(EDA)</strong> part, I touched a little bit of <em>Part 2</em> here where I removed some columns that are perfectly correlated. For Part 2, this is where the real fun part starts we get to make forecasts for Q2 using probability and use our <strong>EDA</strong> to <em>quantitatively</em> or <em>visually</em> justify any assumption that will be made in our solution. You don&#39;t want to miss this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75c3440d08bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Analysis Project for Retail: Sales Performance Report Using Python]]></title>
            <link>https://medium.com/@Jammaladeyemi/data-analysis-project-for-retail-sales-performance-report-using-python-2e6a9bca021e?source=rss-dd7d2ad11f3b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e6a9bca021e</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Jammal Adeyemi]]></dc:creator>
            <pubDate>Wed, 06 Jul 2022 13:32:58 GMT</pubDate>
            <atom:updated>2022-07-06T13:32:58.564Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*geEUTANhEQ14I8euv60rSA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler">Markus Winkler</a> on <a href="https://unsplash.com/photos/IrRbSND5EUc?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditShareLink">Unsplash</a></figcaption></figure><p>In the modern economy, business analytics is a powerful tool. Organizations produce enormous amounts of data across industries, which has increased the demand for specialists that are data literate and familiar with how to evaluate and analyze that data. In this article, we’ll look at a retail dataset spanning four years of transactions (2011 to 2014). The dataset, which was provided by <a href="https://blossom.africa/">Blossom Academy</a> in CSV format, relates to an international business that competes in the retail sector.</p><h3><strong>Let’s Dive In</strong></h3><p>We need to import the relevant libraries that would be useful for our analysis, and then, load the data into Pandas.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/307cc62c7281a9d922cec82c6ef8814b/href">https://medium.com/media/307cc62c7281a9d922cec82c6ef8814b/href</a></iframe><blockquote>Note: Make sure your dataset is located in the same folder as the Python script you are running. You must alter the read_csv option to point to the file’s location if you have it stored somewhere else.</blockquote><h4><strong>About Dataset</strong></h4><p>Let’s inspect our data. To do that, we can use .head() &amp; .tail() functions. The.head()gives us the first 5 rows while.tail() gives us the last 5. You can always specify any number of rows you want. In our case, we want to get the first 3 rows and the last 3 rows. We’ll get the following result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovpoYW155KAdlbUE7VOg1w.jpeg" /><figcaption>First 3 rows</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HA74yZzy3plrPRhU58w4gQ.jpeg" /><figcaption>Last 3 rows</figcaption></figure><p>Each row in the dataset corresponds to an order made by a customer. We have the following features:</p><pre><strong>Product:</strong><br>1. ProductID - Number assigned to each product ;<br>2. ProductName - The product name ;<br>3. Sub-Category - This is a subcategory of its parent category;<br>4. Category - This is the main category that helps group products of similar nature (sub-categories);<br>5. Quantity - The quantities of each product per transaction;<br>6. Discount - The amount deducted from the original price;<br>7. Sales - The total amount;<br>8. Profit - The financial gain from the sales.</pre><pre><strong>Customer:</strong><br><em>1. CustomerID</em> - Number assigned to each customer;<br>2. CustomerName - The customer&#39;s name ;<br>3. Segment - The company&#39;s target market into groups of potential customers; <br>4. City - City where each customer resides;<br>5. State - State where each customer resides ;<br><em>6. Country</em> - Country where each customer resides;<br>7. Market - Market where each customer resides;<br>8. Region - Region where each customer resides.</pre><pre><strong>Others features: </strong><br>1. Order ID - Number assigned to each order; <br>2. Order Date - The date the order was made; <br>3. Ship Date - The date the product was shipped; <br>4. Shipping Cost - The cost it takes to ship an item;<br>5. Order Priority - How fast each customer wanted the products to be delivered to them;</pre><h4><strong>Basic Data Checkup</strong></h4><ul><li><strong>Get Dataset Info</strong></li></ul><p>We use the info() function to identify the data types and some basic information on the content of the DataFrame<em>.</em>df.info()<em> </em>should return a list of all the columns in our dataset (24 columns in total), 51290 entries (rows), and data type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*01XW2a4fpGFqFZdYR9gTMA.jpeg" /><figcaption>Dataset Info</figcaption></figure><p>The dataset contains over 50,000 transactions made by customers, fifteen of our columns have the object data type, two columns have the <em>int64</em> data type, two columns have the datatime64[ns]<em> </em>data type and five columns have the float64data type.</p><ul><li><strong>Check for Missing Values</strong></li></ul><p>In data science projects, missing values (also known as missing data or NaN) are a frequent issue that can result in inaccurate analysis and have a substantial impact on results. This can be the result of incorrect data being inputted, unavailable data, or a programming error.</p><p>The isnull() function returns false if we do not have missing values and true<em> </em>otherwise. The sum() function returns the sum of those missing values in each column. We could also use the .sort_values() function with the ascending=False parameter to sort the output in descending order as we can see below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*n1bRvwT-0yY3l43gRI7Fnw.jpeg" /><figcaption>Missing values</figcaption></figure><p>This output shows us more clearly that the <em>Postal Code</em> column has 41,216 missing values which is up to 80% of the total entries.</p><ul><li><strong>Check for Unique Values</strong></li></ul><p>We use the Unique() function to identify the Unique values of each column of the Data. For example, Ship Mode has 4 unique values i.e they are only 4 different inputs in all the 51290 entrees.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8dc21eb2c18f70d394552857e4c6d0bc/href">https://medium.com/media/8dc21eb2c18f70d394552857e4c6d0bc/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ky-7MdksRsGPehN2dlxHeg.jpeg" /></figure><ul><li><strong>Summary Statistics</strong></li></ul><p>This part gives some statistical information from the numerical column (default). Mean, percentile, max &amp; min values, and other statistics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*xiI3eN_qHZca_jXWdWXMIg.jpeg" /><figcaption>Summary Statistics</figcaption></figure><ul><li><strong>Visualizing the Correlation Matrix</strong></li></ul><p>We use the corr() function to display the correlation coefficients for different variables in our dataset<em>.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dec349bce651c60d41131d1984b13139/href">https://medium.com/media/dec349bce651c60d41131d1984b13139/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*l3apPQf6ot8GryPhrYj9Lw.jpeg" /><figcaption>Correlation coefficients of different variables</figcaption></figure><p>A correlation coefficient is a value between -1 and 1 that indicates the degree and direction of a link between two variables. In other words, it shows how comparable two or more variables’ measurements are across a dataset.</p><p>1 is a Perfect positive correlation which means when one variable changes, the other variables change in the same direction.</p><p>0 is Zero correlation which means there is no relationship between the variables.</p><p>-1 is a Perfect negative correlation which means when one variable changes, the other variables change in the opposite direction.</p><h4><strong>Data Cleaning and Manipulation</strong></h4><p>The following step is data cleaning, which is based on the information gleaned during the exploratory phase.</p><ul><li><strong>Drop unnecessary column(s)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*OaEbphQwgXUc6_1haF6PiA.jpeg" /><figcaption>Drop column ‘Row ID’ and ‘Postal Code’</figcaption></figure><p>The columnRow ID has no specific meaning, it’s like an index column. The Postal Code has quite a lot of missing values and it doesn&#39;t affect the datasets.</p><ul><li><strong>Add New Necessary Columns</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc559c7c72d87929a953101a71695fe3/href">https://medium.com/media/fc559c7c72d87929a953101a71695fe3/href</a></iframe><ol><li>Unit Price — Here we divided the Sales column over the Quantity column, to find out how much the product co</li><li>The month and year columns are gotten from the Order Date column. We want to have 2 separate columns of Month and Year that show the months the order was made and the corresponding year.</li></ol><h4><strong>Answering Business Questions</strong></h4><pre><strong>1. Sales &amp; Profit Per Market</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7FlUFIKwDCpHIf2tDJqiKQ.jpeg" /><figcaption>Sales &amp; Profit per Market</figcaption></figure><p>The company makes the most sales &amp; profit from the APAC Market, while they make the least sales &amp; profit from the Canada Market</p><pre><strong>2. Products that are least bought</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*Qo_A-rS5lx0lXNxL77EsJA.jpeg" /><figcaption>Product sales</figcaption></figure><p>So these are the products that are least bought across all the markets and countries in the dataset.</p><pre><strong>3. Which Month does the company record more sales?</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*rXkxPvLOH7f8lotRjhGmQg.jpeg" /><figcaption>Month</figcaption></figure><p>The company records more sales in November and December as shown in the bar chart above.</p><pre><strong>4. The trend of sales for each year</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R04e10fULZCkdJpfF1KFsA.jpeg" /></figure><p>In 2011, the company made its highest sales in December and its lowest sales in April. In 2012, the company made its highest sales in December and its lowest sales in February. In 2013, the company made its highest sales in November and its lowest sales in February. In 2014, the company made its highest sales in November and its lowest sales in February. In general, in 2014 the company recorded its highest sales in the market. Also, there is a need to find out why the company sales take a big drop in July across all years.</p><pre><strong>5. The trend of profit for each year</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_r_cYOThewLnbCn9-eTLeg.jpeg" /></figure><p>In 2011, the company made its highest profit in December and its lowest profit in July. In 2012, the company made its highest profit in August and its lowest profit in February. In 2013, the company made its highest profit in November and its lowest profit in September. In 2014, the company made its highest profit in November and its lowest profit in July. In general, in 2014 the company recorded its highest profit in the market.</p><pre><strong>6. The general trend of sales from 2011–2014</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*KD8GGWo3OUEqITgWXwlFDw.jpeg" /><figcaption>General Trend</figcaption></figure><p>As noted before, we could see that 2014 recorded the highest sales made by the company.</p><pre><strong>7. Does the shipping cost affect the sales?</strong></pre><p>From the correlation graph above, the correlation coefficient between Shipping cost&amp; Sales is <strong>0.77</strong>. From my explanation earlier, this is a +ve correlation type and a very strong correlation strength which means that yes the Shipping cost affects the Sales.</p><pre><strong>8.</strong> <strong>What is the dominant product category in each market?</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qH11cg3IZFgheMpLimkcOA.jpeg" /><figcaption>Product Category</figcaption></figure><p>The most dominant product category in the market is <strong>Technology</strong> and the least dominant is <strong>Office Supplies</strong>.</p><pre><strong>9. The city with the most orders for a given product category?</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AP5R8qIA1zSFN6PLD8db1Q.jpeg" /></figure><p>New York City makes the most order across the 3 categories that we have, and Los Angeles comes in second followed by the rest.</p><pre><strong>10. Which products are making a loss?</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*xdDwRKdA0Uz5Aue8uusVNg.jpeg" /><figcaption>Sub-category Profit chart</figcaption></figure><p>Tables Sub-category makes a negative profit which isn’t good in general.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*xhTPoW-JZhLlBZURdM1PVw.jpeg" /><figcaption>Product with -ve profit</figcaption></figure><p>A lot of the products make a negative profit but these are the top 15 products that give a negative profit.</p><pre><strong>11. Which segment provides more profit?</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*YparrJ-whuC0ltHescgC3A.jpeg" /><figcaption>Segment</figcaption></figure><p><strong>Consumers</strong> provide more profit to the company compared to <strong>Home Office</strong> which makes the least profit.</p><pre><strong>12. What is the correlation between shipping cost and profit?</strong></pre><p>From the correlation graph above, the correlation coefficient between Shipping Cost&amp; Profit is <strong>0.35</strong>. From my explanation earlier, this is a +ve correlation type and a moderate correlation strength.</p><pre><strong>13. Which order priority yields more sales?</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*wtB2rPMtvRAd3vJwRjeMxA.jpeg" /></figure><p>The <strong>Medium</strong> Order Priority yields more sales.</p><pre><strong>14. What is the average shipping cost to each region?</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*6lJCsEmBdc2jAA7RA_3_aA.jpeg" /></figure><p><strong>North Asia</strong> Region has the highest average shipping cost</p><h4>Key Findings</h4><p>After thoroughly examining our data, we have come to several various conclusions:</p><ol><li>There has been a great significant increase in sales in the company over years despite some shortcomings.</li><li>New York &amp; Los Angeles City made the most order for all product categories.</li><li>The technology category is the most dominant category in the 7 markets that we have.</li><li>Sales &amp; Profit takes a dip during July across all years and the company makes the most sales between November and December.</li><li>The customer segment makes the most profit.</li><li>The shipping cost affects sales as we can see that they are strongly correlated.</li></ol><p>From the business angle, based on our findings we would recommend the following to stakeholders of the company:</p><ol><li>The company should stop selling products that the profit is negative as that is a loss to the company.</li><li>Reduce discounts in cities where we have high discounts but low profits.</li><li>For the company to increase customer satisfaction, the relationship between shipment interval and cost needs to be improved. There also needs to be a yardstick for proximity, distance, quick delivery, and longer delivery times.</li><li>In regions and countries with low sales, the company should increase product marketing and advertising.</li></ol><h4>Summary</h4><p>The purpose of this article was to outline the procedures I used to analyze a retail dataset. To begin, I performed some tasks like removing missing values from datasets, creating new columns, and changing the data type of columns (to_datetime). Then the article moves to the Exploration data Analysis where we explore questions at the business level related to our data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e6a9bca021e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>