Predicting Outcomes

Use your prediction report to build scenarios and forecast outcomes.

Using Obviously AI's APIs you can now setup scenarios and predict outcomes using any prediction report you have created on the Obviously AI platform. These details can be exported to your app to show your users or for any internal purpose. So, let's get started.

1. Create Prediction Report

This API endpoint only works with existing reports already made on the Obviously AI platform. To make a prediction report simply upload your data, go to the Predict page and pick a column you want to predict. This will generate a Prediction report for you, you can now use this report to build personas and scenarios and predict the outcome via API. Here is a quick demo video for making a prediction report:

2. Get Report ID

To get your Report ID, simply copy the string after the app.obviously.ai/predictions/ from the URL of the report page. We will use this to identify which report's details we want to pull.

3. Calling the API

Now that we have the Report ID, we can use this along with our API Key to call the /user/persona endpoint. On this endpoint, you make a post request with all the attributes of the persona and get a JSON with predicted probabilities back. It's as simple as writing a few lines of code:

curl https://api.obviously.ai/user/persona
-H 'Authorization: ApiKey <api_key>'
-d '{
  "features": {
    "<column_A>": value_A,
    "<column_B>": value_B,
    "<column_C>": value_C,
    "<column_D>": value_C,
    "<column_E>": value_E,
    "<column_F>": value_F,
  },
  "id": "<report_id>"
}'
import requests

head = {
    'Authorization' : 'ApiKey <api_key>'
}

data = {
  "features" : {
    "<column_A>": value_A,
    "<column_B>": value_B,
    "<column_C>": value_C,
    "<column_D>": value_C,
    "<column_E>": value_E,
    "<column_F>": value_F,
  },
  "id": "<report_id>"
}

response = requests.post(
  'https://api.obviously.ai/user/persona', 
  json=data, 
  headers=head
)

response.json()

You can find detailed documentation about the /user/persona endpoint here.

4. Other Actions

Additionally, you can also use the /user/batch-persona endpoint here, that allows you to predict outcomes for personas in large batches. And similarly, use /user/batch-predict endpoint here, that allows you to make predictions directly from a list of personas in a CSV file. Learn more on the endpoints page.