<?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 Mohsin Zafar on Medium]]></title>
        <description><![CDATA[Stories by Mohsin Zafar on Medium]]></description>
        <link>https://medium.com/@mohsin.zafar?source=rss-a891da839a07------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QG-Lv4O7_tmUcj8zmwaRUw.jpeg</url>
            <title>Stories by Mohsin Zafar on Medium</title>
            <link>https://medium.com/@mohsin.zafar?source=rss-a891da839a07------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 13:52:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohsin.zafar/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[Meet Mohsin, Data Scientist]]></title>
            <link>https://medium.com/trusted-data-science-haleon/meet-mohsin-data-scientist-656612c6c58c?source=rss-a891da839a07------2</link>
            <guid isPermaLink="false">https://medium.com/p/656612c6c58c</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[data-scientist]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mentoring]]></category>
            <category><![CDATA[meet-the-team]]></category>
            <dc:creator><![CDATA[Mohsin Zafar]]></dc:creator>
            <pubDate>Mon, 15 Jul 2024 08:02:40 GMT</pubDate>
            <atom:updated>2024-07-15T08:02:40.015Z</atom:updated>
            <content:encoded><![CDATA[<h4>by<a href="https://medium.com/@mohsin.zafar"> Mohsin Zafar</a></h4><p>My name is Mohsin Zafar, and I am a Data Scientist based in London, UK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*Cl2uQO8xozIYhhnLgVpEaw.png" /><figcaption>Mohsin</figcaption></figure><h3><strong>A little bit about me</strong></h3><p>I have a background in Mathematics from the University of Warwick, with over five years of experience working as a Data Scientist in London. Currently, I am involved in diverse data science projects at Haleon, where I use data to drive innovation and informed decisions in the healthcare industry.</p><p>A fun fact about me: I <em>love</em> learning languages. My parents are from Pakistan, so I speak Urdu and Hindi. I grew up in Germany, so I speak German natively and spent an academic year abroad in Spain which allows me to practice my Spanish. Additionally, I started learning Arabic this year as well, which I am super excited about!</p><h3>What did I want to be when I grew up?</h3><p>Growing up, I had a passion for gaining knowledge and improving people’s lives. In school, I was inspired by scientists like Al-Razi (Rhazes), known for his work in medicine and chemistry. Learning about his discoveries, such as pioneering the use of alcohol in medicine and developing early antiseptics, in my biology class motivated me to pursue science further. His medical innovations, which have helped many fuelled my desire to pursue a career in STEM.</p><p>As I grew older, I found a strong affinity for mathematics, leading me to pursue a degree in the field. My goal was to combine my maths skills with my knowledge of science, biology, and chemistry to contribute to advancements in these areas. I am very fortunate that being a Data Scientist at Haleon allows me to realise my childhood passion as I work on projects that support and enhance scientific research and innovations that improve people’s lives.</p><h3>Why did I choose this career path?</h3><p>During my year abroad at the University of Barcelona in Spain, I had the chance to take some master’s courses in their data science program. I took classes like Introduction to Machine Learning Models, Time Series Analysis, and Computer Vision. I enjoyed these subjects and fell in love with the idea of combining mathematics with programming to develop machine-learning models and statistical forecasts.</p><p>After that year abroad, I knew this was the direction I wanted to go. I wanted a career that combined programming with heavy use of mathematics and statistics, and data science was the perfect fit. This path keeps me intellectually stimulated and brings me immense joy.</p><h3>How Do I Keep Up With the Field?</h3><p>Staying current in data science is essential. I regularly read research papers and articles from top journals and websites. Also attending webinars, and conferences from groups such as GraphQL and Pydata. I like taking online courses from platforms such as Linkedin Learning, Coursera and MIT OpenCourseWare to keep up with new developments. I try to take part of data science communities, both online and offline, which allows me to learn from others and share ideas.</p><h3>What’s Your Top Tip for Anyone Who Wants to Enter the Field?</h3><p>My top tip for aspiring data scientists is to build a strong foundation in math, statistics, and programming. These skills are crucial for understanding data science techniques. Work on practical projects to apply what you learn and build a portfolio. Having a personal blog and creating videos can also help you stand out from the competition. Stay curious and keep learning, as the field is always evolving. This approach will help you stand out and succeed in data science.</p><h3>What do I like most about working at Haleon?</h3><p>Haleon’s motto of “Everyday Health with Humanity” and its mission to deliver better health wherever they can deeply resonate with my childhood dream of using science and technology to improve people’s lives. This alignment of passions is what drew me to Haleon and has kept me motivated throughout my career.</p><p>At Haleon, I work with incredibly brilliant and humble individuals. The environment is collaborative and supportive, and I never hesitate to ask questions, whether from seniors, juniors, or colleagues across the globe. Everyone is down-to-earth and committed to both professional and personal growth.</p><p>We also have an amazing team of junior data scientists who go above and beyond to master both the technical and professional skills they need. Mentoring them ties in with one of my passions: teaching. It’s a great joy to guide them and watch them grow over time. This dynamic and nurturing environment makes working at Haleon truly fulfilling for me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=656612c6c58c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trusted-data-science-haleon/meet-mohsin-data-scientist-656612c6c58c">Meet Mohsin, Data Scientist</a> was originally published in <a href="https://medium.com/trusted-data-science-haleon">Trusted Data Science @ Haleon</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Reinforcement Learning to track marketing spend]]></title>
            <link>https://medium.com/trusted-data-science-haleon/using-reinforcement-learning-to-track-marketing-spend-db67e843476b?source=rss-a891da839a07------2</link>
            <guid isPermaLink="false">https://medium.com/p/db67e843476b</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[case-study]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[marketing]]></category>
            <dc:creator><![CDATA[Mohsin Zafar]]></dc:creator>
            <pubDate>Tue, 16 May 2023 09:17:55 GMT</pubDate>
            <atom:updated>2023-05-19T08:47:37.770Z</atom:updated>
            <content:encoded><![CDATA[<p><em>by </em><a href="https://medium.com/@mohsin.zafar"><em>Mohsin Zafar</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XX_QbtSnCq4zSrSCnE5OAQ.jpeg" /><figcaption>Image by <a href="https://pixabay.com/users/472301-472301/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2187996">Shahid Abdullah</a> from <a href="https://pixabay.com//?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2187996">Pixabay</a></figcaption></figure><h3>Introduction</h3><p>At Haleon, the marketing team is investigating the use of reinforcement learning to obtain granular insights and inferences about marketing spend allocation. To help achieve this, the Data Science team are working with marketing to develop an internal Data Science tool that allows for the obtaining of fine-grained insights and inferences regarding the distribution of marketing spend, and provides insights on ROI across different audiences. It aims to provide solutions to questions like “Did this audience buy the product after seeing an advertisement? If so, should we maximise this Advertising Group’s (AdGroup) budget allocation?”. Answers to these questions help the business to make data-driven decisions on how to allocate marketing spending for optimal ROI. The granular insights and inferences obtained through the project also help the company to identify areas where it can reduce waste and optimise its budget, thereby maximising the effectiveness of its marketing efforts.</p><p><strong>What are AdGroups?</strong> AdGroups are groups of related keywords used by advertisers to organise their advertising campaigns. Here are three examples:</p><p>1. Outdoor Adventure Enthusiasts: keywords might include “backpacks,” “tents,” “camping gear,” and “hiking boots.”</p><p>2. Skin care: keywords might include “acne treatment,” “anti-aging creams,” “moisturisers,” and “sunscreen.”</p><p>3. Nutrition: keywords might include “vitamins and supplements,” “healthy eating plans,” “meal delivery services,” and “superfoods.”</p><p>For example, questions asked by one of our marketing campaign managers could be something like, “Given the performance to date with respect to dentists, should we change the spend allocation in coming weeks and how?”</p><p>To get from the business question to the data science, we would interpret this as “Given the performance to date amongst dentists, create a model to recommend optimum spending for the future.”</p><p>Judging success in this scientific endeavour could be: minimising acquisition costs and increasing conversion rates. Within a campaign or bundle of campaigns, make sure ROI rises with time.</p><h3>The Focus of Reinforcement Learning x Marketing AdGroups project</h3><p>This project concentrates on improving the search channels where there are chances to have an uplift given marketing spend. Part of the project is also to understand the causality of growth drivers. In short, we want to maximise conversion rates while minimising cost-per-acquisition. The data used for the project is initially collected by a marketing data provider<strong> </strong>and passed to <strong>a third-party firm</strong> which processes the transactional data and performs aggregations according to pre-agreed metrics. This aggregation is then shared with the Data Engineering team who runs several scripts to query and transform the data. Below is the schema of the final transformed data.</p><figure><img alt="Schema representation for the data that is used in the model" src="https://cdn-images-1.medium.com/max/1024/1*AImqdMziso1m8lfO5rcPHQ.png" /><figcaption>Schema Representation for the project — developed by Haleon’s Data Engineering Team</figcaption></figure><p>The technical stack that was used includes Microsoft Azure for cloud management, python packages like PySpark, statsmodels, SciPy and scikit-learn for model development. Furthermore, our final output is displayed in a self-service tool that uses a Power-BI dashboard to show the above information to the end users, our marketing campaign managers.</p><p>To understand our implementation of the project better, it’s good to have a grasp of the multi-arm problem with respect to marketing and some of the solutions to that problem.</p><h3>The Multi-Arm Problem with Respect to Marketing</h3><p>A multi-armed bandit problem, in the context of marketing, is a more sophisticated version of A/B testing that employs machine learning algorithms to dynamically allocate traffic to variations or AdGroups that are performing well while distributing less traffic to variations and AdGroups that are underperforming. The phrase “multi-armed bandit” originates from a fictitious experiment in which a player must select from a variety of options (slot machines/AdGroup, or “one-armed bandits”), each with an undetermined reward. Through a sequence of options, the objective is to identify the best or most advantageous result. The player (marketing manager) must choose which machines (AdGroup) to pull (invest money in), in what order, and how many times at the start of the experiment while odds and payouts are unknown.</p><p>A key feature of a multi-armed bandit problem is the trade-off between exploration and exploitation:</p><p>· Exploration: Find out more information about each arm.</p><p>· Exploitation: Choose the best arm so far.</p><figure><img alt="A group of 4 friends playing Tug of War. Two people on each side" src="https://cdn-images-1.medium.com/max/640/1*FOuoyZPFdEMZRNciKQo1YA.jpeg" /><figcaption>Tug of War: Exploration vs Exploitation — Photo by <a href="https://www.pexels.com/@edmond-dantes/">Edmond Dantès </a>on <a href="https://www.pexels.com/photo/people-playing-tug-of-war-8556606/">Pexels</a></figcaption></figure><h3>A Solution to the Multi-Armed Bandit Problem: Thompson Sampling</h3><p>Computer scientists have created a wide range of solutions to the multi-armed bandit problem. Some of the most popular methods include Epsilon-Greedy, Upper Confidence Bound (UCB), Bayesian Bandits. The algorithm we chose for our problem is called Thompson Sampling (Bayesian).</p><p>The idea of Thompson Sampling is that the amount of money invested for each AdGroup should reflect the likelihood that it will really be the best lever using this randomised probability matching procedure. This method is probabilistic, based on Bayesian ideas. As each choice of investment is selected at random from a probability distribution, this process is known as sampling.</p><p>Thompson Sampling can efficiently balance the exploration-exploitation tradeoff in reinforcement learning, making it a popular choice for optimising AdGroups in marketing projects. It is more robust to uncertainty and variable data than other algorithms and is relatively easy to implement and interpret. Overall, Thompson Sampling is a powerful and flexible algorithm that can be highly effective in optimising AdGroups in this marketing project, which is the reason why we chose to use Thompson Sampling for this project.</p><h3>Thompson Sampling — A Deep Dive</h3><p>The traditional way of Thompson sampling is a Bayesian algorithm and the intuition behind it is as follows:</p><p>1. All groups are assumed to have a very flat normal distribution (very large variance) of success.</p><p>2. Samples are obtained one at a time from a randomly sampled machine.</p><p>3. Then for each observed finding from a given group based on the reward, the distribution is updated with probabilities of success for each slot machine.</p><p>4. As more samples are obtained, the success distributions are updated, and the distributions become narrower. This then helps the player in choosing the machines wisely to get the maximum rewards as they can determine which machines consistently give the highest rewards.</p><p>The way a particular group is chosen by looking at the current probability distribution of each AdGroups and then choosing a random point based on each distribution. Methods such as Inverse Transform Sampling can be used for this. Then from sample and their probability distributions, the highest sample (if maximising KPI) will be chosen in which case it is A. The outcome from A is then observed and the probability distribution for A is then updated.</p><p>The confidence in the estimated mean grows with the number of observations. The probability distribution narrows as a result, and the sampled value is then chosen from a set of values that is more closely related to the genuine mean. Due to the increased frequency with which the AdGroups with a higher likelihood of returning a reward would be chosen, exploration reduces and exploitation rises as a result.</p><p>Meanwhile, AdGroups with a low estimated mean will begin to be picked less frequently and have a tendency to be eliminated sooner from the selection process. As a result, their true mean might never be discovered. It isn’t so important if full information of poorly performing AdGroups is never updated because the main priority to us is swiftly locating the AdGroups with the highest likelihood of benefitting the advertising campaign.</p><h3>Thompson Sampling on our AdGroups Project</h3><p>First, we start off by defining several audiences or AdGroups. We then assign a default flat distribution to each audience. The metric could be click-through rate (CTR), cost per clickable (CPC), or cost per action (CPA). The definition of the metrics is below:</p><ul><li>Click-through rate (CTR) can be used to gauge how well your keywords and ads, and free listings, are performing. It’s a ratio showing how often people who see your ad or free product listing end up clicking it.</li><li>Cost-per-click (CPC) means how much you pay for each click on your ads.</li><li>Cost per action (CPA) is calculated by dividing the total cost of conversions by the total number of conversions.</li></ul><figure><img alt="A dashboard showing line charts of different marketing metrics" src="https://cdn-images-1.medium.com/max/1024/1*n7_dHlYt_6XDFM4HaK5_ag.jpeg" /><figcaption>Marketing metrics displayed on a dashboard — Photo by <a href="https://unsplash.com/@hostreviews">Stephen Phillip</a>s on <a href="https://unsplash.com/photos/shr_Xn8S8QU">Unsplash</a></figcaption></figure><p>One of the reasons we chose to use Thompson sampling is because it is a great way to create and update statistical distributions. At the start of the campaign, we are assuming that each has the same uniform distribution. We could have an idea of what the distribution may look like for certain AdGroups. For example, people into fitness are more likely to buy protein snacks than people that love travelling. To put our intuition with unknown statistical parameters into a quantitive statistical distribution, we would need a model that can create those statistical distributions for us. That is where Thompson sampling comes in handy as it is very good at creating distributions with little data inputs and minimal waste as it uses a Bayesian approach to deal with the exploration-exploitation dilemma.</p><p>Since we are sampling a known finite dataset, we are iterating through each AdGroup per trial at the same time. This helps us get a better understanding of the</p><p>AdGroups in our dataset since all the data is being used. The implementation of the Thompson Sampling algorithm then updates the distribution for each audience through iteration of our dataset which causes the flat distribution to shift to our statistical distribution chosen at the beginning of the algorithm. So, for example, if our distribution of choice is a Gaussian distribution then our flat distribution, a Gaussian distribution with a very large standard deviation, shifts to a more bell curve shape. The more information we input, the narrower this distribution will become. This update works by iterating through each audience on each day of the inputted dataset and using the target metric to update our known mean and standard deviation. Once the iteration has been completed, we will get a statistical distribution for each audience.</p><figure><img alt="6 AdGroups probability distribution" src="https://cdn-images-1.medium.com/max/1024/1*dqNqCC6OQLwazvCN5lCpTQ.png" /><figcaption>Distribution outputs for Thompson Sampling across different AdGroups</figcaption></figure><figure><img alt="6 AdGroups probability distribution" src="https://cdn-images-1.medium.com/max/1024/1*wlRK_wmf1vkTQO8DkwWizQ.png" /><figcaption>Distribution outputs for Thompson Sampling across different AdGroups</figcaption></figure><h3>Recommendations Optimiser</h3><p>Now that we know the statistical distributions of each AdGroup using Thompson Sampling we can determine future recommendations and budget allocation for each AdGroup since we have their distributions. This is accomplished by choosing a random number from each audience distribution using the `draw()` method.</p><p>As an illustration, say we have obtained four statistical distributions for different AdGroups using our Thompson sampling method. For the sake of simplicity let us give a name for each AdGroup, namely Green, Blue, Orange, and Red.</p><p>Now using the selection of a random number from each distribution we might obtain the following:</p><p>Green: 100, Blue: 75, Orange: 300, Red: 500.</p><p>If we want to maximise our marketing metric (such as Conversion Rate), we choose Red (500), while if we want to minimise our marketing metric (such as Exit Rate), we choose Blue (75). The metric we want to minimise and maximise depends on the marketing campaign manager and their goals for the project. We award the winner of our first trial one point based on our selection metric.</p><p>So, after repeating the process a total of 100 trials, we can get points assigned like this:</p><p>· Total Picks = 100</p><p>· Green: 40</p><p>· Blue = 30</p><p>· Orange = 20</p><p>· Red = 10</p><p>The budget allocation for that audience will now be determined by the percentage of times that audience is chosen in all draws. The budget in the aforementioned case would seem as follows:</p><p>Green: 40%, Blue: 30%, Orange: 20%, Red: 10%.</p><p>The campaign managers will then use a data dashboard to receive this information and decide how to spend the budget.</p><figure><img alt="Marbles coming out of a yellow bag" src="https://cdn-images-1.medium.com/max/640/1*Bi4hhZ22GfvY-g_I_R4WlA.jpeg" /><figcaption>A bag of marble where you can randomly select the colour of the marble. — Photo by <a href="https://unsplash.com/@crissyjarvis">Crissy Jarvis</a> on <a href="https://unsplash.com/photos/1kZzV02D2hM">Unsplash</a></figcaption></figure><h3>Contextual Bandit: Human Intervention</h3><p>As mentioned previously, the multi-armed bandit algorithm generates a result, however, it doesn’t consider the status of the surrounding environment (context). This is where our campaign managers step in to use the data to alter the surroundings or context to boost the effectiveness of the marketing effort. By making the choice contingent on how the environment is behaving, the contextual bandit broadens the model. For example, a certain AdGroup prefers to see the colour blue so you make sure your model can facilitate that automatically.</p><p>With such a model, you may not only personalise decisions for each AdGroup and situation while optimising decisions based on prior observations. The algorithm looks at a situation, decides between a few possible courses of action, and then evaluates the results of that decision. Rewards are determined by results. You want to maximise the return from your contextual bandit strategy, but you also want to minimise the loss while you investigate various bandits. The regret metric, which compares the cumulative reward from the best policy to the model’s cumulative total of rewards over time, is used to assess a model’s performance. The model performs better the smaller the regret.</p><h3>Conclusion</h3><p>Through this project, we have addressed the Multi-Arm Problem in marketing using Thompson sampling. By implementing this algorithm, we were able to optimise our AdGroups and achieve higher ROI and budget savings. Thompson sampling helped balance exploration-exploitation tradeoff and allocate traffic to better performing AdGroups, optimising the budget and maximising marketing effectiveness. Due to the continual change in the preferences of our target audiences, the importance of human intervention was also highlighted in the form of the Contextual Bandit approach.</p><p>Overall, the project has led to significant savings in the marketing budget, while also increasing conversion rates and minimising cost-per-acquisition. The project’s success has demonstrated the power of reinforcement learning in solving complex business problems and the value it can bring to the field of marketing technology.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db67e843476b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trusted-data-science-haleon/using-reinforcement-learning-to-track-marketing-spend-db67e843476b">Using Reinforcement Learning to track marketing spend</a> was originally published in <a href="https://medium.com/trusted-data-science-haleon">Trusted Data Science @ Haleon</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>