Encode Categorical
encode_categoricalEncodes categorical dataset columns by automatically selecting one-hot or label encoding, with optional column limits and drop-first control.
Instructions
Encode categorical columns, choosing the encoding automatically.
Recommended: run train_test_split first and pass the split_id. If a dataset id is used,
pass columns explicitly so the target column is not encoded by accident.
Args:
dataset_id (str): ID of a dataset or of a split.
columns (list[str], optional): Categorical columns to encode. If omitted, all categorical columns.
method (str): "auto", "onehot" or "label". With "auto", columns with at most
max_onehot_categories categories are one-hot encoded and the rest are label encoded.
max_onehot_categories (int): Category limit used by "auto". Default is 10.
drop_first (bool): Passed to one-hot encoding. Default is False.
Returns:
dict: Which columns were one-hot encoded, which were label encoded, and the details.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"dataset_id": "<dataset_id>"
},
"name": "encode_categorical"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | auto | |
| columns | No | ||
| dataset_id | Yes | ||
| drop_first | No | ||
| max_onehot_categories | No |