<?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 Paula Maldonado on Medium]]></title>
        <description><![CDATA[Stories by Paula Maldonado on Medium]]></description>
        <link>https://medium.com/@pcmaldonado?source=rss-23e38bdb70ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QYcYN3qz93sFeiqtdaBGVw.png</url>
            <title>Stories by Paula Maldonado on Medium</title>
            <link>https://medium.com/@pcmaldonado?source=rss-23e38bdb70ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 06:29:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pcmaldonado/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[Guide to Using Descriptive Statistics in Data Science]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/guide-to-using-descriptive-statistics-in-data-science-238527b3aaf3?source=rss-23e38bdb70ce------2"><img src="https://cdn-images-1.medium.com/max/2400/0*woJAoGYlpo-Tmys5" width="2400"></a></p><p class="medium-feed-snippet">Understand the key concepts to summarize data</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/guide-to-using-descriptive-statistics-in-data-science-238527b3aaf3?source=rss-23e38bdb70ce------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/guide-to-using-descriptive-statistics-in-data-science-238527b3aaf3?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/238527b3aaf3</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Thu, 05 May 2022 20:02:39 GMT</pubDate>
            <atom:updated>2022-05-14T15:36:54.312Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Useful Git Commands for Beginners]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/useful-git-commands-for-beginners-e02cf45c5fde?source=rss-23e38bdb70ce------2"><img src="https://cdn-images-1.medium.com/max/2600/0*lDda9hPDpffZC5nf" width="6000"></a></p><p class="medium-feed-snippet">Besides add, push and pull</p><p class="medium-feed-link"><a href="https://medium.com/codex/useful-git-commands-for-beginners-e02cf45c5fde?source=rss-23e38bdb70ce------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/useful-git-commands-for-beginners-e02cf45c5fde?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/e02cf45c5fde</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Mon, 02 May 2022 02:05:58 GMT</pubDate>
            <atom:updated>2022-05-14T15:36:16.049Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to use Deep Learning to identify dog breeds]]></title>
            <link>https://medium.com/@pcmaldonado/how-to-use-deep-learning-to-identify-dog-breeds-c4266adb4f15?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4266adb4f15</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[udacity-nanodegree]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Wed, 20 Apr 2022 16:27:16 GMT</pubDate>
            <atom:updated>2022-05-13T19:37:00.775Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using Convolutional Neural Networks and Transfer Learning to build a dog breed classifier</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L893enzevZ7LWIlK" /><figcaption>Photo by <a href="https://unsplash.com/@jamie452?utm_source=medium&amp;utm_medium=referral">Jamie Street</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In an age where people constantly share images, it can be very useful to know how to analyze them and create value from them.</p><p><strong>Image classification</strong>, for example, can be very helpful. There are hundreds of breeds of dogs in the world, and for non-experts, it can be very difficult to identify them correctly.</p><p>In this project, we will see how, using <strong>Convolutional Neural Networks (CNNs) </strong>and <strong>transfer learning</strong>, we are able to create a model that can identify the breed of a dog and even tell you what breed of dog you look like!</p><h3>Metrics</h3><p>To measure and compare different models’ performance, we will use <strong>accuracy</strong>, i.e. the number of good predictions divided by the total number of predictions.</p><p>Moreover, we can use this metric because even if the classes are slightly imbalanced -as we will see below- since we have a large number of possible breeds (133 in our dataset), if we simply predicted the most popular breed for every dog or applied random guessing, we would have very low accuracy. Thus, accuracy will give us a good overall sense of how the model is doing.</p><p>For optimizing the model, the loss function used is the <strong>categorical cross-entropy</strong> loss function, which is often used in multi-class classification tasks. Moreover, when training our CNNs, a validation set will be used to see how well the model generalizes, and at each epoch, the best model will be saved.</p><h3>Overview</h3><p>The project contains several steps:<br>· <a href="#8396">EDA</a><br>· <a href="#5fdb">Modeling</a><br> ∘ <a href="#591c">a. Detecting Human Faces</a><br> ∘ <a href="#b7d7">b. Detecting Dogs</a><br> ∘ <a href="#9270">c. Building a CNN from Scratch</a><br> ∘ <a href="#ec59">d. Building a CNN using Transfer Learning</a><br>· <a href="#8588">Results</a><br> ∘ <a href="#a2a9">Predicting dog breeds</a><br>· <a href="#4c7a">Conclusion</a><br>· <a href="#d8bb">Improvements</a></p><p>To access the full code, check the <a href="https://github.com/pcmaldonado/Dog_Breed_Classification">GitHub</a> repository.</p><h3>EDA</h3><p>First of all, we will use two datasets, one containing labeled <a href="https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/dogImages.zip">dog images</a>, and another one containing <a href="https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/lfw.zip">human faces</a>.</p><p>After loading these images, we can see that there are 13,234 total human images, and 8,351 dog images divided into 133 categories.</p><p>For each dog breed, we have on average 50 dog photos. However, as we can see in the image below, many categories contain much fewer images. Thus, our dataset is rather small.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZOf-cjrWvGMIDGpeXPjkg.png" /><figcaption>Each bar represents the number of dog images for a given category</figcaption></figure><h3>Modeling</h3><h4>a. Detecting Human Faces</h4><p>Since we would like to tell a human which dog they look like, we must first be able to detect a human face. To do so, we can use <a href="https://opencv.org/">OpenCV</a> (Open Source Computer Vision Library) and a <a href="https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_alt.xml">pre-trained classifier</a> for frontal faces.</p><p>Then, to implement the face detector, we import the cv2 package and we write the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/173dce6693c1c946f39d5d75a650064d/href">https://medium.com/media/173dce6693c1c946f39d5d75a650064d/href</a></iframe><p>Testing this function on 100 human images and 100 dog images, we obtain the following results regarding the classifier:</p><ul><li>It correctly identified a face in 98% of human images</li><li>It mistakenly identified 12% of dogs as humans.</li></ul><h4><strong>b. Detecting Dogs</strong></h4><p>Now for detecting dogs, as before, we can use a pre-trained model. In this case, we will use a pre-trained <a href="http://ethereon.github.io/netscope/#/gist/db945b393d40bfa26006">ResNet-50</a> model, trained on <a href="http://www.image-net.org/">ImageNet</a>.</p><p>Before using our model, however, we must preprocess our images. Indeed, when using TensorFlow as the backend, Keras CNNs require a 4D tensor as input, with shape: (nb_samples, rows, columns, channels).</p><p>We can accomplish this by applying the function below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/360e4fa607245686abe3af0c0c68d879/href">https://medium.com/media/360e4fa607245686abe3af0c0c68d879/href</a></iframe><p>Now that we have a way to format our image for supplying to ResNet-50, we are ready to use our pre-trained model.</p><p>Note, however, that we must implement an additional preprocessing function from Keras: preprocess_input. This will helps us normalize our images, by subtracting the mean pixel from every pixel in the image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6d7370f55079b717379d0014cc1fd54/href">https://medium.com/media/e6d7370f55079b717379d0014cc1fd54/href</a></iframe><p>As we can see above, we take the argmax of the predicted probability vector. This gives us an integer corresponding to the object class predicted by the model. Using this <a href="https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a">dictionary</a>, we can identify the object class, knowing that the dog classes correspond to keys 151 to 268.</p><p>Finally, as before, the model was tested on a subset of 100 images of dogs, all of which were correctly identified, and on a subset of 100 images of humans, one of which was mistakenly identified as a dog.</p><h4>c. Building a CNN from Scratch</h4><p>Before using transfer learning, it can be good to take a closer look at how CNNs work.</p><p>Convolutional Neural Networks use locally connected layers, usually mixing:</p><ul><li><strong>Convolutional Layers </strong>that detect regional patterns in an image</li><li><strong>Pooling Layers</strong> that help decrease the dimensionality and thus decrease the risk of overfitting</li></ul><p>Moreover, the first layer must always include the input shape (in our case: 224, 224, 3) and the last layer must be a fully connected layer with a node for each category and a softmax activation function (needed for computing the categorical cross-entropy loss function). All other layers should have a ‘<em>relu’ </em>activation function.</p><p>Knowing this, we can build a fairly simple CNN where we add an additional fully connected layer, a dropout layer to prevent overfitting, and a layer to flatten the input :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*SVwp10iCnuw6lYwajYzn2w.png" /></figure><p>This model, trained for 10 epochs, with a batch size equal to 25, obtained 6.34% accuracy on the test set. Although this is a very weak performance, we can note that it is at least above random guessing.</p><p>Using transfer learning, we will be able to have much better performance.</p><h4>d. Building a CNN using Transfer Learning</h4><p>Now we will see how to use transfer learning to create a CNN that can identify dog breeds from images.</p><p>When using transfer learning, two important things to check before choosing a model architecture:</p><ul><li>Is our data similar to the data used for training the pre-trained model?</li><li>How big is our dataset?</li></ul><p>In this case, the data we used here is similar to the data used for training the pre-trained CNNs available in Keras. In addition, we saw that our dataset is rather small. These two factors indicate that our model architecture should largely include the pre-trained model as is, but without the end of the neural network which should be replaced by a new fully-connected layer.</p><p>In addition, to reduce training time, a GAP (Global Average Pooling) layer could be included in between.</p><p>We can expect the training process to be rather fast as it will only include the GAP layer and the Dense layer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef244d7376692ee670b8524dc4128799/href">https://medium.com/media/ef244d7376692ee670b8524dc4128799/href</a></iframe><h3>Results</h3><p>The model architecture discussed above was implemented for 20 epochs and using a batch size equal to 32. Three different pre-trained CNNs were tested:</p><ul><li><a href="https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/DogVGG19Data.npz">VGG-19</a></li><li><a href="https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/DogInceptionV3Data.npz">Inception</a></li><li><a href="https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/DogXceptionData.npz">Xception</a></li></ul><p>And the following results were obtained on the test set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*4tO9fsF6mLf1nsRxNBXS8w.png" /></figure><p>We can see that using Xception we obtained 85% accuracy, much better than before!</p><h4><strong>Predicting dog breeds</strong></h4><p>Most of the work has already been done, now we only need to write a function that can take advantage of our previous work to estimate the breed of a dog.</p><p>The goal for our algorithm is to, given an image path file, be able to tell if the image provided contains a dog or a human and to estimate which breed the dog is, or what dog the human looks like. In addition, it should display the image provided as well as an image of the estimated breed.</p><p>To do so, first, we write a function that can find a dog image for a certain breed among our training files (find_breed), then another function to be able to display both images (show_images), and finally, we can write our final function, which builds upon our previous work and uses the model trained using Xception:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c6a8b6ad3f458cc39d11d5451d89098/href">https://medium.com/media/4c6a8b6ad3f458cc39d11d5451d89098/href</a></iframe><p>These are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*2ehDpGBWW0VWoqWZ-vNcwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*SEIdDHBdBnr2zbK-QbuVBw.png" /></figure><p>Not so bad!</p><h3>Conclusion</h3><p>This project takes a look at how to use modern technologies to deal with image classification. More precisely, we saw how to build a model using CNNs and transfer learning and we were able to build a multi-class model that achieved 85% accuracy on test data.</p><h3>Improvements</h3><p>There are many ways of improving this work, a few would be:</p><ul><li>Testing other model architectures</li><li>Fine-tuning training hyperparameters (number of epochs, batch size)</li><li>Adding more dog breeds and more images per breed</li><li>Apply data augmentation</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4266adb4f15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to creating interactive visualizations in Python]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/guide-to-creating-interactive-visualizations-in-python-78f79ffc7d61?source=rss-23e38bdb70ce------2"><img src="https://cdn-images-1.medium.com/max/1914/1*waAAmpi2A4GEB_9akIvC-A.png" width="1914"></a></p><p class="medium-feed-snippet">Using HoloViz tools to create and deploy an interactive dashboard</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/guide-to-creating-interactive-visualizations-in-python-78f79ffc7d61?source=rss-23e38bdb70ce------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/guide-to-creating-interactive-visualizations-in-python-78f79ffc7d61?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/78f79ffc7d61</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Tue, 19 Apr 2022 14:29:40 GMT</pubDate>
            <atom:updated>2022-05-14T15:37:04.304Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Analyzing the results of an A/B test using Python]]></title>
            <link>https://medium.com/@pcmaldonado/starbucks-take-home-assignment-a8b647fb21e0?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8b647fb21e0</guid>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Mon, 11 Apr 2022 18:37:52 GMT</pubDate>
            <atom:updated>2022-05-15T10:09:21.128Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Starbucks Takeaway assignment for data scientists candidates</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Gv00avS8rvUAyjET" /><figcaption>Photo by <a href="https://unsplash.com/@photographybyniels?utm_source=medium&amp;utm_medium=referral">Niels Kehl</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, we’ll look at a takeaway assignment on A/B testing that Starbucks used to test the skills of their job candidates. The data and instructions were provided by Udacity, in collaboration with Starbucks, as part of an optional exercise from their <a href="https://www.udacity.com/course/data-scientist-nanodegree--nd025">Data Scientist Nanodegree Program</a><em>.</em></p><p>As a reminder, A/B testing is a general methodology for testing user reactions to a new feature or product, allowing decisions to be made based on data rather than intuition. They work by splitting users into two groups: a <strong>control group</strong> for which nothing changes (group “A”), and a <strong>treatment group</strong> for which the new feature is presented (group “B”).</p><p><em>Note: All images are by the author unless otherwise noted.</em></p><h3>Take-Home Assignment</h3><p>Starbucks’ customers have been randomly selected to receive an advertising promotion to purchase a specific product. The goal is to analyze the data results to optimize the <strong>promotion strategy</strong> in order to send the promotion only to those customers who are most receptive to it, to <strong>limit the cost of sending the promotion.</strong></p><p>The data consists of about 120,000 observations split in a 2:1 ratio between training and test files. It contains information about whether or not a customer was sent the promotion, whether or not they eventually purchased that product, and seven additional features that characterize the customer but are only provided abstractly as V1 to V7.</p><p>The assignment requires solving <strong>two tasks</strong>:</p><ol><li><strong>Analyze the results of the experiment</strong> and identify the effect of the Treatment on product purchase and Net Incremental Revenue</li><li><strong>Build a model to select the best customers to target</strong> that maximizes the Incremental Response Rate and Net Incremental Revenue</li></ol><blockquote><strong>Incremental Response Rate (IRR)</strong></blockquote><blockquote>This is the ratio of customers who received the promotion and purchased the product minus the ratio of customers who did not receive the promotion but still purchased the product.</blockquote><blockquote><strong>Net Incremental Revenue (NIR)</strong></blockquote><blockquote>This measures how much money is made (or lost) by sending out the promotion.</blockquote><h3>Overview</h3><p>To solve this assignment, we will use statistical concepts such as <strong>hypothesis testing</strong> and <strong>bootstrapping</strong>, as well as <strong>machine learning</strong> methods.</p><p>More precisely, we will…</p><blockquote>1. Conduct <strong>hypothesis testing</strong> to check the A/B test</blockquote><blockquote>2. Analyze the results of the A/B test using bootstrapping</blockquote><blockquote>3. <strong>Build a ML model to select the best customers to target</strong></blockquote><p>If you want to follow along with the code, check the <a href="https://github.com/pcmaldonado/StarbucksAssignment">GitHub</a> repository.</p><h3>1. Checking the A/B test</h3><p>Before analyzing the results of the experiment, we should always start by checking the invariant metrics.</p><p>The<strong> invariant metric</strong>, as the name implies, is a metric that should not vary between the control group and the test group. Checking that these metrics are similar between the two groups ensures that what we are analyzing comes from the feature we want to test.</p><p>In this case, checking the invariant metric would mean ensuring that the control group and the treatment group have relatively equal sizes, which would mean that the proportion <strong><em>p</em></strong><em> </em>of either group is 50%.</p><p>To do so, we need to conduct a <strong>hypothesis test</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/0*rgw_G60KBdCeiBBV" /><figcaption>Null hypothesis | Alternative hypothesis</figcaption></figure><p>Because we are checking whether <em>p</em> is the same or different than a certain value (<em>p </em>could be higher or lower than 0.5) we will use a <strong>two-tailed test </strong>using the following formula for a Z-test (more information about this test <a href="https://vitalflux.com/one-proportion-z-test-formula-examples/">here</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/0*1vLYsF6H-YMyKUyX" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17ec368d1a0c43a6503bc801f3b033cd/href">https://medium.com/media/17ec368d1a0c43a6503bc801f3b033cd/href</a></iframe><p>With this test, we get a <strong>p-value = 0.5046</strong>, which is higher than all commonly used <strong>significance levels</strong> (0.10, 0.05, and 0.01). This means that we <strong>fail to reject the null hypothesis:</strong> we cannot reject the hypothesis that <em>p = 0.5</em>, i.e. that the two groups have equal sizes, and thus our invariant metric can be validated.</p><h3>2. Analyze the results of the experiment</h3><p>Now that we know that all participants were correctly assigned to the control and test groups, we can perform a hypothesis test to <strong>check the evaluation metrics: the IRR and the NIR.</strong></p><p>More precisely, we want to test the following hypotheses with a significance level, alpha, equal to 5%:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/0*yeEYOachJttxTDj_" /><figcaption>H0: Null Hypothesis = the promotion did not have an Incremental Response Rate effect</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/0*n_MoTby6QCPzlNwW" /><figcaption>H0: Null Hypothesis = the promotion did not have a positive Net Incremental Revenue effect</figcaption></figure><p>However, because we are testing two metrics, it is recommended that we apply a <a href="https://www.statisticssolutions.com/bonferroni-correction/"><strong>Bonferroni Correction</strong></a>. This means dividing alpha by the number of metrics being tested. In our case, this means a significance level equal to 0.05/2 = 0.025.</p><p>Since there is no way to directly perform a hypothesis test for these two parameters, we will use a different approach: bootstrapping.</p><p><strong>Bootstrapping</strong> uses random sampling with replacement to simulate the replication of the experiment to get a better idea of which outcomes are likely and which are rare (for more details you can check this <a href="https://www.youtube.com/channel/UCtYLUTtgS3k1Fg4y5tAhLbw">video</a>).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96fcab27b69ee01b78d6c70d1adf6f3f/href">https://medium.com/media/96fcab27b69ee01b78d6c70d1adf6f3f/href</a></iframe><p>From these bootstrapped samples of IRR and NIR, we can compute a 95% confidence interval to test the null hypothesis:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*5i7FOq42aORCjyU2FnDAxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*SgtAZgNyhspTMS1gvc_otw.png" /></figure><p>Since the IRR Confidence Interval is well above 0, <strong>we can reject the first null hypothesis</strong>: the promotion had a significant positive effect on the Incremental Response Rate.</p><p>However, the NIR Confidence Interval is not above 0, and thus <strong>we fail to reject the second null hypothesis</strong>: the promotion did not have a significant positive effect on the Net Incremental Revenue.</p><p>In addition, we can also compute the p-values using the SciPy library and we get the same results: for the IRR we get a p-value near 0 (&lt;0.025) and thus we reject the null hypothesis; for the NIR we get a p-value near 1 (&gt;0.025) and thus we fail to reject the null hypothesis.</p><p>From this we can conclude two things:</p><ul><li>The <strong>promotion increased sales</strong>: more customers purchased the product with the promotion, as compared to if they didn’t receive the promotion</li><li>As the promotion was sent randomly to customers,<strong> </strong>it had a <strong>negative effect on the net incremental revenue</strong></li></ul><p>Knowing that the promotion <em>did </em>have a positive effect on sales, the next step is to build a model to decide on a promotion strategy and target customers that are more receptive to the promotion to increase the NIR.</p><h3>3. Build a model to select customers to target</h3><p>Finally, we can train a classification model to select the best customers to target. Here, we want to predict whether a customer who has received a promotion will buy the product or not, in order to maximize our two metrics: IRR and NIR.</p><p>Since we want to predict if a customer will buy the product or not, we can use a classification model. However, it is important to note that only 1.70% of customers purchased the product in the treatment group. This means that <strong>the data is highly imbalanced, </strong>and thus our modeling must take this into account.</p><p>Finally, as a reference for our future models, it is good to note that on the A/B testing, where customers were randomly selected, the evaluation metrics were: <strong>IRR: 0.0095 </strong>and<strong> NIR: -2334.60.</strong></p><h4>Baseline model: Logistic Regression</h4><p>It is often useful to use a simple model as a baseline. In this case, we will test a Logistic Regression approach, which gives us the following results:</p><pre>LogisticRegression<br>IRR: 0.0146<br>NIR: -58.75</pre><p>We can see that the results are much better than when customers were randomly chosen as in the A/B test. However, the Net Incremental Revenue is still negative, which means that customers are still not being targeted well enough.</p><h4>Balanced Random Forest Classifier</h4><p>Knowing that the data is highly imbalanced, we can use a Balanced Random Forest Classifier from the <a href="https://imbalanced-learn.org/stable/references/generated/imblearn.ensemble.BalancedRandomForestClassifier.html">Imbalanced-learn</a> library which “randomly under-samples each bootstrap sample to balance it”.</p><p>Without any fine-tuning, we get the following results:</p><pre>BalancedRandomForestClassifier (no hyperparemeters fine-tuning)<br>IRR: 0.0168<br>NIR: 149.10</pre><p>This is much better than the previous result: the NIR is not only positive but also much higher than before!</p><p>If we <strong>apply GridSearchCV with 10-fold cross-validation </strong>to test different values for hyperparameters such as the maximum depth, the maximum number of features, etc., we are able to further improve the results:</p><pre>BalancedRandomForestClassifier (after applying GridSearchCV)<br>IRR: 0.0189<br>NIR: 415.20</pre><p>Applying fine-tuning had a major effect on the performance of the model:</p><ul><li>From an<strong> Incremental Response Rate </strong>of 0.0168 to<strong> 0.0189,</strong> and</li><li>From a<strong> Net Incremental Revenue of </strong>149.10 to<strong> 415.2</strong></li></ul><p>Although additional models could be tested, this model seems like a good candidate to use for our promotion strategy to target customers.</p><p>Finally, we can apply permutation feature importance to take a look at how the different features impact the final estimation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*dcW2JNhv073PXblSGXEBkg.png" /></figure><p>Since we don’t know what these features represent it is difficult to interpret these results, however, it seems that the V4 feature is the most relevant when deciding on whether or not to send the promotion to a customer.</p><h3>Conclusion</h3><p>In this article, we were able to answer the questions of the Take-Home Assignment that Starbucks used to test its job candidates:</p><ul><li>We conducted a <strong>hypothesis test</strong> to check the invariant metric of the A/B test</li><li>We applied <strong>bootstrapping </strong>techniques to analyze the results of the A/B test and measured the impact of the promotion on the evaluation metrics</li><li>We built a model with <strong>finely tuned hyperparameters</strong> that can help <strong>maximize the IRR and the NIR </strong>by improving the promotion strategy of targeted customers</li></ul><p><em>Note: the educational materials of Udacity are licensed under the terms and conditions of the </em><a href="https://creativecommons.org/licenses/by-nc-nd/4.0/"><em>CC BY-NC-ND 4.0</em></a><em> License.</em></p><p><a href="https://medium.com/@pcmaldonado/membership"><strong>Become a member</strong></a><strong> and read every story on Medium. Your membership fee directly supports me and other writers you read. You’ll also get full access to every story on Medium.</strong></p><p><a href="https://medium.com/@pcmaldonado/membership">Join Medium with my referral link - Paula Maldonado</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8b647fb21e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get a high salary as a Data Scientist?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/this-will-help-you-know-what-to-expect-when-looking-for-a-data-scientist-job-90c039dbaaaa?source=rss-23e38bdb70ce------2"><img src="https://cdn-images-1.medium.com/max/2600/0*j_h2hO7cU7cBJygv" width="5184"></a></p><p class="medium-feed-snippet">A data-driven approach using scraped data containing salary records from top companies from 2017</p><p class="medium-feed-link"><a href="https://medium.com/codex/this-will-help-you-know-what-to-expect-when-looking-for-a-data-scientist-job-90c039dbaaaa?source=rss-23e38bdb70ce------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/this-will-help-you-know-what-to-expect-when-looking-for-a-data-scientist-job-90c039dbaaaa?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/90c039dbaaaa</guid>
            <category><![CDATA[salary]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-scientist]]></category>
            <category><![CDATA[faang]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Wed, 30 Mar 2022 11:51:46 GMT</pubDate>
            <atom:updated>2022-05-24T10:11:50.217Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Explaining Black-Box models using Python]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@pcmaldonado/simple-guide-to-interpreting-black-box-models-in-python-5c8bb3b5fcae?source=rss-23e38bdb70ce------2"><img src="https://cdn-images-1.medium.com/max/2600/0*5Z6AfJYv_Ltkcndr" width="5402"></a></p><p class="medium-feed-snippet">A quick look at different global and local model-agnostic methods for explaining complex machine learning models</p><p class="medium-feed-link"><a href="https://medium.com/@pcmaldonado/simple-guide-to-interpreting-black-box-models-in-python-5c8bb3b5fcae?source=rss-23e38bdb70ce------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@pcmaldonado/simple-guide-to-interpreting-black-box-models-in-python-5c8bb3b5fcae?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c8bb3b5fcae</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programmation]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Sat, 26 Mar 2022 13:13:57 GMT</pubDate>
            <atom:updated>2022-05-14T15:36:02.857Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Linear Regression: Normal Equation & Gradient Descent — from Scratch]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@pcmaldonado/linear-regression-normal-equation-gradient-descent-from-scratch-dc8c0f51940?source=rss-23e38bdb70ce------2"><img src="https://cdn-images-1.medium.com/max/600/1*smyzad_w1tMIrPWfbkmzww.png" width="600"></a></p><p class="medium-feed-snippet">This project, inspired by the book &#x201C;Hands-On Machine Learning&#x201D; by Aur&#xE9;lien G&#xE9;ron, studies Linear Regression from scratch, using Python.</p><p class="medium-feed-link"><a href="https://medium.com/@pcmaldonado/linear-regression-normal-equation-gradient-descent-from-scratch-dc8c0f51940?source=rss-23e38bdb70ce------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@pcmaldonado/linear-regression-normal-equation-gradient-descent-from-scratch-dc8c0f51940?source=rss-23e38bdb70ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc8c0f51940</guid>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Paula Maldonado]]></dc:creator>
            <pubDate>Mon, 08 Nov 2021 20:25:28 GMT</pubDate>
            <atom:updated>2022-05-14T15:35:43.602Z</atom:updated>
        </item>
    </channel>
</rss>