Skip to main content
Glama

Encode Categorical

encode_categorical

Encodes 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

NameRequiredDescriptionDefault
methodNoauto
columnsNo
dataset_idYes
drop_firstNo
max_onehot_categoriesNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the behavioral burden. It usefully explains the auto-selection threshold, default max_onehot_categories, drop_first behavior, and the return summary, but it does not state whether the input dataset is modified in place, whether original columns are retained, or how errors are handled.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core action and recommendation, then uses clear Args and Returns sections. Every line contributes useful information, and there is no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a five-parameter transformation tool with no annotations or output schema, the description is mostly complete: it explains parameters, automatic encoding logic, and the return summary. The main remaining gap is whether the operation mutates the dataset or returns a new encoded representation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, and it does. It documents all five parameters, including the allowed method values, the dataset-or-split meaning of dataset_id, optional columns behavior, max_onehot_categories, and drop_first.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: 'Encode categorical columns, choosing the encoding automatically.' It also distinguishes this tool from sibling encoders like label_encode and one_hot_encode by making automatic method selection the central behavior.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives clear operational guidance: run train_test_split first and pass the split_id, and explicitly pass columns when using a dataset id to avoid encoding the target. It does not explicitly compare when to use this tool versus label_encode or one_hot_encode.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools