> ## Documentation Index
> Fetch the complete documentation index at: https://arize-ax.mintlify.site/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Client$Log()

> Batch Logging - Designed for sending batches of data to Arize

## Overview

The Client\$log() is designed for training, validation or production environment where batches of data are processed. These environments may be either a R Studio Notebook or a R server that is batch processing lots of backend data.

Import and initialize Arize R client from the Arize `Client$new()` to call `Client$log()` with a R data.frame() containing inference data.

## Initializing Client Examples

```java theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
ORGANIZATION_KEY <- 'ORGANIZATION_KEY'
API_KEY <- 'API_KEY'
arize_client <- Client$new(
    organization_key = ORGANIZATION_KEY, 
    api_key = API_KEY)
```

## Parameters & Returns

```php theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
schema <- create_schema(
  prediction_id_column_name = "prediction_id",
  prediction_label_column_name = "prediction_label",
  prediction_score_column_name = "prediction_score",
  actual_label_column_name = "actual_label",
  actual_score_column_name = "actual_score",
  feature_column_names = features,
  timestamp_column_name = "prediction_ts"
)


# send training data
arize_client$log(
  .data_frame = df_train,
  .schema = schema
  .model_id = model_id,
  .model_version = model_version,
  .model_type = model_types$SCORE_CATEGORICAL,
  .environment = environments$TRAINING,
)
```

| Parameter | Data Type | Description | Required |
| - | - | - | - |
| .data\_frame | data.frame | data.frame to log | Required |
| .schema | arize::create\_schema | the schema<br />(see `?arize::create_schema`) | Required |
| .model\_id | character | character, id for the model | Required |
| .model\_type | integer | `1` for binary,<br />`2` for numeric,<br />`3` for categorical,<br />`4` for score-categorical | Required |
| .environment | environment | `1` for production,<br />`2` for validation,<br />`3` for training | Required |
| .model\_version | character | character, the model version | Optional |
| .batch\_id | character | character, the batch id | Optional |
| .sync | logical | logical, whether to sync | Optional |
| .validate | logical | logical, whether to run validation checks | Optional |
| .path | character | character, path to use for serialization | Optional |

## Schema Attributes

| | | | |
| - | - | - | - |
| Attribute | Data Type | Description | Required |
| **prediction\_id\_column\_name** | character | Column name for prediction\_id | Required |
| **feature\_column\_names** | List\[character] | List of column names for features | Optional |
| **prediction\_label\_column\_name** | character | Column name for prediction label | Optional |
| **prediction\_score\_column\_name** | character | Column name for prediction scores | Optional |
| **actual\_label\_column\_name** | character | Column name for actual label | Optional |
| **actual\_score\_column\_name** | str | Column name for numeric sequences. Used for NDCG calculations in ranking models | Optional |
| **timestamp\_column\_name** | character | Column name for timestamps | Optional |

## Examples

Check out the [Example Tutorial](https://colab.research.google.com/github/Arize-ai/client_python/blob/main/arize/examples/tutorials/Arize_Tutorials/Model_Types/Arize_Tutorial_Log_Score_Categorical_Breast_Cancer_With_PandasLogger.ipynb)

### Example 1: Logging Features, Predictions, & Actuals

```php theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
model_id <- "click_through_rate_categorical_vignette_R"  # This is the model name that will show up in Arize
model_version <- "v1.0"  # Version of model - can be any string

schema <- create_schema(
  prediction_id_column_name = "id",
  feature_column_names = features,
  prediction_label_column_name = "predictions",
  prediction_score_column_name = "CTR_predicted",
  actual_label_column_name = "actuals",
  actual_score_column_name = "CTR",
  timestamp_column_name = "model_date"
)

arize_client$log(
  .data_frame = df_train,
  .model_id = model_id,
  .model_version = model_version,
  .model_type = model_types$SCORE_CATEGORICAL,
  .environment = environments$TRAINING,
  .schema = schema
)
```
