Sklearn Cross Validation
AI-generatedSummary
Run cross-validation on the chosen sklearn model, returning per-fold scores and metrics.
Inputs
- modelType — Model type to use (e.g., LogisticRegression, RandomForestClassifier).
- cvMethod — Cross-validation method (e.g., kfold, stratified).
- folds — Number of folds for cross-validation.
- featureColumns (required) — Comma-separated list of feature column names.
- targetColumn (required) — Name of the target column.
- scoring — Scoring metric for cross-validation.
- randomState — Random seed for reproducibility.
- pythonPath — Path to Python executable with scikit-learn installed.
Output shape
array of result objects
Each input row yields a result object with model_type, cv_method, scoring_metric, n_folds, mean_test_score, std_test_score, mean_train_score, std_train_score, test_scores_per_fold, train_scores_per_fold, fit_times, and total_samples; on error the object includes an 'error' field.
Examples
Example 1: Classify using Logistic Regression with 5-fold CV
modelType=LogisticRegression, cvMethod=kfold, folds=5, featureColumns=feature1,feature2, targetColumn=target, scoring=accuracy, randomState=42
Example 2: Regression with Random Forest Regressor, 3-fold CV
modelType=RandomForestRegressor, cvMethod=kfold, folds=3, featureColumns=age,income,feature3, targetColumn=salary, scoring=r2, randomState=123
Example 3: Classification with SVC and Stratified K-Fold
modelType=SVC, cvMethod=stratified, folds=10, featureColumns=age,income, targetColumn=churn, scoring=f1_weighted, randomState=7