2026-07-27 09:45:06 -05:00 | | | //+------------------------------------------------------------------+
|
2026-03-20 21:41:01 -05:00 | | | //| ResVisualizer.mqh |
|
| | | //| Copyright 2025, Niquel Mendoza. |
|
| | | //| https://www.mql5.com/es/users/nique_372 |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2025, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com/es/users/nique_372"
|
| | | #property strict
|
| | |
|
| | | #ifndef AIDATATASKRUNER_UI_TRAINING_RESVISUALIZER_MQH
|
| | | #define AIDATATASKRUNER_UI_TRAINING_RESVISUALIZER_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Include |
|
| | | //+------------------------------------------------------------------+
|
| | | #include "ResultsTab.mqh"
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Defines \ Enums \ Struct |
|
| | | //+------------------------------------------------------------------+
|
| | | // Valor key para el hashmap
|
| | | #define AIDATATASKRUNER_TRAINIG_PY_KEY(A) (A["path"].ToString()+A["type"].ToString())
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class CTrainingPyVisualizer : public CTrainingResultsAlmacenador
|
| | | {
|
| | | private:
|
| | | //---
|
| | | CTextBox m_text_box;
|
| | |
|
| | | public:
|
| | | CTrainingPyVisualizer(void) {}
|
| | | ~CTrainingPyVisualizer(void) {}
|
| | |
|
| | | //---
|
| | | bool Set(int top_gap, int left_gap, int right_gap, int bottom_gap, CWindow* win, CWndCreate* wnd_create) override final;
|
2026-04-11 07:16:03 -05:00 | | | void Show(const int row) override final;
|
2026-03-21 08:06:31 -05:00 | | | void OnLenguajeChange() override final {} // Nada no necesitamos
|
| | |
|
| | | //---
|
| | | void OnTrainingInit() override final;
|
2026-06-03 22:07:50 -05:00 | | | void OnTrainingNewResult(TSN::CJsonNode& json) override final;
|
2026-03-21 08:06:31 -05:00 | | |
|
| | | //---
|
2026-06-03 22:07:50 -05:00 | | | __forceinline uint8_t EventsFlags() const override final { return TRAINING_RUNNER_PY_FLAG_ON_TRAINIG | TRAINING_RUNNER_PY_FLAG_ON_TRAINIG; }
|
2026-03-20 21:41:01 -05:00 | | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTrainingPyVisualizer::Set(int top_gap, int left_gap, int right_gap, int bottom_gap, CWindow *win, CWndCreate *wnd_create)
|
| | | {
|
| | | //--- TextBox
|
| | | m_text_box.MainPointer(win);
|
| | | m_text_box.FontSize(10);
|
| | | m_text_box.Font("Arial");
|
| | | m_text_box.MultiLineMode(true);
|
| | | m_text_box.WordWrapMode(false);
|
| | | m_text_box.ReadOnlyMode(true);
|
| | | m_text_box.AutoXResizeMode(true);
|
| | | m_text_box.AutoXResizeRightOffset(right_gap);
|
| | | m_text_box.AutoYResizeMode(true);
|
| | | m_text_box.AutoYResizeBottomOffset(bottom_gap);
|
| | | m_text_box.SelectedTextColor(C'61,142,240');
|
| | | m_text_box.SelectedBackColor(clrAquamarine);
|
| | | m_text_box.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
|
| | | m_text_box.BackColor(AIDATATASKRUNER_COLOR_FONDO_TAB_PRESSED);
|
| | | m_text_box.BackColorHover(AIDATATASKRUNER_COLOR_FONDO_TAB_PRESSED);
|
| | | m_text_box.BackColorPressed(AIDATATASKRUNER_COLOR_FONDO_TAB_PRESSED);
|
| | | m_base_tab.AddToElementsArray(m_base_tab_idx, m_text_box);
|
| | |
|
| | |
|
| | | //---
|
| | | if(!m_text_box.CreateTextBox(left_gap, top_gap))
|
| | | {
|
| | | GUIBASE_ERROR_CREATION(m_text_box);
|
| | | return false;
|
| | | }
|
| | |
|
| | | //---
|
| | | wnd_create.AddToElementsArray(0, m_text_box);
|
| | | return true;
|
| | | }
|
| | |
|
2026-03-21 08:06:31 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void CTrainingPyVisualizer::OnTrainingInit()
|
| | | {
|
2026-06-03 22:07:50 -05:00 | | | m_data_size = ArrayResize(m_data, 0, 0);
|
2026-03-21 08:06:31 -05:00 | | | }
|
| | |
|
2026-04-11 07:16:03 -05:00 | | | /*
|
2026-03-21 08:06:31 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void CTrainingPyVisualizer::OnTrainingNewResult(CJson *json)
|
| | | {
|
| | | AddItemFast(json); // Añadifmos a fastr (aqui habra hock)
|
| | | }
|
| | |
|
2026-03-20 21:41:01 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-04-11 07:16:03 -05:00 | | |
|
2026-03-20 21:41:01 -05:00 | | | // type = clasificacion
|
| | | self.m_metrics = {
|
| | | 'accuracy': accuracy,
|
| | | 'precision': precision,
|
| | | 'recall': recall,
|
| | | 'f1_score': f1
|
| | | }
|
| | |
|
| | | // type = regresion
|
| | | */
|
| | |
|
2026-06-03 22:07:50 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void CTrainingPyVisualizer::OnTrainingNewResult(TSN::CJsonNode &json)
|
| | | {
|
2026-07-07 19:11:54 -05:00 | | | const int idx = m_data_size;
|
| | | ArrayResize(m_data, ++m_data_size);
|
| | |
|
| | | //----
|
| | | const int size = json["metrics"].Size();
|
| | | ArrayResize(m_data[idx].lines, size);
|
| | | int n = 0;
|
| | |
|
| | | //----
|
2026-07-27 09:45:06 -05:00 | | | CJsonIteratorObj it = json["metrics"].BeginObj();
|
2026-07-07 19:11:54 -05:00 | | | while(it.IsValid())
|
| | | {
|
| | | const string key = it.Key();
|
| | | TSN::CJsonNode val = it.Val();
|
| | | const string display = val.ToString();
|
| | | if(display != NULL)
|
| | | {
|
| | | m_data[idx].lines[n++] = key + ": " + display;
|
| | | }
|
| | | it.Next();
|
| | | }
|
2026-06-03 22:07:50 -05:00 | | | }
|
| | |
|
2026-03-20 21:41:01 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-04-11 07:16:03 -05:00 | | | // {"metrics": {"accuracy": 0.5714285714285714, "precision": 0.45454545454545453, "recall": 0.45454545454545453, "f1_score": 0.45454545454545453},
|
2026-03-26 15:56:42 -05:00 | | | // "type": "Clasification", "path": "C:\\Users\\leoxd\\AppData\\Roaming\\MetaQuotes\\Terminal\\Common\\Files\\EasySbAi\\XAUUSD\\M5\\label_0"}
|
2026-04-11 07:16:03 -05:00 | | | void CTrainingPyVisualizer::Show(const int row)
|
2026-03-20 21:41:01 -05:00 | | | {
|
2026-06-03 22:07:50 -05:00 | | | if(row >= 0 && row < m_data_size)
|
2026-03-20 21:41:01 -05:00 | | | {
|
| | | m_text_box.ClearTextBox();
|
| | |
|
2026-07-07 19:11:54 -05:00 | | | const int n = ArraySize(m_data[row].lines);
|
| | | for(int i = 0; i < n; i++)
|
| | | m_text_box.AddLine(m_data[row].lines[i]);
|
2026-03-21 08:06:31 -05:00 | | |
|
| | | m_text_box.Update(true);
|
2026-03-20 21:41:01 -05:00 | | | }
|
| | | }
|
| | |
|
| | | #endif // AIDATATASKRUNER_UI_TRAINING_RESVISUALIZER_MQH
|