Skip to main content
Glama

train_test_split

Split a dataframe into train and test sets for model validation. Preserve class proportions with stratify, and ensure reproducibility with a fixed random_state.

Instructions

Split dataframe into train/test sets. Stores them as '{name}_train' and '{name}_test'. stratify=True preserves target class proportions (classification only). Run BEFORE training any model. Always use fixed random_state for reproducibility. Use stratify=True for imbalanced classification datasets. Example: train_test_split(target_column="Revenue", test_size=0.2)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
df_nameNo
stratifyNo
test_sizeNo
random_stateNo
target_columnYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

No annotations are provided, but the description discloses key behaviors: it stores results with '_train' and '_test' suffixes, stratify behavior, and the importance of random_state. It does not explicitly state whether the original dataframe is modified, but the overall transparency is strong.

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 concise and well-structured, with the primary action first, followed by important behavioral notes and a clear example. Every sentence adds value without being verbose.

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

Completeness5/5

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

Given the tool's moderate complexity and the presence of an output schema, the description provides sufficient context: usage timing, parameter guidance, stratification behavior, and an example. It fully equips an agent to use the tool correctly in a data science workflow.

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

Parameters4/5

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

Schema description coverage is 0%, so the description is the only source of parameter meaning. It explains target_column, test_size, stratify, and random_state, but does not explicitly describe df_name. The example covers all main parameters, compensating well for the schema gap.

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 clearly states the tool's purpose: splitting a dataframe into train/test sets, with a specific output naming pattern. It distinguishes itself from sibling tools like train_model or evaluate_model by being the explicit preprocessing step.

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

Usage Guidelines5/5

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

The description provides explicit usage context: 'Run BEFORE training any model' and gives practical recommendations like using a fixed random_state and stratify for imbalanced classification. It also includes a concrete example, making it easy for an agent to know when and how to invoke it.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AstyanM/mcp-data-science'

If you have feedback or need assistance with the MCP directory API, please join our Discord server