Exporting Scikit-Learn Regression Models to ONNX at Different Precisions
Summary
This technical article examines how Scikit-learn regression models can be exported to ONNX and executed from MQL5, with a focus on differences between single- and double-precision calculations. It explains that some ONNX machine-learning operators accept several input types but return float output, potentially reducing fidelity when a source model uses double precision. The article describes comparing converted outputs with original models and inspecting model representations.
Across 45 regression models from Scikit-learn 1.3.2, the reported conversion results were 40 models for float and 30 for double; five were not converted. The article says some linear models avoid operator limitations by being represented with basic matrix operations, while SVM and tree ensemble operator constraints leave several model families available only in float. These findings concern portability and numerical accuracy, not trading performance. Results depend on the cited software versions and converter behavior, and successful export alone does not establish that a regression model predicts markets effectively.
Key ideas
- ONNX operator output types can limit precision even when inputs or source model parameters use double precision.
- The article compares exported model predictions with their Scikit-learn counterparts and inspects ONNX graphs.
- It reports float conversion for 40 of 45 models and double conversion for 30.
- Some models can use basic matrix operators to preserve double calculations, while certain SVM and tree models remain float-only.
- Export compatibility and numerical fidelity do not demonstrate predictive value in trading.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.