Skip to main content

Using Arize to monitor inferences

Connect Arize to Modelbit to monitor the inferences produced by your deployments.

Adding Arize keys to Modelbit

To add your Arize Space and API keys to Modelbit:

  1. Locate your Space Key and API Key in Arize on the Space Settings page.
  2. In Modelbit, click the Arize integration in Settings and your keys.

Once the Space and API keys have been added to Modelbit you're ready to use the Arize client in your deployments.

Setting up your notebook environment

To make development easier in your Notebook environment, set the envvars ARIZE_SPACE_KEY and ARIZE_API_KEY to your Arize Space and API keys.

Alternatively, you can use Modelbit to set those environment variables:

import os

os.environ["ARIZE_SPACE_KEY"] = mb.get_secret("ARIZE_SPACE_KEY")
os.environ["ARIZE_API_KEY"] = mb.get_secret("ARIZE_API_KEY")

Logging inferences to Arize

Define a function that will log your inference results to Arize. Note that Client() is called within this function:

from arize.api import Client
from arize.utils.types import ModelTypes, Environments

def log_to_arize(features, prediction):
arize_resp = Client().log(
model_id='sample-model-1',
model_type=ModelTypes.SCORE_CATEGORICAL,
environment=Environments.PRODUCTION,
features=features,
prediction_label=prediction,
).result()
if arize_resp.status_code != 200:
print(f'Arize logging failed: {arize_resp.text}')

Next, define your inference function that logs its results to Arize by calling log_to_arize:

def example_arize(features):
# first, calculate your inference
prediction = ('Fraud', 0.4) # This might be "model.predict(features...)" in your code

# then log the inference to Arize
log_to_arize(features, prediction)

# after logging is complete, return the inference
return prediction

Finally, deploy your inference function to Modelbit. The call to mb.deploy will automatically include your log_to_arize function:

mb.deploy(example_arize)

Whenever your deployment produces an inference, that inference will be logged to Arize.

Arize logging API

For more information on what you can log to Arize, see Arize's Python Single Record documentation.