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
| Name | Required | Description | Default |
|---|---|---|---|
| fold | No | ||
| n_jobs | No | ||
| optimize | No | R2 | |
| data_path | Yes | ||
| normalize | No | ||
| date_features | No | ||
| fold_strategy | No | kfold | |
| keep_features | No | ||
| target_column | Yes | ||
| text_features | No | ||
| exclude_models | No | ||
| include_models | No | ||
| test_data_path | No | ||
| transformation | No | ||
| ignore_features | No | ||
| imputation_type | No | simple | |
| remove_outliers | No | ||
| normalize_method | No | zscore | |
| numeric_features | No | ||
| ordinal_features | No | ||
| feature_selection | No | ||
| numeric_imputation | No | mean | |
| polynomial_features | No | ||
| bin_numeric_features | No | ||
| categorical_features | No | ||
| interaction_features | No | ||
| n_features_to_select | No | ||
| transformation_method | No | yeo-johnson | |
| categorical_imputation | No | mode | |
| feature_selection_method | No | classic |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |