MegaJoctan / MALE5

Machine Learning repository for MQL5
https://omegafx.co
MIT License
126 stars 33 forks source link

How to use class Regressor Nets.mqh #4

Closed phamthanhlam closed 7 months ago

phamthanhlam commented 7 months ago

Hi MegaJoctan! Can you please give an example of how to use Regressor Nets.mqh?

MegaJoctan commented 7 months ago
#include <MALE5\preprocessing.mqh>
#include <MALE5\Linear Models\Linear Regression.mqh>

CLinearRegression lr; //Load the linear regression mode
MinMaxScaler scaler; //Data scalling technique

void some_function()
  {
//---

   int handle = iRSI(Symbol(), PERIOD_CURRENT, 12, PRICE_OPEN);

   matrix x;
   vector y;

   // Add your trainng data to the x and y matrix and vector respectively
   // .....

   x = scaler.fit_transform(x); //Normalize x variable(s)   | important for all machine learning models 
   lr.fit_LeastSquare(x, y); //Train the linear regression model by least squre method

   vector new_data;

   double predicted_value = lr.predict(new_data); //obtain the signal
}