Skip to main content
Glama

train_classifier

Build and compare classification models on CSV, Parquet, or JSON data with configurable preprocessing, feature engineering, model selection, and evaluation metrics.

Instructions

Train a classification model using PyCaret with advanced configuration.

- NOTE: Please use absolute paths for data_path and test_data_path to avoid path resolution errors.

Args:
    data_path: Path to dataset (csv/parquet/json).
    target_column: Name of target column.
    test_data_path: Optional path to specific test dataset. If provided, used for evaluation/holdout.
    optimize: Metric to optimize for (e.g., 'Accuracy', 'AUC', 'Recall', 'Precision', 'F1', 'Kappa', 'MCC'). Default is 'Accuracy'.
    include_models: List of model IDs to include in comparison (e.g., ['lr', 'dt', 'rf']). If None, all models are compared (except heavy ones excluded by default).
    exclude_models: List of model IDs to exclude from comparison (e.g., ['catboost']). If None, defaults to excluding heavy models: ['svm', 'rbfsvm', 'gpc', 'mlp', 'ridge', 'qda'].
    ignore_features: Features to ignore.
    numeric_features: Features to treat as numeric.
    categorical_features: Features to treat as categorical.
    ordinal_features: Dictionary of ordinal features and their order (e.g., {'grade': ['low', 'medium', 'high']}).
    date_features: Features to treat as dates.
    text_features: Features to treat as text (for TF-IDF etc).
    keep_features: Features to ensure are kept.
    imputation_type: 'simple' or 'iterative' (default: 'simple').
    numeric_imputation: 'mean', 'median', 'mode' or int/float (default: 'mean').
    categorical_imputation: 'mode' or str (default: 'mode').
    fix_imbalance: If True, fix imbalance in training data (default: False).
    remove_outliers: If True, remove outliers from training data (default: False).
    normalize: If True, scale features (default: False). Recommended for linear models.
    normalize_method: 'zscore', 'minmax', 'maxabs', 'robust' (default: 'zscore').
    transformation: If True, apply gaussian transformation to make data more normal (default: False).
    transformation_method: 'yeo-johnson' or 'quantile' (default: 'yeo-johnson').
    polynomial_features: If True, create polynomial features (default: False).
    interaction_features: List of features to create interactions for.
    bin_numeric_features: List of numeric features to bin into categories.
    feature_selection: If True, select best features (default: False).
    feature_selection_method: 'classic', 'univariate', 'sequential' (default: 'classic').
    n_features_to_select: Fraction (0.0-1.0) or number of features to select (default: 0.2).
    fold_strategy: 'kfold', 'stratifiedkfold', 'groupkfold', 'timeseries' (default: 'kfold').
    fold: Number of folds (default: 10).
    n_jobs: Number of jobs to run in parallel (-1 for all cores).

Returns:
    JSON string with run_id, model_path, metrics, feature_importances, and report_path.

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": {
      "data_path": "<data_path>",
      "target_column": "<target_column>"
    },
    "name": "train_classifier"
  }
}

Input Schema

NameRequiredDescriptionDefault
foldNo
n_jobsNo
optimizeNo
data_pathYes
normalizeNo
date_featuresNo
fix_imbalanceNo
fold_strategyNokfold
keep_featuresNo
target_columnYes
text_featuresNo
exclude_modelsNo
include_modelsNo
test_data_pathNo
transformationNo
ignore_featuresNo
imputation_typeNosimple
remove_outliersNo
normalize_methodNozscore
numeric_featuresNo
ordinal_featuresNo
feature_selectionNo
numeric_imputationNomean
polynomial_featuresNo
bin_numeric_featuresNo
categorical_featuresNo
interaction_featuresNo
n_features_to_selectNo
transformation_methodNoyeo-johnson
categorical_imputationNomode
feature_selection_methodNoclassic

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.8

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description carries the full burden and it does disclose meaningful behavior: default exclusion of heavy model families, every preprocessing default, and the returned artifacts (run_id, model_path, report_path), which imply files are written. It never states expected runtime, that training can be long or resource-intensive, whether existing artifacts are overwritten, or what errors occur on bad paths beyond the absolute-path note.

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?

The purpose sentence and the absolute-path warning are front-loaded, followed by a scannable one-line-per-parameter block. Length is justified by 31 parameters, but a few entries are pure tautology ('ignore_features: Features to ignore', 'keep_features: Features to ensure are kept') and add no information.

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 31-parameter training tool this is close to complete: paths, target, model selection, preprocessing, folds, and outputs are all covered, and an output schema exists for return values. Minor gaps remain around data prerequisites (minimum rows, categorical target requirement) and the absence of enum constraints backing the listed string options.

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% across 31 parameters, and the description compensates by documenting every one with its purpose, accepted values, and default — including non-obvious ones like ordinal_features' dict-of-lists shape, the default heavy-model exclusion list, and n_features_to_select accepting a fraction or a count. This is exactly the compensation a zero-coverage schema requires.

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 classification model') plus the underlying engine (PyCaret) and that it supports advanced configuration. Classification versus the sibling train_regressor is implicit in the wording, so the agent can pick the right tool without opening the schema, though the alternative is never named.

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?

Usage detail is embedded rather than framed: it explains when to supply test_data_path (evaluation/holdout), that include_models defaults to all non-heavy models, and that normalization is 'Recommended for linear models'. There is no explicit when-to-use-this-vs-sibling guidance, no note on running process_data/inspect_data first, and no preconditions for the dataset.

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