Optimize Any Python, Swift, or Java Object with Reinforcement Learning

2 minute read

Improve AI is a machine learning platform for making apps self-improving, meaning they optimize their own data structures and variables to improve revenue and conversions.

With Improve AI v7.2, you can now optimize the variables of any Java, Swift, or Python object with reinforcement learning. It’s like an exponentially faster form of A/B testing.

The new optimize() method finds the best combination of variable values given current conditions.

Optimized objects are created immediately, on the fly, with zero network latency.

Optimize Any Object

Improve AI can optimize any object or JSON-encodable dictionary in Swift, Java, or Python to find the best combination of variables given current conditions.

As an example, let’s optimize a pop up discount offer in an iOS app. The goal is to maximize expected revenue by assigning the best combination of variable values.

First, we’ll create an Offer type with four variables: title, description, discount, and buttonText:

struct Offer: Codable {
    var title: String
    var description: String
    var discount: Float
    var buttonText: String
}

Next we’ll create a mapping from each variable to possible values.

Here the values are hardcoded but they could easily be loaded from a database or configuration file:

titles = ["Special Offer!", "Limited Time!"]
descriptions = ["New and improved.", "Great features." "Huge value."]
discounts = [0.1, 0.2, 0.3, 0.4]
buttonTexts = ["Try Free", "Subscribe", "Continue"]

To generate an optimized Offer, simply call optimize() with a map of the variables and the Offer type.

offer = offersModel.optimize(["title": titles, "description": descriptions, "discount": discounts, "buttonText": buttonTexts], 
                             Offer.self)

The best combination of variables is selected by the machine learning model and the result is returned as a new Offer object.

That’s like A/B testing on steroids.

Contextual Optimization

Unlike A/B testing, optimize() also considers the context of each variable assignment. On iOS and Android, the context automatically includes country, language, OS, device, time of day and many other attributes. (No personally identifiable information is ever used, transmitted, or stored)

With contextual optimization, different versions of the object may be returned for different contexts. This allows the object’s variables to adapt dynamically to it’s environment, enabling deep optimization, personalization, and more.

Custom context can also be provided via given():

offer = offersModel.given(["churned": true])
                   .optimize(variableMap, Offer.self)

In this example, given the user has churned, create an Offer that will maximize expected revenue.

Perhaps churned users need a larger discount? Perhaps they just need a nudge with the right message? With optimize() you don’t have to guess - it will automatically learn the best Offer for each context.

Contextual optimization, which is often infeasible with A/B testing, is trivial with this new capability.

Simple Training

optimize() is easily trained with reinforcement learning.

if (purchased) {
    offersModel.addReward(profit)
}

With reinforcement learning, positive rewards are assigned for positive outcomes (a “carrot”) and negative rewards are assigned for undesirable outcomes (a “stick”).

When rewards are business metrics, such as revenue or conversions, it will automatically optimize those metrics over time.

Getting Started

Object optimization is available immediately for Python, iOS, and Android/Java. See the Quick-Start Guide to learn more.

Thank you for your efforts to improve the world a little bit today.

Updated: