Expert Config: Hyperparameters, Cross-Validation, and Class Balancing
Understand hyperparameters, algorithm-specific config forms, cross-validation, feature selection, class balancing (SMOTE/undersampling), and training options.
Expert Config: Hyperparameters, Cross-Validation, and Class Balancing
Expert Config lets you control how each algorithm is trained. This guide covers hyperparameters, cross-validation, feature selection, class balancing, and training options.
What Are Hyperparameters?
Hyperparameters are settings you choose before training. They control how the algorithm learns—for example, how many trees in a forest, how deep they are, or how fast the model learns.
| Hyperparameter | Affects | Typical Values |
|---|---|---|
| nestimators | Number of trees (Forest, XGBoost) | 50–500 |
| maxdepth | Tree depth | 3–20 |
| learningrate | Step size in gradient descent | 0.01–0.3 |
| minsamplesleaf | Minimum samples per leaf | 1–20 |
| C (SVM) | Regularization strength | 0.1–100 |
| nneighbors (KNN) | Number of neighbors | 3–50 |
Algorithm-Specific Config Forms
Each algorithm has its own set of hyperparameters. The platform shows a form for the algorithm you selected.
Tree-Based (Decision Tree, Random Forest, XGBoost, LightGBM)
| Parameter | What It Does |
|---|---|
| nestimators | Number of trees |
| maxdepth | Maximum tree depth (deeper = more complex) |
| minsamplessplit | Minimum samples to split a node |
| minsamplesleaf | Minimum samples per leaf |
| learningrate | Step size (boosting only) |
| subsample | Fraction of rows per tree (reduces overfitting) |
| colsamplebytree | Fraction of features per tree |
Linear (Logistic, Ridge, Lasso, Elastic Net)
| Parameter | What It Does |
|---|---|
| C | Inverse of regularization strength |
| penalty | L1, L2, or Elastic Net |
| alpha | Regularization amount (Ridge/Lasso) |
| l1ratio | Mix of L1 vs L2 (Elastic Net) |
SVM
| Parameter | What It Does |
|---|---|
| C | Margin vs misclassification trade-off |
| kernel | linear, rbf, poly |
| gamma | Kernel coefficient (rbf, poly) |
| degree | Polynomial degree (poly kernel) |
KNN
| Parameter | What It Does |
|---|---|
| nneighbors | Number of neighbors |
| weights | uniform or distance |
| metric | Distance (euclidean, manhattan) |
Neural Network
| Parameter | What It Does |
|---|---|
| hiddenlayersizes | Neurons per layer (e.g., 100, 50) |
| activation | relu, tanh, logistic |
| learningrate | initial, constant, adaptive |
| maxiter | Maximum training iterations |
| earlystopping | Stop when validation stops improving |
Cross-Validation
Cross-validation splits your data into folds, trains on some folds, and evaluates on the rest. This gives a more reliable estimate of performance than a single train/test split.
How It Works
- Data is split into K folds (e.g., 5 or 10).
- For each fold: train on K-1 folds, validate on 1 fold.
- Average the validation scores across all folds.
- The final model may be retrained on all data.
| K | Use Case |
|---|---|
| 5 | Default; good balance |
| 10 | More reliable; slower |
| 3 | Quick check; less reliable |
Feature Selection
Feature selection reduces the number of input columns. Benefits: faster training, less overfitting, simpler models.
Methods
| Method | How It Works |
|---|---|
| Variance threshold | Drops columns with very low variance |
| Correlation | Drops highly correlated features |
| Univariate | Keeps features with highest individual impact |
| Model-based | Uses feature importance from a model (e.g., Random Forest) |
| Recursive elimination | Iteratively removes least important features |
Class Balancing (SMOTE and Undersampling)
When one class is much rarer than another (e.g., fraud: 1%, normal: 99%), models tend to ignore the rare class. Class balancing helps.
SMOTE (Synthetic Minority Over-sampling)
What it does: Creates synthetic examples of the minority class by interpolating between existing minority samples.
When to use: When you have enough minority samples to interpolate (e.g., hundreds, not tens).
| Parameter | What It Does |
|---|---|
| kneighbors | Number of neighbors for interpolation |
| samplingstrategy | Target ratio (e.g., 0.5 = 50% minority) |
Undersampling
What it does: Randomly removes rows from the majority class to match the minority.
When to use: When you have plenty of majority samples; be aware you discard data.
| Method | Description |
|---|---|
| Random | Drop random majority rows |
| Tomek links | Remove borderline majority samples |
| Cluster centroids | Replace majority with cluster centroids |
When to Use Balancing
| Situation | Approach |
|---|---|
| Mild imbalance (e.g., 70/30) | Often no change needed |
| Strong imbalance (e.g., 95/5) | SMOTE or undersampling |
| Very rare class (e.g., 99/1) | SMOTE + undersampling, or collect more data |
Training Options
| Option | What It Does |
|---|---|
| Random seed | Makes results reproducible |
| Train/validation split | Ratio (e.g., 80/20) or use cross-validation |
| Early stopping | Stop when validation score stops improving |
| Max iterations | Limit training time |
| Verbosity | Log level (quiet, normal, verbose) |
Quick Reference
| Task | Where to Look |
|---|---|
| Tune tree depth | maxdepth |
| Prevent overfitting | maxdepth, minsamples_leaf, subsample |
| Handle class imbalance | SMOTE, undersampling |
| Get stable performance estimate | Cross-validation |
| Reduce features | Feature selection |
| Reproduce results | Random seed |
Related Articles
ML Algorithms: All 15+ Explained in Plain English
Plain-English explanations of Linear/Ridge/Lasso/Elastic Net, Logistic Regression, Decision Tree, Random Forest, XGBoost, LightGBM, SVM, KNN, Naive Bayes, Neural Network, AdaBoost, Extra Trees—with pros, cons, and a comparison table.
Machine Learning Overview: Workflow and Getting Started
A beginner-friendly recap of ML, classification vs regression vs clustering, the ML workflow (select, configure, train, evaluate, predict), and a 5-minute quick-start guide.
Was this helpful?