All Articles

Which Image Should You Show?

I’ve been exploring probabilistic programming in 2019 and 2020. I was having a conversation about why a real estate listing was using what I thought was a sub-optional photo when there were photos available that I thought many people would prefer. It occurred to me that this was the multi-armed bandit problem.

Many sunglasses to choose from. Photo by chuttersnap on Unsplash

It is common to have a website where there are multiple images for a product or item but it is uncommon to know for certain which of those images will motivate the user the most often into buying or clicking.

I didn’t find a software-as-a-service that solved this problem without having to go through an enterprise sales process.

So I built a solution and named it PreferredPictures, since it will determine which picture is preferred by your prospective customers.

I implemented Thompson Sampling to determine which option to select. The SaaS progressively learns what the conversion rate is of each option. The ping attribute on the <a> tag provides an easy way for conversion tracking without using JavaScript.

Why is this better than an A/B test?

A/B tests typically run until one option is statistically signifigantly better than the other option. With Thompson sampling the optimization process continues forever, so if the audience’s preferences change it will notice that change and return the optimal choice.

Current Status as of August 2020

I haven’t finished the full software-as-a-service part of the solution with pricing and subscription functionality but the solution now works as a Cloudflare worker. The comparision of latency between the Cloudflare worker and the Lambda function is enough for another post.

You can see the first set of documentation for the service at