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
| Name | Required | Description | Default |
|---|---|---|---|
| fold | No | ||
| n_jobs | No | ||
| optimize | No | ||
| data_path | Yes | ||
| normalize | No | ||
| date_features | No | ||
| fix_imbalance | 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 |