target_encode
Transform high-cardinality categorical columns into smoothed target means, enabling better model performance. Use on training data after splitting to prevent leakage.
Instructions
Target-encode high-cardinality categorical columns. Each category is replaced by the smoothed mean of the target variable. Good for columns with many unique values. Best for high-cardinality (>10 categories). IMPORTANT: to avoid data leakage, split data first with train_test_split, then encode training set only. Example: target_encode(columns=["AgentCode","OriginCode"], target_column="Log_Revenue", smoothing=10.0)
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": {
"columns": "<columns>",
"target_column": "<target_column>"
},
"name": "target_encode"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| columns | Yes | ||
| df_name | No | ||
| smoothing | No | ||
| target_column | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |