logger#

client#

Use this to log inferences from your model (ML, CV, NLP, etc.) to Arize.

To use in your code, import the following: from arize.pandas.logger import Client

class Client(api_key=None, space_id=None, space_key=None, uri='https://api.arize.com/v1', additional_headers=None, request_verify=True, developer_key=None, host=None, port=None)#

Bases: object

Arize API Client

log(dataframe, schema, environment, model_id, model_type, metrics_validation=None, model_version=None, batch_id=None, sync=False, validate=True, path=None, surrogate_explainability=False, timeout=None, verbose=False)#

Logs a pandas dataframe containing inferences to Arize via a POST request. Use this to upload inferences from your model (ML, CV, NLP, etc.) to Arize.

If you are looking to upload LLM traces or LLM evaluations, use log_spans or log_evaluations, respectively.

Returns a Response object from the Requests HTTP library to ensure successful delivery of records.

Parameters:
  • dataframe (pd.DataFrame) – The dataframe containing model data.

  • schema (BaseSchema) – A BaseSchema instance that specifies the column names for corresponding data in the dataframe. Can be either a Schema or CorpusSchema (if the environment is Environments.CORPUS) object. To use the casting feature, set Schema feature or tag columns to a TypedColumns object.

  • environment (Environments) – The environment the data corresponds to (Production, Training, Validation).

  • model_id (str) – A unique name to identify your model in the Arize platform.

  • model_type (ModelTypes) – Declare your model type. Can check the supported model types running ModelTypes.list_types().

  • metrics_validation (List[Metrics], optional) – A list of desired metric types; defaults to None. When populated, and if validate=True, the presence of schema columns are validated against the desired metrics.

  • model_version (str, optional) – Used to group a subset of predictions and actuals for a given model_id to compare and track changes. Defaults to None.

  • batch_id (str, optional) – Used to distinguish different batch of data under the same model_id and model_version. Defaults to None.

  • sync (bool, optional) – When sync is set to True, the log call will block, or wait, until the data has been successfully ingested by the platform and immediately return the status of the log. Defaults to False.

  • validate (bool, optional) – When set to True, validation is run before sending data. Defaults to True.

  • path (str, optional) – Temporary directory/file to store the serialized data in binary before sending to Arize.

  • surrogate_explainability (bool, optional) – Computes feature importance values using the surrogate explainability method. This requires that the arize module is installed with the [MimicExplainer] option. If feature importance values are already specified by the shap_values_column_names attribute in the Schema, this module will not run. Defaults to False.

  • timeout (float, optional) – You can stop waiting for a response after a given number of seconds with the timeout parameter. Defaults to None.

  • verbose – (bool, optional) = When set to true, info messages are printed. Defaults to False.

Returns:

Response object

client (single record)#

To use in your code, import the following: from arize.api import Client

class Client(api_key=None, space_id=None, space_key=None, uri='https://api.arize.com/v1', max_workers=8, max_queue_bound=5000, timeout=200, additional_headers=None, request_verify=True)#

Bases: object

Arize API Client to log model predictions and actuals to the Arize AI platform

log(model_id, model_type, environment, model_version=None, prediction_id=None, prediction_timestamp=None, prediction_label=None, actual_label=None, features=None, embedding_features=None, shap_values=None, tags=None, batch_id=None, prompt=None, response=None, prompt_template=None, prompt_template_version=None, llm_model_name=None, llm_params=None, llm_run_metadata=None)#

Logs a record to Arize via a POST request.

Parameters:
  • model_id (str) – A unique name to identify your model in the Arize platform.

  • model_type (ModelTypes) – Declare your model type. Can check the supported model types running ModelTypes.list_types()

  • environment (Environments) – The environment that this dataframe is for (Production, Training, Validation).

  • model_version (str, optional) – Used to group together a subset of predictions and actuals for a given model_id to track and compare changes. Defaults to None.

  • prediction_id (str, int, or float, optional) – A unique string to identify a prediction event. This value is used to match a prediction to delayed actuals in Arize. If prediction id is not provided, Arize will, when possible, create a random prediction id on the server side.

  • prediction_timestamp (int, optional) – Unix timestamp in seconds. If None, prediction uses current timestamp. Defaults to None.

  • prediction_label (bool, int, float, str, Tuple(str, float) – RankingPredictionLabel or MultiClassPredictionLabel; optional): The predicted value for a given model input. Defaults to None.

  • ( (actual_label) – bool, int, float, str, Tuple[str, float], ObjectDetectionLabel, RankingActualLabel, MultiClassActualLabel, optional

  • ) – The ground truth value for a given model input. This will be matched to the prediction with the same prediction_id as the one in this call. Defaults to None.

  • features (Dict[str, Union[str, bool, float, int]], optional) – Dictionary containing human readable and debuggable model features. Defaults to None.

  • embedding_features (Dict[str, Embedding], optional) – Dictionary containing model embedding features. Keys must be strings. Values must be of type Embedding. Defaults to None.

  • shap_values (Dict[str, float], optional) – Dictionary containing human readable and debuggable model features keys, along with SHAP feature importance values. Defaults to None.

  • tags (Dict[str, Union[str, bool, float, int]], optional) – Dictionary containing human readable and debuggable model tags. Defaults to None.

  • batch_id (str, optional) – Used to distinguish different batch of data under the same model_id and model_version. Required for VALIDATION environments. Defaults to None.

  • prompt (str or Embedding, optional) – input text on which the GENERATIVE_LLM model acts. It accepts a string or Embedding object (if sending embedding vectors is desired). Required for GENERATIVE_LLM models. Defaults to None.

  • response (str or Embedding, optional) – output text from GENERATIVE_LLM model. It accepts a string or Embedding object (if sending embedding vectors is desired). Required for GENERATIVE_LLM models. Defaults to None.

  • prompt_template (str, optional) – template used to construct the prompt passed to a large language model. It can include variable using the double braces notation. Example: ‘Given the context {{context}}, answer the following question {{user_question}}.

  • prompt_template_version (str, optional) – version of the template used.

  • llm_model_name (str, optional) – name of the llm used. Example: ‘gpt-4’.

  • llm_params (str, optional) – hyperparameters passed to the large language model.

  • llm_run_metadata (LLMRunMetadata, optional) – run metadata for llm calls.

Returns:

concurrent.futures.Future object