<?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 Alex Lokhov on Medium]]></title>
        <description><![CDATA[Stories by Alex Lokhov on Medium]]></description>
        <link>https://medium.com/@alexlokhov?source=rss-adcc3fd9598f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UiJgmrp983Z4kKXsvTVqeA.jpeg</url>
            <title>Stories by Alex Lokhov on Medium</title>
            <link>https://medium.com/@alexlokhov?source=rss-adcc3fd9598f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:08:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexlokhov/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[Using alternative data to track returns rates in the online fashion industry]]></title>
            <link>https://medium.com/@alexlokhov/using-alternative-data-to-track-returns-rates-in-the-online-apparel-industry-67b80dc1c22b?source=rss-adcc3fd9598f------2</link>
            <guid isPermaLink="false">https://medium.com/p/67b80dc1c22b</guid>
            <category><![CDATA[alternative-data]]></category>
            <category><![CDATA[fashion-retail]]></category>
            <dc:creator><![CDATA[Alex Lokhov]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 13:29:36 GMT</pubDate>
            <atom:updated>2022-08-11T13:30:13.307Z</atom:updated>
            <content:encoded><![CDATA[<p>The online apparel industry went through a cycle of a boom and bust cycle since the beginning of the pandemic. In the early days of the lockdown, online fashion retailers experienced significant growth. Then in 2021 these retailers suffered from supply chain issues and elevated freight costs. More recently, many fashion retailers reported increased product returns rates. High return rates negatively affect revenue as well as add substantial costs to running a business. To combat this problem, some retailers even started introducing return fees.</p><p>Alternative data has been widely used to track top-level metrics such as companies’ revenue. In this analysis we will look at how we can leverage alternative data to track return rates as this is something that many industry observers would like to have visibility of.</p><p>The first thing to keep in mind is that often businesses do not report return rates explicitly. In some cases, we can approximately derive it from comparing net sales and gross sales; assuming that both metrics are reported by the business. The retailer we will analyse in this example is ASOS — a UK-based online fashion retailer. Since 2021, ASOS stopped reporting gross revenue (or gross average order value), and we can no longer reliably determine the actual returns rate. Since we don’t have a ground truth benchmark for our forecast there is no way of knowing exactly how good the forecast is.</p><p>One issue with tracking returns rate is that it is a lagging indicator. When a product is purchased, it is usually not returned straight away. For instance, many orders that are placed in November during the Black Friday sale are not returned until late December. If we simply calculate the ratio between purchases and returns in any given month, we would see a relatively low % of returns in November and a relatively high % of returns in December. But this ratio doesn’t tell us anything about the <em>underlying</em> returns rate: the percent of orders placed in a given month (or week) that is subsequently returned. We have to use a more granular dataset and find a way to match original purchases with the corresponding returns. Some alternative data datasets contain anonymised information about individual transactions (orders) or even individual items and item values.</p><p>In this analysis we will use one of the more granular datasets. For simplicity, we will use order-level data, without considering individual items. The important property of our dataset is that each order comes with the order identifier that uniquely identifies the original purchase transaction <em>and</em> the corresponding return transaction. In our case, the information about both the original orders and the returns is stored in the same table. To match orders and returns we can perform a ‘self-JOIN’, joining the table with itself, using the unique order identifier as the JOIN key. We would have to make sure that we only keep the new purchases in the left part of the JOIN and only the returns in the right part. We will perform a ‘left inner’ JOIN: this way we keep all purchases, including the ones that have not been returned (yet).</p><p>To visualise the result, we can simply run a % of total calculation, hiding orders that have not been returned (have NULLs in the fields coming from right side of the JOIN).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/0*0pkF4RC9Egy6vFDU" /></figure><p>Looking at the data this way, we can see that the underlying returns rate for the purchases made in late November and beginning of December is lower than during any other time of the year. This is a typical seasonal dip that is commonly observed in the industry:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*5t6NsgMxb-kk5oZw" /><figcaption>Source: ASOS HY22 results, April 2022.</figcaption></figure><p>The other important observation is that we see a dip in returns rate in the last 3 to 4 weeks. This, of course, happens because not all orders that will eventually be returned have been returned yet. Does that mean that we should completely ignore the most recent weeks and wait until we have sufficient data? Not necessarily. While we can’t reliably predict the actual returns rate for these most recent weeks, we could still make an early estimation. In order to do so, we can group weekly orders into return subgroups, where each subgroup represents the week of the return <em>relative to the date of the original purchase</em>. For instance, by looking at the % of orders that has been returned after just one week of the original purchase, we could have an early indication of what the full return rate for that week is going to be.</p><p>Since we have JOINed purchases and returns, the date of the original purchase and the date of the return will be in the same row. A simple SQL calculation will give us the time delta in weeks:</p><blockquote><strong><em>DATEDIFF(week, ‘PURCHASE_DATE’, ‘RETURN_DATE’).</em></strong></blockquote><p>The calculation will return NULLs if an order hasn’t been returned. We can either keep these NULLs or replace them with some special value (‘-1’, for example). This would make our life easier when we do subsequent grouping.</p><blockquote><strong><em>IFNULL(DATEDIFF(week, ‘PURCHASE_DATE’, ‘RETURN_DATE’), -1)</em></strong></blockquote><p>By using this new calculation as a dimension, we can divide purchases made in the same week into colored subgroups. Each subgroup represents the week of the return relative to the date of the purchase:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/0*ywGq6_xuU9xAugIe" /></figure><p>We can now see that the trend in returns in more recent weeks is not slowing down.</p><p>There is one last small fix that is required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*kAHGospmzSWE8Wkq" /></figure><p>If we take a closer look at the above chart, we would see that some weekly subgroups are not ‘complete’: this is because we are halfway through some of these weeks. For instance, we are in the middle of week 5 of returns for the orders that were originally placed 5 weeks ago. This can lead to incorrect interpretation of the data. To deal with this, we can simply hide all incomplete subgroups from the chart. Now we can do a cleaner comparison of weekly returns trends for the most recent weeks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*uOUD4EY5Nr5ofBT0" /></figure><p>In conclusion, with a good understanding of the problem and with a bit of work and data restructuring, alternative data could give us answers to some more nuanced questions about the online fashion industry. A <em>live</em> example of the above analysis implemented for ASOS and a couple of other online fashion retailers is available here:</p><p><a href="https://alexlokhov-retailinsights-main-azyibq.streamlitapp.com/">https://alexlokhov-retailinsights-main-azyibq.streamlitapp.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67b80dc1c22b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do Russians ever smile?]]></title>
            <link>https://medium.com/@alexlokhov/do-russians-ever-smile-e6f9f9f5623c?source=rss-adcc3fd9598f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6f9f9f5623c</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[instagram]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Alex Lokhov]]></dc:creator>
            <pubDate>Mon, 09 Apr 2018 09:48:21 GMT</pubDate>
            <atom:updated>2018-04-09T09:48:21.640Z</atom:updated>
            <content:encoded><![CDATA[<h4>Analyzing human emotions on Instagram</h4><p>Ever since I moved to London, I hear that Russian people don’t smile. And I thought that I have started noticing it too, especially when I travel back to my motherland. Russia has adopted many attributes of the Western culture in recent years, but one character trait still seems to make Russians differ from most other nations: they are permanently “stone-faced”. There has even been some scientific <a href="https://www.theatlantic.com/science/archive/2016/05/culture-and-smiling/483827/">research</a> that explains this phenomena. Then there is a nation that is perceived to be on the other end of the “emotional spectrum” — Americans. There is a presumption that Americans tend to over-exaggerate their emotions. And of course Americans are famous for their perfect smiles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*v-qZ6qz6NKzOKlbzBRJkfQ.jpeg" /></figure><p>Being a data geek, I wanted to test these stereotypes and see if I can prove or disprove them with data. Thanks to the recent advancements in AI and machine learning, we have access to automated face recognition technologies, which among other things can detect human emotions. With a large enough dataset of people’s faces from around the world I could test if Russians are indeed not as smiley as other cultures. One great resource for getting publicly available photos is Instagram, where millions of images and videos are being posted daily. We don’t know nationalities of Instagram users, but for the purpose of this exercise I used the location of where a picture was taken. Since I was specifically interested in pictures with faces, I decided to search for posts with the hashtag #selfie. There might be some bias in this data — a “selfie” is not a normal picture. People in selfies often pose, pout, look very serious, and so on. Still, I thought that with enough data I could start seeing differences in how people express themselves, even if the distinctions are very subtle.</p><h4>Findings</h4><p>­</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*ohopj6SlhzK_X-7U0y0z5g.png" /></figure><p>In order to make sure that my findings are statistically valid I have excluded countries with smaller sample sizes. Out of the top 17 countries by the count of selfies posted on Instagram, Russia and Ukraine came as two countries with the lowest percentage of people smiling. Being Russian I was not very impressed with the outcome. But there you go — the reputation of Eastern Europeans as cold and glum is confirmed.</p><p>Looking at the “happiest” countries, we can see that Indonesia and Turkey are in the lead, followed by Australia and Italy. It seems that countries that have more sun also have more smiling people. But more data would be needed to test this hypothesis.</p><p>United States were only slightly ahead of Great Britain. Maybe the contrast between the US and the rest of the world is not as great as we think.</p><h4>What about other emotions?</h4><p>There are 7 different emotions that can be picked up by the AI that I was using, not including “neutral” which simply shows absence of any other emotion. Happiness, of course, is the most frequently observed one. It happens so often that I had to temporarily exclude it from my analysis, otherwise the number of happy people would dwarf people showing any other feelings. This left me with 6 other emotions: sadness, surprise, contempt, anger, disgust and fear. What I wanted to see is how these other feelings are expressed by people from different countries. It was interesting to see that without “happiness” the picture changes completely: Japan appears to be the most “emotional” country with “sadness” or “surprise” being demonstrated by nearly 3% of all people. Korea is the top country in terms of the number of people that appear to be sad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*281MVMaDnaOw33zEMkej6Q.png" /></figure><p>Another noticeable “outliers” are France where almost 2.4% of all people express contempt and Ukraine where no one ever gets surprised.</p><p>After getting the answer to my most burning inquiry, I was keen to explore the data a bit more. My next question was — what is it that makes us happy?</p><h4>Do we smile more as we get older?</h4><p>I was curious to know how our emotions change with age. It is worth mentioning that I don’t know the actual age of anyone on Instagram. The age is “guessed” by the AI based on the picture. It turns out that we smile a lot between the age of 8 and 10, but then our happiness goes downhill as we go into our teenage years. Or maybe we just try to “look cool” which means not expressing too much emotion in front of a camera. Between the age of 25 and 40 we learn to smile again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*kD-F9YrvsPI3_xg11tXb4A.png" /></figure><h4>What about gender?</h4><p>Another angle I really wanted to explore was gender difference. Women take more selfies which resulted in slight imbalance in my data: 61% of people appearing in the dataset are women.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*kI2WjKskIhw8d1G02gQgpg.png" /></figure><p>What is interesting is that although women appear in selfies more often then men, women seem to be appear more in selfies in their early 20s, while men are more active between the age of 25 and 35. Perhaps men just don’t want to grow up?</p><p>Of course I wanted to know if women smile more (I would intuitively assume that they do). It turns out that this is the case: 51% of women appear with a smile compared to 39% of men. What was more interesting to see was how women’s and men’s “happiness” changes with age.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*2_IGaNCjc6fDG6fry1RDbQ.png" /></figure><p>It looks like there is not that much difference between boys and girls, but as people get older, we start seeing a striking contrast between women and men. Men do not change that much as they get older while women start smiling a lot more as they age. By the time women turn 40, 9 out of 10 of them would smile in front of a camera. It seems that women’s smiling coincides with posting fewer selfies on Instagram.</p><h4>Does being in a relationship make us smile more?</h4><p>What about being in a relationship? Does that make us happy? Intuitively we would say yes, but let’s look at our data to see if we can find some evidence. For the simplicity of the analysis I am going to assume that when two (and only two) people of different genders appear in a picture — they are in some kind of a relationship. Thanks to the AI we can detect people’s gender with a high degree of accuracy. After we split all pictures into two categories: “couple” and “not couple”, we can look at the average percent of people smiling in each one of the two groups. I have decided to keep countries to have more context in the visualization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*qjJp1j6NuAepntRdI1L8OA.png" /><figcaption>Couples in the UK are always smiling</figcaption></figure><p>It looks like people in relationships are indeed much more happy than when they are not. Or at least this is how they appear.</p><p>But wait! Why are we only looking at couples? Do people simply behave differently when they are not alone? As it turns out, people smile more in all selfies where there is more than one person; it does not matter whether the other person is a partner or not. A “group” selfie is very different to “single” selfie. People smile more in a company with more people. Remember “the most famous selfie” from the Oscars ceremony in 2014?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*TOB_xJVWB6nu7FOw5szrXQ.png" /></figure><h3>Tech</h3><p>I have used a number of different tools when I did this research. One of the tools is Tableau. Tableau can connect to many data sources, including web based APIs. There is a <a href="https://illonage.github.io/">Web Data Connector for Instagram</a>, which was developed by my colleague Geraldine Zanolli (you would need Tableau Desktop in order to use it). I was able to get the data that I need using this Web Data Connector that plugs straight into the Instagram’s API.</p><p>My other challenge was to find an automated service that can read human emotions. Two companies that offer “emotion recognition” APIs are Google and Microsoft. Google offers it as part of the Google’s Cloud Vision API and Microsoft offers something called “Face API” (I find the name quite amusing). Both can detect a range of emotions and some other attributes like age, gender, make up, facial hair, and so on. Both Cloud Vision API and Face API have web forms for uploading pictures, so you can test them with your own photos. Next time, before you play poker, you can practice your poker face and see if any of your emotions can be picked up by AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*4Is_kNhzh71khFVyR_UnMQ.png" /></figure><p>After collecting some Instagram data, I had to deal with the problem of data quality. Both Microsoft and Google charge for API requests after you go over a certain free monthly limit. I wanted to make sure that I only send pictures that actually contain people’s faces. It turns out that about half of all pictures posted with the #selfie tag on Instagram do not contain faces at all. There are many pictures of pets and various random things and objects. It would have been nice to add pictures of pets to my research, but at this point we do not have technology that can “read” an animal’s emotions (or at least I am not familiar with it). For that reason I simply excluded any pictures that did not have human faces from my analysis. A quick and dirty way to do this is to use the <a href="https://github.com/ageitgey/face_recognition">face_recognition</a> library. I noticed that the library failed to detect partially obscured faces or faces that are turned sideways; but I concluded it was good enough for my analysis.</p><p>Some additional processing was required to map the location of each picture to a country. Instagram only returns location name and latitude and longitude of each photo. I used the <a href="https://github.com/thampiman/reverse-geocoder">reverse_geocoder</a> library which is a great tool for mapping locations with known geographical coordinates to countries.</p><p>After adding geographical data and filtering out “wrong” pictures I was able to build a dashboard that I used to visually explore the dataset before I moved on to the next step of the analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*gqq6IJRpqKVJJ1_WdRy6TQ.png" /></figure><p>The rest of the analysis was trivial. Slightly more complex questions can be answered with the help of Level of Detail expressions in Tableau. For instance to identify pictures with couples I used the following expression:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*S-9jXaoyRX-eFQcb92XJHg.png" /><figcaption>Each record corresponds to a person. Each picture has a unique [Id] identifier.</figcaption></figure><p>The expression returns positive value if there are exactly two people in the picture and if their genders are different.</p><p>The resulting dataset consisted of 5,783 selfies and 8,348 people (some pictures have more than one person). The data was collected on the 5th of April, 2018.</p><p>­</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6f9f9f5623c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>