Skip to main content
Glama

Knn Classifier

knn_classifier

Train a k-nearest-neighbours classifier on a train/test split and return model metrics and warnings; features are standardised by default for distance-based classification.

Instructions

Train a k-nearest-neighbours classifier: a row gets the majority class of its closest training rows. Distance based, so features are standardised by default. Slow on very large data. The split must have only numerical, complete features. Args: split_id (str): ID of a split made by train_test_split. n_neighbors (int): Number of neighbours. Default is 5. weights (str): "uniform" (all neighbours count equally) or "distance" (closer ones count more). Default is "uniform". p (int): Distance type: 1 = Manhattan, 2 = Euclidean. Default is 2. scale (bool): Standardise the features first (strongly recommended). Default is True. Returns: dict: model_id, train/test metrics (accuracy, precision, recall, F1, ROC-AUC) and warnings.

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": {
      "split_id": "<split_id>"
    },
    "name": "knn_classifier"
  }
}

Input Schema

NameRequiredDescriptionDefault
pNo
scaleNo
weightsNouniform
split_idYes
n_neighborsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does so well: it discloses the default standardisation, the distance-based nature, the performance caveat ('Slow on very large data'), the input constraint on feature types, and that warnings are returned. It does not cover model persistence or what happens to the returned model_id, which is a minor remaining gap.

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

Conciseness4/5

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

Front-loaded: the purpose, the algorithm intuition, and the two key constraints (standardisation, numerical complete features) come before the arg list. The per-parameter block is verbose but justified given zero schema coverage; little here is wasted.

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 no-annotation, no-output-schema training tool, the definition covers prerequisites, every parameter with defaults, and the contents of the returned dict (model_id, metrics, warnings). Only edge behaviors — invalid splits, or how model_id is later consumed — are left unstated.

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 document all five parameters, and it does: each arg gets a type, meaning, and default, including the allowed values for weights and the encoding of p. The interpretation of 'distance' weighting and the note that scale is 'strongly recommended' add genuine meaning beyond the bare schema.

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

Purpose4/5

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

States a specific verb and resource ('Train a k-nearest-neighbours classifier') and adds a one-line explanation of the algorithm's decision rule. It does not explicitly distinguish itself from sibling classifiers such as svm_classifier or decision_tree_classifier, but the operation and model family are unambiguous.

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

Usage Guidelines3/5

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

The description supplies a concrete prerequisite — features must be numerical and complete, and the split must come from train_test_split — which effectively tells the agent when this tool will fail. It never says when to prefer kNN over the other classifier siblings or what to do when the prerequisite is unmet, so guidance is implied rather than explicit.

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