# Predictive Churn

{{< glossary_definition "predicted_to_churn" >}}

Churn is a natural part of engagement ebb and flow, and while a
certain amount of churn is normal and healthy, there are ways to identify
churn risk factors and take actions to prevent your user base from eroding.

## About Predictive Churn

With Predictive Churn, you can identify app and web users by their likelihood to churn, based on risk profiles Airship generates via machine learning, using [gradient boosted decision tree](https://en.wikipedia.org/wiki/Gradient_boosting) methodology.

Risk factors update weekly and are exposed as [Tags](https://www.airship.com/docs/reference/glossary/#tag) for [segmentation](https://www.airship.com/docs/guides/audience/segmentation/segmentation/) and analysis in [Performance Analytics](https://www.airship.com/docs/reference/glossary/#pa), and exposed as Tag Change events in [Real-Time Data Streaming](https://www.airship.com/docs/reference/glossary/#rtds).

Example use cases for Predictive Churn:

* Target users with offers before they churn.
* Run an A/B Test with a single variant and a control group to measure the message's impact on churn.
* Trigger an automation or [Sequence](https://www.airship.com/docs/reference/glossary/#sequence) based on a change in risk group.
* Send a message in a Sequence based on a change in risk group.
* Create a [Segment](https://www.airship.com/docs/reference/glossary/#segment) that blends risk groups based on the type of messaging and your goals.

### The Predictive Churn model

Predictive Churn belongs to Airship's *Predictive*
suite of products, which uses
[machine learning](https://en.wikipedia.org/wiki/Machine_learning) to
predict user behaviors and optimize engagement strategy for customer
lifecycle marketers.

The model is trained on recency and frequency of notification sends and app opens or website visits for a cross-section of anonymized apps and sites. It runs weekly on Mondays. It detects the most relevant risk factors for a churn outcome and assigns a high, medium, or low churn factor to each user who has been active in the past 60 days. By including your app key as an input, the model tailors its predictions to your audience based on your app or website usage.

Notable terms:

Active User
: An *active user* is a member of your audience that has opened your app, had an active web session, or clicked a web notification in the last 30 days.

Inactive User
: An *inactive user* is a member of your audience that had a predictive tag of high, medium, or low and has not opened your app, had an active web session, or clicked a web notification in the last 30 days.

Churn
: A *churn* outcome occurs when a previously active user becomes inactive, i.e., Airship has not seen any activity (measured in app opens, website visits, or web notification clicks) from a user in the last 30 days. Push opt-in status does not factor into the churn outcome, so it is possible that a user who opted out of notifications could still appear active for churn prediction purposes.
   > **Note:** A churned user is not the same as an uninstalled user.


Churn Risk
: Predictive Churn makes a prediction about the likelihood of a future churn
   outcome, meaning that a user will go inactive. We assign one of three
   measures of risk for such an outcome:

   * High — Users most likely to become inactive
   * Medium — Users who exhibit signs of potentially becoming inactive
   * Low — Users least likely to become inactive

### Tags and change events

A user's churn risk profile is represented as a `high`, `medium`, or `low` [Tag](https://www.airship.com/docs/reference/glossary/#tag) within the `ua_churn_prediction` [Tag Group](https://www.airship.com/docs/reference/glossary/#tag_group). Changes to that tag are represented as `TAG_CHANGE` events.

Tag changes return both the change in tag (`add` or `remove`) and the `current` tag. The `current` tag is the end result of the tag change. There are three scenarios for tag change events:

* **Add prediction** — Adds a new Predictive Churn tag to a channel that did not previously have a prediction. Not all devices begin with a churn prediction; churn prediction is assigned to active users when the Predictive Churn model runs (weekly on Mondays).
* **Prediction change** — Replaces the prediction on a channel.
* **Remove prediction** — Removes the prediction from a channel, typically when a channel becomes inactive.

The following is an example of a Predictive Churn tag change:

```json
{
   "id": "e1559cd7-af96-45ab-bb74-a22cd99a01d5",
   "offset": "1422600",
   "occurred": "2017-01-15T09:26:30.362Z",
   "processed": "2017-01-15T16:15:30.048Z",
   "device": {
      "android_channel": "d5ec96e3-5ced-47b0-a4dd-1b2b6bda442e",
      "named_user_id": "job.bob@example.com",
      "attributes": {
         "locale_variant": "",
         "app_version": "312",
         "device_model": "LG-H811",
         "app_package_name": "com.company.app",
         "iana_timezone": "America/Los_Angeles",
         "push_opt_in": "true",
         "locale_country_code": "US",
         "device_os": "6.0",
         "locale_timezone": "-28800",
         "locale_language_code": "en",
         "location_enabled": "true",
         "background_push_enabled": "true",
         "ua_sdk_version": "6.1.2",
         "location_permission": "ALWAYS_ALLOWED"
      }
   },
   "body": {
      "add": {
         "ua_churn_prediction": [
         "medium"
         ]
      },
      "remove": {
         "ua_churn_prediction": [
         "high"
         ]
      },
      "current": {
         "ua_churn_prediction": [
         "medium"
         ]
      }
   },
   "type": "TAG_CHANGE"
   }
```


See the [Tag change event](https://www.airship.com/docs/developer/rest-api/connect/schemas/events/#tag-change) in the [Real-Time Data Streaming](https://www.airship.com/docs/reference/glossary/#rtds) API reference.

## Use Predictive Churn in messaging

Before you can use Predictive Churn for targeting, you must enable it for your project. It is supported for production projects only. If your app and website both use the Airship SDK, you should enable the feature for both.

1. Next to your project name, select the dropdown menu (
), then **Settings**.
1. Under **Project settings**, select **Predictive AI**.
1. Enable **Predictive App Churn** and/or **Predictive Web Churn**.

Tags are assigned the first Monday after enabling the feature.

### Segments

You can include a Predictive Churn risk profile in your [Segments](https://www.airship.com/docs/reference/glossary/#segment). First, search for and select **Predicted to Churn**, and then select an operator and a risk profile.

### Message and experiment audiences

Add a Predictive Churn risk profile as an audience condition for messages and experiments. See **Predicted to Churn** in [Targeting Specific Users](https://www.airship.com/docs/guides/audience/segmentation/target-specific-users/).

You can also specify a risk profile for individual Sequence messages. See **Conditions** in [Add messages to a Sequence](https://www.airship.com/docs/guides/messaging/messages/sequences/create/add-messages/).

### Automation and Sequence triggers

Trigger an [Automation](https://www.airship.com/docs/guides/messaging/messages/sequences/create-automation/) or [Sequence](https://www.airship.com/docs/reference/glossary/#sequence) based on changes to a user's Predictive Churn risk profile. For example, you might set up an automation to send users a special offer when their Predictive Churn risk changes to High, helping retain users at risk of leaving your audience. See **Predicted to Churn** in [Automation and Sequence triggers](https://www.airship.com/docs/guides/messaging/messages/sequences/triggers/). For automation using the API, see the next section.

You can also set a churn risk profile as a trigger condition. For Automations, see **Conditions** in [Create an Automation](https://www.airship.com/docs/guides/messaging/messages/sequences/create-automation/). For Sequences, see **Conditions** in the Trigger step in [Create a Sequence](https://www.airship.com/docs/guides/messaging/messages/sequences/create/create/).

### Audience definition in the API

With the API, use the [audience tag selector object](https://www.airship.com/docs/developer/rest-api/ua/schemas/audience-selection/) to target by the `ua_churn_prediction` Tag Group and Tag values `low`, `medium`, or `high`.

For example, the following is a notification to users of all device types whose current churn prediction is `medium`:

```http
POST /api/push HTTP/1.1
Authorization: Basic <master authorization string>
Content-Type: application/json
Accept: application/vnd.urbanairship+json; version=3

{
   "audience": {
      "tag": "medium",
      "group": "ua_churn_prediction"
   },
   "notification": {
        "alert": "me·di·um, n., an agency or means of doing something."
    },
    "device_types": [
       "ios",
       "android",
       "web"
    ]
}
```


## Analytics

In [Performance Analytics](https://www.airship.com/docs/reference/glossary/#pa), the [Predictive Dashboard](https://www.airship.com/docs/guides/reports/analytics/definitions/#predictive) helps you track churn risk factors over time. This Dashboard provides a view into Predictive Churn risk groups, distribution of users across risk groups, and the performance of churn mitigation tactics. If you have both Predictive App and Web Churn enabled, you can set the Device Family filter to Web or Mobile to see churn data for either audience.

Predictive tags update every Sunday, and reports default to the most recent update.

**Use cases:**

* Explore added or removed Predictive tags.
* Slice user behavior by churn risk tag.
* Export ad IDs, named users, and channel IDs based on their risk category.
* Export named users and ad IDs based on app opens, uninstalls, and risk category.
* Find churn cohorts and slice by the users' current tags.
* Find churn cohorts, filter, then analyze a funnel of past behavior.
