Skip to main content
Glama

train_regressor

Train and compare regression models with PyCaret using configurable preprocessing, feature engineering, and evaluation. Returns model path, metrics, feature importances, and report.

Instructions

Train a regression 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., 'R2', 'RMSE', 'MAE', 'MSE', 'RMSLE', 'MAPE'). Default is 'R2'.
    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', 'mlp', 'kr', 'ard', 'par', 'ransac', 'tr', 'huber'].
    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.
    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').
    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_regressor"
  }
}

Input Schema

NameRequiredDescriptionDefault
foldNo
n_jobsNo
optimizeNoR2
data_pathYes
normalizeNo
date_featuresNo
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.6/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 disclosure burden. It does disclose useful behavior: default exclusion of heavy models, default fold/normalize/imputation settings, holdout evaluation when test_data_path is supplied, and that a model_path and report_path are persisted. It omits cost signals an agent needs, such as expected runtime, whether training is long-running or blocking, and whether repeated calls create distinct run_ids.

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 path warning is front-loaded and the Args block is well ordered, which is appropriate for a 30-parameter tool. Two small wastes: "advanced configuration" adds nothing, and the Returns section restates what the output schema already declares.

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 high-complexity tool with zero schema description coverage, the definition documents nearly every parameter with value sets and defaults, and the output schema covers return values. Remaining thin spots are the feature-role parameters (ignore_features, numeric_features, keep_features), whose interaction and precedence rules are not explained.

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% and there are 30 parameters with no enums in the schema, so the description is the only source of meaning. It supplies allowed value sets for optimize, imputation_type, numeric_imputation, normalize_method, transformation_method, feature_selection_method, and fold_strategy, plus concrete default lists for the excluded heavy models, which the schema does not express.

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?

"Train a regression model using PyCaret with advanced configuration" names a specific verb and resource, and the regressor framing implicitly separates it from the train_classifier sibling. The word "advanced" is filler, but the core purpose is unambiguous.

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

Usage Guidelines2/5

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

There is no explicit statement of when to choose this tool over train_classifier, whether data must first pass through process_data or inspect_data, or what happens if a test set is omitted. The only conditional guidance is the absolute-path warning and the include/exclude_models defaults, which are parameter mechanics rather than usage policy.

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