Sklearn Grid Search CV icon

Sklearn Grid Search CV

Perform hyperparameter tuning using Grid Search with Cross-Validation

Sklearn Grid Search CV

AI-generated

Summary

Perform hyperparameter grid search with cross‑validation on a specified scikit‑learn model and return best parameters and optional trained model.

Inputs

  • modelType — Select the scikit‑learn estimator type to train.
  • featureColumns (required) — Comma‑separated list of feature column names.
  • targetColumn (required) — Name of the target column.
  • paramGrid (required) — JSON string defining the hyperparameter grid to search.
  • cv — Number of cross‑validation folds.
  • scoring — Scoring metric used to evaluate models.
  • returnModel — Whether to include the best trained model in the output.
  • nJobs — Number of parallel jobs; -1 uses all processors.
  • pythonPath — Path to the Python executable that has scikit‑learn installed.

Output shape

list of result objects

Each result includes best_params, best_score, cv_results, and optionally best_model (base64‑encoded pickle) and feature_columns; errors are propagated unless continueOnFail is enabled.

Examples

Example 1: Train a logistic regression classifier on a classification dataset using default settings.

modelType=LogisticRegression, featureColumns='feat1,feat2', targetColumn='label', paramGrid='{"C": [0.1,1,10]}', cv=5, scoring='accuracy', returnModel=true

Example 2: Tune a random forest regressor on a regression dataset with a custom grid and 3 folds.

modelType=RandomForestRegressor, featureColumns='f1,f2,f3', targetColumn='y', paramGrid='{"n_estimators": [100,200], "max_depth": [10,20]}', cv=3, scoring='neg_mean_squared_error', nJobs=4

Discussion