Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      CodeSOD: A Unique Way to Primary Key

      July 22, 2025

      BrowserStack launches Figma plugin for detecting accessibility issues in design phase

      July 22, 2025

      Parasoft brings agentic AI to service virtualization in latest release

      July 22, 2025

      Node.js vs. Python for Backend: 7 Reasons C-Level Leaders Choose Node.js Talent

      July 21, 2025

      The best CRM software with email marketing in 2025: Expert tested and reviewed

      July 22, 2025

      This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

      July 22, 2025

      I’m a wearables editor and here are the 7 Pixel Watch 4 rumors I’m most curious about

      July 22, 2025

      8 ways I quickly leveled up my Linux skills – and you can too

      July 22, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025
      Recent

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025

      Zero Trust & Cybersecurity Mesh: Your Org’s Survival Guide

      July 22, 2025

      Execute Ping Commands and Get Back Structured Data in PHP

      July 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025
      Recent

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025

      “I don’t think I changed his mind” — NVIDIA CEO comments on H20 AI GPU sales resuming in China following a meeting with President Trump

      July 22, 2025

      Galaxy Z Fold 7 review: Six years later — Samsung finally cracks the foldable code

      July 22, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Using AI to Compare Retail Product Performance

    Using AI to Compare Retail Product Performance

    June 30, 2025

    AI this, AI that. It seems like everyone is trying to shoehorn AI into everything even if it doesn’t make sense. Many of the use cases I come across online are either not a fit for AI or could be easily done without it. However, below I explore a use case that is not only a good fit, but also very much accelerated by the use of AI.

     

    The Use Case

    In the retail world, sometimes you have products that don’t seem to sell well even though they might be very similar to another product that does. Being able to group these products and analyze them as a cohort is the first useful step in understanding why.

     

    The Data and Toolset

    For this particular exercise I will be using a retail sales dataset from Zara that I got from Kaggle. It contains information about sales as well as the description of the items.

    The tools I will be using are:

      • Ollama (to run LLMs locally)
      • Gemma3 LLM
      • Python
          • Pandas
          • Langchain
      • Power BI
     

    High-level actions

    I spend a lot of my time design solutions and one thing I’ve learned is that creating a high-level workflow is crucial in the early stages of solutioning. It allows for quick critique, communication, and change, if needed. This particular solution is not very complex, nevertheless, below are the high-level actions we will be performing.

    1. Load the csv data onto memory using Pandas
    2. Create a Vector Store to store our embeddings.
      1. Embed the description of the products
    3. Modify the Pandas dataframe to accommodate the results we want to get.
    4. Create a template that will be sent to the LLM for analysis
    5. Process each product on its own
      1. Get a list of comparable products based on the description. (This is where we leverage the LLM)
      2. Capture comparable products
      3. Rank the comparable products based on sales volume
    6. Output the data onto a new CSV
    7. Load the CSV onto PowerBI for visualization
      1. Add thresholding and filters.

    The Code

    All of the code for this exercise can be found here

     

    The Template

    Creating a template to send to the LLM is crucial. You can play around with it to see what works best and modify it to fit your scenario. What I used was this:

     
    template = """<br>    You are an expert business analyst that specializes in retail sales analysis.<br>    The data you need is provided below. It is in dictionary format including:<br>    "Product Position": Where the product is positioned within the store,<br>    "Sales Volume": How many units of a given product were sold,<br>    "Product Category": The category for the product,<br>    "Promotion": Whether or not the product was sold during a promotion.<br>    There is additional information such as the name of the product, price, description, and more.<br>    Here is all the data you need to answer questions: {data}<br>    Here is the question to answer: {question}<br>    When referencing products, add a list of the Product IDs at the end of your response in the following format: 'product_ids = [<id1>, <id2>, ... ]'.<br>"""

    When we iterate, we will use the following as the question:

     
    question = f"Look for 5 products that loosely match this description: {product['description']}?"

     

    The output

    Once python does its thing and iterates over all the products we get something like this:

    Product ID Product Name Product Description Sales Volume Comparable Product 1 Comparable Product 2 … Group Ranking
    185102 BASIC PUFFER JACKET Puffer jacket made of tear-resistant… 2823 133100 128179 … 1
    187234 STRETCH POCKET OVERSHIRT Overshirt made of stretchy fabric…. 2575 134104 182306 … 0.75
    … … … … … … … …

     

    Power BI

    We then load the data onto Power BI to visualize it better. This will allow us to not only analyze the data using filtering and conditional formatting, but we can also explore the data even further with Copilot.

    Look at the screenshot below. I’ve initially setup conditional formatting so that all the products that rank low within their group are highlighted.

    I then used Copilot to ask how all of these relate to each other. It was quick to point out that all of them were jackets.

    Pbi Copilot

    This arms us with enough information to go down a narrower search to figure out why the products are not performing. Some other questions we could ask are:

    1. Is this data seasonal and only includes summer sales?
    2. How long have these jackets been on sale?
    3. Are they all sold within a specific region or along all the stores?
    4. etc.

    Conclusion

    Yes, there are many, many use cases that don’t make sense for AI, however there are many that do! I hope that what you just read sparks some creativity in how you can use AI to further analyze data. The one thing to remember is that in order for AI to work as it should, it needs contextual information about the data. That can be accomplished via semantic layers. To know more, got to my post on semantic layers. 

    Do you have a business problem and need to talk to an expert about how to go about it? Are you unsure how AI can help? Reach out and we can talk about it!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLaravel Virtual Wallet
    Next Article Wire Room Math: AI + SME = (Less Compensation Paid) X (Headline Risk + Payment Errors)^2

    Related Posts

    Development

    GPT-5 is Coming: Revolutionizing Software Testing

    July 22, 2025
    Development

    Win the Accessibility Game: Combining AI with Human Judgment

    July 22, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-46272 – D-Link Router Command Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    5 Business Benefits of Investing in AI-Powered Performance Testing

    Development

    How to Automate Compliance and Fraud Detection in Finance with MLOps

    Development

    CVE-2025-3473 – IBM Security Guardium Privilege Escalation Local Buffer Overflow

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Development

    The Developer’s Guide to AI Chatbot Authorization

    July 16, 2025

    Read The Developer’s Guide to AI Chatbot Authorization and learn AI with SitePoint. Our web…

    fnt – apt for fonts

    July 2, 2025

    LWiAI Podcast #201 – GPT 4.5, Sonnet 3.7, Grok 3, Phi 4

    June 3, 2025

    CVE-2025-3464 – ASUS Armoury Crate Authentication Bypass

    June 16, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.