- Quiete el hash map dado que no sera necesario ahora el acceso es por indice - Correcion de visualizacion en los botones
170 lines
6 KiB
MQL5
170 lines
6 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| 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;
|
|
void Show(const int row) override final;
|
|
void OnLenguajeChange() override final {} // Nada no necesitamos
|
|
|
|
//---
|
|
void OnTrainingInit() override final;
|
|
//void OnTrainingNewResult(CJson* json) override final;
|
|
|
|
//---
|
|
__forceinline uint8_t EventsFlags() const override final { return TRAINING_RUNNER_PY_FLAG_ON_TRAINIG; }
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
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;
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
void CTrainingPyVisualizer::OnTrainingInit()
|
|
{
|
|
CleanItems(true);
|
|
}
|
|
|
|
/*
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
void CTrainingPyVisualizer::OnTrainingNewResult(CJson *json)
|
|
{
|
|
AddItemFast(json); // Añadifmos a fastr (aqui habra hock)
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
|
|
// type = clasificacion
|
|
self.m_metrics = {
|
|
'accuracy': accuracy,
|
|
'precision': precision,
|
|
'recall': recall,
|
|
'f1_score': f1
|
|
}
|
|
|
|
// type = regresion
|
|
*/
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
// {"metrics": {"accuracy": 0.5714285714285714, "precision": 0.45454545454545453, "recall": 0.45454545454545453, "f1_score": 0.45454545454545453},
|
|
// "type": "Clasification", "path": "C:\\Users\\leoxd\\AppData\\Roaming\\MetaQuotes\\Terminal\\Common\\Files\\EasySbAi\\XAUUSD\\M5\\label_0"}
|
|
void CTrainingPyVisualizer::Show(const int row)
|
|
{
|
|
if(InRange(row, FUNCION_ACTUAL))
|
|
{
|
|
//---
|
|
m_text_box.ClearTextBox();
|
|
|
|
//---
|
|
CJsonIterator it = items[row]["metrics"].begin();
|
|
while(it.IsValid())
|
|
{
|
|
//---
|
|
const string key = it.Key();
|
|
CJsonNode val = it.Val();
|
|
|
|
//---
|
|
string display = NULL;
|
|
switch(val.ctx.GetType(val.idx))
|
|
{
|
|
case J_BOOL:
|
|
display = val.ToBool(false) ? "true" : "false";
|
|
break;
|
|
case J_INT:
|
|
display = string(val.ToInt());
|
|
break;
|
|
case J_DBL:
|
|
display = DoubleToString(val.ToDouble(), 4);
|
|
break;
|
|
case J_STR:
|
|
display = val.ToString();
|
|
break;
|
|
}
|
|
|
|
//---
|
|
if(display != NULL)
|
|
m_text_box.AddLine(key + ": " + display);
|
|
|
|
//---
|
|
it.Next();
|
|
}
|
|
|
|
//---
|
|
m_text_box.Update(true);
|
|
}
|
|
}
|
|
|
|
#endif // AIDATATASKRUNER_UI_TRAINING_RESVISUALIZER_MQH
|