What to do first Feature Selection or Model `Parameters` Setting?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
In the realm of machine learning, building an effective model isn't just about collecting a dataset and running it through an algorithm. It involves a series of carefully considered steps that optimize the predictive capability of the model. Two critical, often debated steps in this process are feature selection and model parameter setting, or hyperparameter tuning. The question often arises: which one should be prioritized?
Feature Selection
Feature selection is the process of identifying and using only the most significant features from your dataset for building your machine learning model. The intent is to reduce dimensionality, remove redundant data, and improve model generalization.
Why Feature Selection?
- Reduces Overfitting: Too many features might cause your model to fit to noise rather than the underlying data pattern.
- Improves Accuracy: Less irrelevant data leads to models that are more accurate.
- Enhances Interpretability: Models are easier to understand with fewer features.
- Reduces Training Time: Training a model with fewer features is computationally less expensive.
Techniques for Feature Selection
- Filter Methods: Use statistical measures to score the features. Examples include Pearson's correlation, Chi-square test, and mutual information.
- Wrapper Methods: Use a subset of features to train the model iteratively and determine the performance. Techniques include Recursive Feature Elimination (RFE) and Forward/Backward Selection.
- Embedded Methods: Feature selection occurs during model training. Examples include LASSO and Ridge regression.
Model Parameters
Setting
Model parameter setting, often referred to as hyperparameter tuning, involves finding the best set of parameters that define the structure of the model. Unlike model parameters that are learned during training, hyperparameters control the learning process.
Why Model Parameters
Setting?
- Optimizes Model Performance: Proper tuning can drastically affect model performance, potentially leading from poor to excellent predictions.
- Improves Model Stability: A well-tuned model adapts better to different data distributions.
- Balancing Bias and Variance: Finding the right set of hyperparameters helps balance overfitting and underfitting.
Techniques for Hyperparameter Tuning
- Grid Search: Exhaustively tries every combination of hyperparameter values specified in search space.
- Random Search: Samples a random combination of hyperparameters. More efficient than grid search.
- Bayesian Optimization: Uses past evaluations to form a probabilistic model of the objective function.
Which Comes First?
The debate on whether feature selection should precede hyperparameter tuning or vice versa is largely situational and depends on several factors, such as:
- Dataset Size: Large datasets might benefit more initially from feature selection to reduce dimensionality.
- Model Complexity: Complex models with a high capacity require careful tuning, which might mean hyperparameter tuning takes precedence.
- Domain Knowledge: Availability of domain-specific insights can guide effective feature selection upfront.
Combined Approach
Sometimes, an iterative approach where feature selection and hyperparameter tuning are alternated can offer more refined results. For example, one might start with basic feature selection to eliminate clearly irrelevant features, perform preliminary hyperparameter tuning, reassess and refine feature selection, and then finalize hyperparameter tuning.
Summary
The decision of what to do first—feature selection or model parameters setting—depends on various factors, including dataset nature, model complexity, and computational resources. A strategic and sometimes adaptive approach can be most effective.
| Decision Factor | Feature Selection | Model Parameters Setting |
| Key Objective | Reduce dimensionality | Optimize model performance |
| Early-Step Consideration | When dataset is large or high-dimensional | For models requiring fine-tuning of hyperparameters |
| Ease of Interpretability | High | Neutral |
| Computational Cost | Cost reduced through simpler models | Relatively high due to exploration of parameter space |
| Impact on Overfitting | Reduces through feature reduction | Balances bias-variance trade-off |
In practice, many machine learning practitioners iterate between feature selection and hyperparameter tuning, leveraging both processes to refine their models progressively. Understanding the specific needs and constraints of your project will guide the optimal order and methodology.
Related reading
- What to do when Seq2Seq network repeats words over and over in output?
- What to do when Seq2Seq network repeats words over and over in output?
- What type of algorithm should i use?
- What type of neural network can handle variable input and output sizes?
- What type of orthogonal polynomials does R use?
- What values are valid in Pandas 'Freq' tags?
- What type of heap is used and time complexity of stdpriority_queue in c?
- What would be the fastest method to test for primality in Java?

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.