<?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 Egemen Karabiyik on Medium]]></title>
        <description><![CDATA[Stories by Egemen Karabiyik on Medium]]></description>
        <link>https://medium.com/@egemenkarabyk?source=rss-22df8ef3002f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wdu1K0rNyk2SbJqOshSPeg.jpeg</url>
            <title>Stories by Egemen Karabiyik on Medium</title>
            <link>https://medium.com/@egemenkarabyk?source=rss-22df8ef3002f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:32:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@egemenkarabyk/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[Swing: The Secret Behind Simple But Smarter Product Recommendations!]]></title>
            <link>https://medium.com/trendyol-tech/swing-the-secret-behind-simple-but-smarter-product-recommendations-03dc69b8b204?source=rss-22df8ef3002f------2</link>
            <guid isPermaLink="false">https://medium.com/p/03dc69b8b204</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Egemen Karabiyik]]></dc:creator>
            <pubDate>Tue, 24 Dec 2024 06:54:22 GMT</pubDate>
            <atom:updated>2024-12-24T06:54:22.233Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FcSgD1a_Ofc-ZuIwujSMwg.jpeg" /></figure><h3><strong>1. What is Swing? </strong>🤔</h3><p>In the world of e-commerce recommender systems, speed, relevance, and scalability are the key factors for success. The <strong>Swing </strong>algorithm<strong> </strong>developed by Alibaba [1]<strong> </strong>provides these by revealing substitute product recommendations thanks to the user-item bipartite graph<strong> </strong>— a map of how users interact with products. The item similarities revealed from <strong>simple real-time user patterns</strong> can create highly <strong>fast, relevant, and smarter </strong>product suggestions.</p><p><strong><em>“Simplicity is the ultimate sophistication” — Leonardo da Vinci</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*BjA-HJqq8BH9K52F.jpg" /><figcaption>Mona Lisa’s simple but sophisticated look.</figcaption></figure><h3>2.<strong> The Secret </strong>of Swing 🎃</h3><p>Swing builds its magic on the <strong>user-item bipartite graph</strong>, a relationship map where users are connected to the products they’ve interacted with (through clicks, favorites, baskets, and orders).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XgMDVU94rsrs0tn9bIW-ig.png" /><figcaption>An example of the user-item interaction graph in swing [1]</figcaption></figure><p>For example:</p><ul><li><strong>User A</strong> clicks on <strong>T-shirt h </strong>and <strong>T-shirt p</strong>.</li><li><strong>User B</strong> clicks on <strong>T-shirt h </strong>and later clicks <strong>T-shirt p</strong>.</li></ul><p>Based on this data, Swing detects that <strong>T-shirt h </strong>and <strong>T-shirt p </strong>are <strong>substitute products</strong> because they are often interacted with by the same users (A/B, A/C, B/C).</p><p>This recommendation is driven by the <strong>patterns in user behavior (what actually customers choose)</strong>, not just the product features. That’s why, even if the two T-shirts were different in style, Swing’s model could have understood that users considered them interchangeable.</p><ul><li><strong>T-shirt h:</strong> Slim Fit, Red, Cotton</li><li><strong>Recommended T-shirt t:</strong> Regular, Dark Red, Polyester</li></ul><h4>Swing Matching Algorithm 💘</h4><p>Let’s imagine you are at a party and trying to introduce two friends who you think would be a good match. You don’t just throw them together, right? You consider their common interests, mutual friends, and how they interact with others.💃🕺 That’s basically what Swing does, but with products and users to generate similar product recommendations.</p><p>The magic formula for the Swing similarity score consists of user pairs (u1, u2) created from a set of users (Ui1, Ui2) who interacted with items (i1, i2), an intersection of products that both users interacted (Iu1, Iu2), smoothening factor (a) and penalization terms (Wu1, Wu2):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*WpKX1jygcg80EM6SJQl1vQ.png" /><figcaption>Similarity score calculation [1]</figcaption></figure><p>Here is how we implemented item-to-item similarity score for the same category product recommendations by using 15 days of user action data:</p><pre># Create bipartite graph more efficiently<br>B = nx.from_pandas_edgelist(data, &quot;content_id&quot;, &quot;user_id&quot;)<br><br># Pre-compute user penalties using vectorized operations<br>user_counts = data.groupby(user_col).size()<br>click_penalty_fac = dict(<br>    (user, (count + user_alpha) ** user_beta)<br>    for user, count in user_counts.items()<br>)<br><br># Pre-compute neighbor sets for all users<br>user_neighbors = {<br>    user: set(B.neighbors(user)) <br>    for user in data[user_col].unique()<br>}<br><br># Pre-compute items and their users<br>item_users = {<br>    item: list(B.neighbors(item))<br>    for item in data[item_col].unique()<br>}<br><br># Iterate items<br>for item, users in item_users.items():<br>    item_swing_scores = swing_score.get(item, {})<br>    <br>    # Iterate user pairs<br>    for i in range(len(users)):<br>        u = users[i]<br>        # Only iterate pairs once by using range(i+1, len)<br>        for v in users[i+1:]:<br>            # Get pre-computed neighbor sets<br>            common_items = user_neighbors[u] &amp; user_neighbors[v]<br>            k = len(common_items)<br>            <br>            # Check if there is just one common item between user pairs<br>            if k &lt; 2:<br>                continue<br><br>            # Calculate similarity score contribution for this user pair to the common items<br>            score_contribution = (<br>                click_penalty_fac[u] * click_penalty_fac[v]<br>            ) / (alpha + k)<br><br>            # Update scores for all common items except the current item<br>            for j in common_items:<br>                if j != item:<br>                    item_swing_scores[j] = item_swing_scores.get(j, 0) + score_contribution<br><br>    if item_swing_scores:<br>        swing_score[item] = item_swing_scores</pre><h4>Penalty Policy For Robust Recommendations 👮</h4><ul><li><strong>Penalties for Active Users:</strong> Imagine you’re at an all-you-can-eat buffet 🍽️. There are two types of people: One who tries a reasonable variety of dishes and the other literally puts EVERYTHING on his plate. Which one’s food recommendations would you consider? 🤔 Probably not the latter one! This is exactly what happens in e-commerce: Some users carefully browse and click on what they’re interested in. Some users click like they’re trying to win a speed-clicking Olympic medal! 🏃‍♂️💨 Thus, Swing defines the contribution of a user to a similarity score as inversely proportional to the user’s click number (user_beta &lt; 0).</li></ul><pre># user_clicks: number of items clicked by the user<br># user_alpha: smoothing factor<br># user_beta: penalty strength<br>click_penalty = (user_clicks + user_alpha) ** user_beta</pre><ul><li><strong>Selective Influence of Popular Products:</strong> Instead of using every interaction from all users who have clicked, Swing randomly selects a <strong>maximum number of users</strong> who have interacted with a product. This prevents popular products from dominating the recommendations.</li></ul><pre># Selection of random max number of users, if item is too popular<br>if len(users) &gt; max_users_num:<br>    users = np.random.choice(users, size=max_users_num, replace=False)</pre><ul><li><strong>Elimination of Bot Users :</strong> Swing completely disregards the bot users’ (who clicks randomly but doesn’t order anything) item interactions. By removing the users who exceed the <strong>maximum number of interactions </strong>limit per session, Swing ensures that bot users’ wide-ranging actions don’t overwhelm the recommendations.</li></ul><pre># Elimination of bot users<br>filtered_user_index = user_actions_count[user_actions_count &lt;= max_user_items].index.tolist()</pre><h3><strong>3. Why Swing? </strong>🧠</h3><ol><li><strong>Simplicity Meets Power:</strong> Instead of complex, hard-to-understand algorithms, Swing works with patterns in <strong>real-world user actions</strong>, making it both intuitive and reliable. 🚀 That’s why we could implement Swing in just two iterations, while making it useful for both niche and popular item recommendation.</li><li><strong>Scalable and Cost Effective: </strong>Without the need for heavy training or large models, Swing saves you computational resources, making it perfect for large-scale platforms. 💻 That’s why we can calculate swing scores for all categories in parallel under 10 minutes.</li><li><strong>Applicability: </strong>Swing scores can be utilized in different stages of recommender systems. 📊 That’s why we use it as a candidate pool, a feature for ranking models, or even directly as a ranking mechanism.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*aCBWw7pfMJREEEVsMZn2vg.png" /><figcaption>A regular recommendation system workflow</figcaption></figure><p>✅ <strong>P.S. </strong>Unlike traditional item-item based collaborative filtering, Swing focuses more on efficiency and accuracy rather than discovery; thanks to its graph structure harmonized with penalization terms for popular items and active/bot users. [1, 2]</p><h3>4. Swing in Action 🕺</h3><p>Here are some cool examples generated with Swing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/188/1*I3Ra4tNJX8J_uJCykLDcOw.png" /><figcaption>Main item: sneaker with stripes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*rMwZEnWNuI9NFzJUs4kLKQ.png" /><figcaption>Top 5 recommendations made by Swing for the sneaker with stripes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*6kPjojWLTRcDZjzTXHAYNA.png" /><figcaption>Main item: patent leather purse</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*ArafaZFuSaW22MBrEO3gqg.png" /><figcaption>Top 5 recommendations made by Swing for the patent leather purse</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*oyFVpG_JJnj-KvBUjj5ZRA.png" /><figcaption>Main item: knitted dress</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*aszGx4lI3HMp1jgQp_NDSQ.png" /><figcaption>Top 5 recommendations made by Swing for the knitted dress</figcaption></figure><h3>5. Conclusion 🎉</h3><p>Throughout offline evaluations, Swing shows high potential for improving click-through rates (19% increase in avg. precision and 15% increase in avg. recall for clicks in the top 24 recommendations). 🎯 On the other hand, the coverage of seed that we can offer recommendation gets worse (9% decrease) with Swing compared to as-is workflow. ⚖️ This trade-off shows us how important is to find the right balance between simplicity and comprehensiveness for better recommendations with high product coverage. That’s why, we decided to run an A/B test with different enrichment versions of Swing implemented into different stages of our workflow.</p><p><strong><em>“Make everything as simple as possible, but not simpler.” — Albert Einstein</em></strong></p><p>For any questions or feedback, feel free to reach out to me via <a href="https://www.linkedin.com/in/egemen-karabiyik-83421775/">Linkedin</a>.</p><h3>References</h3><p>[1] <a href="https://arxiv.org/abs/2010.05525">https://arxiv.org/abs/2010.05525</a></p><p>[2] <a href="https://www.alibabacloud.com/help/en/airec/swing-algorithm-tools">https://www.alibabacloud.com/help/en/airec/swing-algorithm-tools</a></p><h3>About Us</h3><p>We’re building a team of the brightest minds in our industry. Interested in joining us? Visit the pages below to learn more about our open positions.</p><p><a href="https://careers.trendyol.com/tr">Home - Trendyol Careers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03dc69b8b204" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trendyol-tech/swing-the-secret-behind-simple-but-smarter-product-recommendations-03dc69b8b204">Swing: The Secret Behind Simple But Smarter Product Recommendations!</a> was originally published in <a href="https://medium.com/trendyol-tech">Trendyol Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>