# Finding the perfect algorithm for realtime optimizing of content

I am looking for an algorithm that allows me the following:

I have a webpage and I want to randomly show one "content" from a list of contents on that webpage depending on who (visitor) sees the webpage. I know my visitors' demographic features like age, gender, locale. I assume that visitors with similar demographics have a similar taste regarding content on my website. I also know that they liked my content when they share it in the end.

What I have:

• A list of available contents, let's say: red, green, blue, purple, violet
• A constant stream of events of visitors with specific demographic data that share a content

What I want:

• First of all, all contents should be displayed completely randomly. Each user should randomly get one content without any preference
• As soon as the first user with a specific demographic shares the content they got I want other visitors with similar demographic features that end up on my webpage to see this specific content with a higher probability.

So basically I want a self optimizing system that learns in realtime.

Whilst the model is learning, you select the next action according to predicted reward from the model. There are choices between different workable strategies. For instance you could use an $\epsilon$-greedy approach: Pick the action with maximum predicted expected reward (or randomly choose between shared maximum values), but sometimes - with probability $\epsilon$ - you choose random content. There are other approaches and options that you can discover by researching contextual bandits and the simpler multi-armed bandit problems.