Fetch metadata from prediction jobs¶
This notebook outlines how to retrieve metadata from prediction jobs with DataRobot's REST API.
In the DataRobot UI, you can see prediction jobs on the Deployments page; this list includes all batch prediction jobs made from REST API code, through DataRobot's Python API client, or from job definitions.
Using DataRobot's REST API, you can get more details on each of those predictions; however, you need to use Python to complete this task.
import getpass
import os
import datarobot as dr
import pandas as pd
import requests
print(os.getcwd())
token = getpass.getpass() # Use your own token
dr.Client(token=token, endpoint="https://app.datarobot.com/api/v2")
Connect to DataRobot¶
Read more about different options for connecting to DataRobot from the client.
API_ENDPOINT = "https://app.datarobot.com/api/v2/batchPredictions"
# Enter your API key here
API_KEY = token
session = requests.Session()
session.headers = {
"Authorization": "Bearer {}".format(API_KEY),
}
session.close()
Fetch metadata¶
Use the snippet below to get metadata from your prediction jobs. The following cell displays an example of what the retrieved data looks like.
resp = session.get(API_ENDPOINT)
print(resp.status_code)
df = pd.json_normalize(resp.json()["data"])
df.head()
Fetch data points¶
log1 = pd.DataFrame(df.iloc[1,])
with pd.option_context(
"display.max_rows", 1000, "display.max_columns", 1000
): # more options can be specified also
display(log1)