ScalerByLeo is a library for preprocessing data for ML models using scalers such as maxmin, robust, standard scaler, and also OpenCL can be used for bulk data scaling.
  • MQL5 93.8%
  • C 6.2%
Datei suchen
Repository-Dateien (neuester Commit zuerst)
Dateiname Letzte Commit-Nachricht Letztes Commit-Datum
Nique_372 745020c7cb
2026-10-09 13:48:41 -05:00
Images new files added 2026-03-01 21:35:16 -05:00
Src 2026-10-09 13:48:41 -05:00
Test nose quie poner 2026-09-16 19:38:47 -05:00
.gitattributes no se q 2026-09-16 10:18:03 -05:00
dependencies.json mejoras 2026-09-16 18:20:12 -05:00
LICENSE 2026-04-25 21:47:26 -05:00
README.md Actualizar README.md 2026-09-17 00:49:29 +00:00
ScalerByLeo.mqproj Generated by MQL5 Wizard 2025-09-09 14:08:27 -05:00

ScalerByLeo Logo

Build trading systems with automatic data scaling, 3 scaler families (CPU + GPU), and GPU support via OpenCL — all from MQL5.


Features

3 scaler families, CPU + GPU, float & double

// CPU (template<TFlt>, TFlt = float or double)
TSN::MaxMinScaler<TFlt>          scaler;
TSN::StandardizationScaler<TFlt> scaler;
TSN::RobustScaler<TFlt>          scaler;

// GPU via OpenCL (same interface, same TFlt)
TSN::MaxMinScalerCL<TFlt>          scalerGPU;
TSN::StandardizationScalerCL<TFlt> scalerGPU;
TSN::RobustScalerCL<TFlt>          scalerGPU;

Every scaler shares the same API: Fit, Transform, InverseTransform, FitTransform, plus Save / LoadByFile / LoadByArr to persist and reload a trained scaler. All CPU and GPU implementations are cross-checked to produce equivalent results.

Matrix scaling

void OnStart()
{
  matrixf mtx;
  mtx.Resize(16000, 16000);
  mtx.Random(0, 20.0);

  TSN::MaxMinScaler<float> scaler;
  matrixf out;
  scaler.FitTransform(mtx, out);
}

Custom column ranges & in-place reconstruction

Scale only a slice of your columns and choose whether the output keeps the full matrix shape (untouched columns preserved) or returns only the scaled slice:

TSN::MaxMinScaler<double> scaler;
scaler.SetRangeEscaler(2, 5);     // scale 5 columns starting at index 2
scaler.SetReconstruir(true);      // output keeps original shape/columns
scaler.FitTransform(mtx, out);

Error handling

Every operation returns bool and sets a descriptive error you can query instead of failing silently:

if(!scaler.FitTransform(mtx, out))
  Print("Scaler error: ", EnumToString(scaler.GetLastScalerError()));

GPU version via OpenCL (real benchmarks)

TSN::MaxMinScalerCL<float> scalerGPU;
scalerGPU.Fit(mtx);
scalerGPU.Transform(mtx, out);   // GPU

TSN::MaxMinScaler<float> scalerCPU;
scalerCPU.Fit(mtx);
scalerCPU.Transform(mtx, out);   // CPU
GPU = 1,268,040 us
CPU = 2,344,502 us

Benchmark on a 9,600 x 9,600 matrix using an Intel UHD Graphics 620 GPU. See Src/Scaler/Bench/README.md for the full set of internal benchmarks (pattern selection for min/max, mean, matrix copy strategy, robust scaling, and the OpenCL upload strategy) that drove the current implementation's performance choices. Used GPU: device #0: GPU 'Intel UHD Graphics 620' with OpenCL 3.0 (24 units, 1100 MHz, 3240 Mb, version 30.0.100.9670, rating 836)


Quick Start

1. Install repository

See Instalation section.

2. Include the scaler in your script

void OnStart()
{
  matrixf data;
  data.Resize(100, 10);
  data.Random(0, 100.0);

  TSN::MaxMinScaler<float> scaler;
  matrixf out;
  scaler.FitTransform(data, out);

  Print("Scaling complete. Sample value: ", out[0][0]);
}

3. Verify the installation

Run any script from the Test/ folder in the MetaTrader 5 Editor. If no errors appear in the log, you're all set.


Repository Structure

ScalerByLeo/
├── Src/
│   ├── Scaler/
│   │   ├── MinMax/   # MaxMinScaler (CPU) + MaxMinScalerCL (GPU)
│   │   ├── Std/      # StandardizationScaler (CPU) + StandardizationScalerCL (GPU)
│   │   ├── RScaler/  # RobustScaler (CPU) + RobustScalerCL (GPU)
│   │   ├── Bench/    # Internal micro-benchmarks used to pick the fastest patterns
│   │   ├── AllImp.mqh  # Single include for all CPU scalers
│   │   └── AllCL.mqh   # Single include for all GPU scalers
│   ├── CL/       # OpenCL context/kernel manager
│   └── Kernels/  # OpenCL kernel sources
├── Test/       # Equality tests and benchmarks (CPU vs GPU)
└── Images/     # Repository banner

License

Read Full License

By downloading or using this repository, you accept the license terms.


Requirements

See the dependencies.json file.


Installation of repo code

cd "C:\Users\YOUR USER\AppData\Roaming\MetaQuotes\Terminal\YOUR ID\MQL5\Shared Projects"
tsndep install "https://forge.mql5.io/nique_372/MQLArticles.git"
  • Using the tsndep command requires the tsndep package (available on PyPI). This command automatically downloads all dependencies and installs every requirement from the repositories.
  • If any part of the system is private, the install will fail. Contact me so I can grant you access (if it's a product, you can purchase it; if you have any questions, don't hesitate to reach out). Check the dependencies.json file for more info.

Contact


Copyright © 2026 Nique-Leo.