Arize AI
Search…
Python Real-Time
1. Install, Import, and Instantiate Arize
!pip install arize
from arize.api import Client
from arize.utils.types import ModelTypes
from datetime import datetime
import uuid
# Instantiate an Arize Client object using your API and Space keys
API_KEY = 'ARIZE_API_KEY'
SPACE_KEY = 'YOUR SPACE KEY'
arize_client = Client(space_key=SPACE_KEY, api_key=API_KEY)
2. Capture your model's features
# Example features, swap these out for your own!
features = {
'city': 'Berkeley',
'merchant_name': 'Philz Coffee',
'merchant_type': 'Coffee Shop',
'charge_amount': 18.55,
}
3. Capture your model's predictions and actuals
prediction_label = 'YOUR_PREDICTION_LABEL'
prediction_score = YOUR_PREDICTION_SCORE
actual_label = 'YOUR_ACTUAL_LABEL'
actual_score = YOUR_ACTUAL_SCORE
4. Log the prediction to Arize
# Log the prediction using arize_client.log
# Be sure to set up your own model parameters in the method call below
response = arize_client.log(
model_id='YOUR_MODEL_NAME',
model_type=ModelTypes.SCORE_CATEGORICAL, # or ModelTypes.NUMERIC, see docs.arize.com for more info
model_version='v1',
prediction_id=str(uuid.uuid4()), # unique identifier for a specific prediction
features=features,
prediction_label=(prediction_label, prediction_score),
actual_label=(actual_label, actual_score)
)
5. Inspect the response
res = response.result()
if res.status_code == 200:
print(f"✅ You have successfully logged production set to Arize")
else:
print(f"logging failed with response code {res.status_code}, {res.text}")
Copy link