Pre processing library - MegaJoctan/MALE5 GitHub Wiki
Preprocessing.mqh: MQL5 Normalization Techniques
This MQL5 library, preprocessing.mqh, provides three essential normalization techniques for machine learning:
- RobustScaler
- MinMaxScaler
- StandardizationScaler
- CLabelEncoder (for label encoding)
These functions help prepare your data for machine learning algorithms by scaling or encoding features to a common range or representation. This step is crucial for improving the performance and stability of many machine learning models.
Key Functionalities:
Scalers:
- RobustScaler:
- Uses the median and interquartile range (IQR) for scaling.
- Less prone to outliers compared to other scalers.
- MinMaxScaler:
- Scales features to a range between
0and1. - Useful for algorithms sensitive to feature scales.
- Scales features to a range between
- StandardizationScaler:
- Standardizes features by subtracting the mean and dividing by the standard deviation.
- Leads to features with zero mean and unit variance.
Label Encoder:
- CLabelEncoder:
- Encodes categorical string labels into numerical labels.
- Useful for converting categorical features into numerical representations usable by machine learning models.
Usage:
Each scaler class provides:
fit_transform(const matrix &X): Fits the scaler on the data matrixXand performs the transformation.transform(const matrix &X): Transforms the data matrixXusing the fitted scaler.transform(const vector &X): Transforms the data vectorXusing the fitted scaler.
The CLabelEncoder class offers:
encode(string &Arr[]): Encodes a string array into a numerical vector.
Saving and Loading Models (Scalers):
- Each scaler class supports saving and loading models:
save(string save_dir): Saves the scaler model to a given directory/folder.load(string dir): Loads a previously saved scaler model from a given folder.
Additional Notes:
- Remember to include this library file (
#include "preprocessing.mqh") in your MQL5 code where you want to use its functionalities.