log
Arize method to log model data record-by-record.
log(
model_id: str,
model_type: ModelTypes,
environment: Environments,
model_version: Optional[str] = None,
prediction_id: Optional[Union[str, int, float]] = None,
prediction_timestamp: Optional[int] = None,
prediction_label: Optional[PredictionLabelTypes] = None,
actual_label: Optional[ActualLabelTypes] = None,
features: Optional[Dict[str, Union[str, bool, float, int]]] = None,
embedding_features: Optional[Dict[str, Embedding]] = None,
shap_values: Optional[Dict[str, float]] = None,
tags: Optional[Dict[str, Union[str, bool, float, int]]] = None,
batch_id: Optional[str] = None,
prompt: Optional[Union[str, Embedding]] = None,
response: Optional[Union[str, Embedding]] = None,
prompt_template: Optional[str] = None,
prompt_template_version: Optional[str] = None,
llm_model_name: Optional[str] = None,
llm_params: Optional[Dict[str, Union[str, bool, float, int]]] = None,
llm_run_metadata: Optional[LLMRunMetadata] = None,
)
Paramater | Data Type | Description |
---|---|---|
model_id | str | (Required) A unique name to identify your model in the Arize platform |
model_type | (Required*) Declared what model type this prediction/actual is for
*(as of v.5.X.X) | |
environment | (Required*) The environment that this prediction/actual is for (Production, Training, Validation)
*(as of v.5.X.X) | |
model_version | str | (Optional) Used to group together a subset of predictions and actuals for a given model_id. Defaults to no_version |
prediction_id | str | (Optional) A unique string to identify a prediction event. Important: This value matches a prediction to an actual label or feature importance (SHAP) in the Arize platform. If prediction_id is not provided, Arize will, when possible, create a random prediction id on the server side. |
prediction_timestamp | int | (Optional) int representing Unix epoch time in seconds, set overwrite the timestamp for prediction.If None , default to log prediction using the current timestamp.Important: Future and Historical predictions are supported up to 1 year from current wall clock time. |
prediction_label | One of str, bool, int, float, Tuple[str,float] | (Optional) The predicted value for a given model input.
*Ingest ranking predictions as a ranking object |
actual_label | One of str, bool, kkint, float, Tuple[str,float] | (Optional) The actual or ground truth value for a given model input. Important: This actual will be matched to the prediction with the same prediction_id as the one in this call even if they were logged in separate log calls.
*Ingest ranking actuals as a ranking object |
features | [dict<str, [str, bool, float, int, list]>)] | (Optional) Dictionary containing human readable and debuggable model features. Keys must be of type str . Values must be one of str , bool , float , int , list of string . |
embedding_features | (Optional) Dictionary containing human readable and debuggable model embedding features. Keys must be str . Values must be Embedding object | |
shap_values | [dict<str, float>] | (Optional) Dictionary containing human readable and debuggable model features keys, along with SHAP feature importance values. Keys must be str , Values must befloat . |
tags | [dict<str, [str, bool, float, long]>] | (Optional) Dictionary containing human readable and debuggable meta data that can be added on a prediction ID. This can be used to filter analysis by non-feature data. Keys must be str . Values must be one of str , bool , float , long . |
batch_id | str | (Optional) Only applicable to Validation datasets. Used to distinguish different batch of data under the same model_id and model_version. |
prompt | (Optional) Embedding object containing the embedding vector (required) and raw text (optional, but recommended) for the input text on which your GENERATIVE_LLM model acts on. | |
response | (Optional) Embedding object containing the embedding vector (required) and raw text (optional, but recommended) for the text GENERATIVE_LLM model generates. | |
prompt_template | str | (Optional) Template used to construct the prompt passed to a large language model. It can include variables using the double braces notation. Example: Given the context {{context}}, answer the following question {{user_question}} . |
prompt_template_version | str | (Optional) The version of the template used. |
llm_model_name | str | (Optional) The name of the llm used. Example: gpt-4 . |
llm_params | str | (Optional) Invocation hyperparameters passed to the large language model. Example: { "temperature": 0.7, "stop":[".","?"], "frequency_penalty":"0.2" } |
llm_run_metadata | (Optional) Run metadata for LLM calls. Example: LLMRunMetadata( total_token_count=400, prompt_token_count=300, response_token_count=100, response_latency_ms=2000, ) |
future = arize_client.log(
prediction_id=record["prediction_id"],
features=record["features"],
prediction_label=record["predicted_label"],
actual_label=record["actual_label"],
model_id="binary-classification-metrics-only-single-record-ingestion-tutorial",
model_type=ModelTypes.BINARY_CLASSIFICATION,
model_version="1.0.0",
environment=Environments.PRODUCTION
)
result = future.result()
Last modified 10h ago