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:
- Locate your Space Key and API Key in Arize on the
Space Settings
page. - In Modelbit, click the
Arize
integration inSettings
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.
Example deployment using Arize
Logging results to Arize requires calling their API from within your deployment. Here is sample code that uses mb.get_secret
to load your Arize API keys. The function log_to_arize
logs information about the inference to Arize.
import os
from arize.api import Client
from arize.utils.types import ModelTypes, Environments
os.environ["ARIZE_SPACE_KEY"] = mb.get_secret("ARIZE_SPACE_KEY")
os.environ["ARIZE_API_KEY"] = mb.get_secret("ARIZE_API_KEY")
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}')
def example_arize(features):
# First, calculate your inference
# This might be "model.predict(features...)" in your code
prediction = ('Fraud', 0.4)
# Then log the inference to Arize
log_to_arize(features, prediction)
# After logging is complete, return the inference
return prediction
Use mb.deploy
or Git to deploy example_arize
to Modelbit. Whenever this 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.