Multiple Dynamic Logistic Regression First Failed Attempt - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources
For anyone who does not understand the code provided in this library, please read the article linked here https://www.mql5.com/en/articles/10626
The biggest challenge I faced while building both linear and logistic regression libraries in both articles were multiple dynamic regression functions that we could use for multiple columns of data without having to hardcode each data added to the model. In the previous article I hardcoded two functions with the same name. The only difference between them was the amount of data each model could handle. One was able to handle two independent variables and the other was able to handle four independent variables.
Blank multiple regression main( double &prediction_y[], double &Y[], double &A[], double &B[]); blank multiple regression main( double &prediction_y[], double & Y[], double &A[], double &B[], double &C[], double &D[]);
However, this approach is inconvenient, feels like an immature way of coding, and violates the rules of clean code and DRY (not repeating the principles OOP is trying to help us achieve)
Unlike Python which has flexible functions and can get a large number of function parameters with the help of *args and **kwargs, in MQL5 this can only be achieved using strings as far as I know, I believe this is our starting point
void CMultipleLogisticRegression::MLRInit( string x_column = "3,4,5,6,7,8" )
The input x_columns represents all the independent columns we will use in the library, these columns will require us to have multiple independent arrays for each column, however, we cannot create arrays dynamically, so the use of arrays will fail here
We can create multiple CSV files dynamically and use them as arrays, that's for sure, but this will make our program more expensive in using computer resources compared to using arrays, especially when dealing with multiple data, not to mention the while loops we often use to open files will slow down the whole process, I'm not 100% sure, so please correct me if I'm wrong
Thought we could still use the way mentioned,
I found a way to use arrays, we will store all the data for all columns in an array and then use the data in that array individually
integer start = 0 ; if (m_debug) //If we are in debug mode, print each array and its behavior ( integer i = 0 ; iArray copy(EachXDataArray,m_AllDataArray, 0 , start, total number of rows); start+=total number of rows; print ( "array number="" ,i, "starting from column number" ,m_XColsArray[i]); Array printing (EachXDataArray); }
In a for loop we can manipulate the data in the array and perform all the calculations of the model in the required way for all columns, I have tried this approach but I am still trying unsuccessfully, the reason why I am explaining this hypothesis is to make everyone reading this article aware of this challenge, I welcome all your opinions in the comments section on how to write this multiple dynamic logistic regression function
This is just a hypothesis intended to enlighten you on the process of coding a multivariate dynamic regression algorithm, as described in the data science and machine learning article series linked above
Attachment download
📎 multipledynamiclogisticregression.mqh (12.75 KB)
📎 testscript.mq5 (1.29 KB)
Source: MQL5 #38894
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •