- Published on
Hyper-Parameter Tuning with Cross-Validation
- Authors
- Name
- Tails Azimuth
Table of Contents
Hyper-Parameter Tuning with Cross-Validation
Importance of Hyper-Parameter Tuning
Hyperparameter tuning is crucial for optimizing machine learning (ML) algorithms. Effective tuning results in improved real-world performance. Cross-validation (CV) plays a vital role in this, especially in the finance sector, where conventional approaches often fall short. This blog focuses on utilizing the Purged k-fold CV method for hyper-parameter optimization.
Purged-Kfold Integration into MLJBase
For hyperparameter tuning, grid search is often an initial step to understand the data's underlying structure. In MLJBase, GridSearchcV
uses a CV generator, and to avoid overfitting, our PurgedKFold class can be passed as an argument.
Python | Julia |
---|---|
|
|
Non-Negative Parameters
Non-negative hyperparameters are common in some ML algorithms, such as the SVC classifier and RBF kernel. Rather than using a uniform distribution for sampling, using a log-uniform distribution is often more effective for such parameters.
For a variable to have a log-uniform distribution between and , its CDF and PDF can be defined as:
Limitations of Accuracy as a Measure
Accuracy alone doesn't provide a meaningful evaluation in finance-related ML, particularly in investment strategies. It fails to account for the probabilities associated with predictions. Cross-entropy loss, or , is a better performance metric as it incorporates prediction probabilities.
The formula for log loss is:
Accuracy doesn't suffice for hyperparameter tuning in financial applications. It should ideally be supplemented or replaced with metrics that better capture the complexities of financial decision-making.
Note: All these functionalities are available in both Python and Julia in the RiskLabAI library. You can view more here for Python and here for Julia.
References
- De Prado, M. L. (2018). Advances in financial machine learning. John Wiley & Sons.
- De Prado, M. M. L. (2020). Machine learning for asset managers. Cambridge University Press.