Knn Classifier
knn_classifierTrain 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
| Name | Required | Description | Default |
|---|---|---|---|
| p | No | ||
| scale | No | ||
| weights | No | uniform | |
| split_id | Yes | ||
| n_neighbors | No |