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-04-11 07:16:03 -05:00
//void OnTrainingNewResult(CJson* json) override final;
2026-03-21 08:06:31 -05:00
//---
2026-04-11 07:16:03 -05:00
__forceinline uint8_t EventsFlags ( ) const override final { return 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 ( )
{
CleanItems ( true ) ;
}
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-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-04-11 07:16:03 -05:00
if ( InRange ( row , FUNCION_ACTUAL ) )
2026-03-20 21:41:01 -05:00
{
//---
m_text_box . ClearTextBox ( ) ;
//---
2026-04-11 07:16:03 -05:00
CJsonIterator it = items [ row ] [ " metrics " ] . begin ( ) ;
2026-03-20 21:41:01 -05:00
while ( it . IsValid ( ) )
{
//---
const string key = it . Key ( ) ;
CJsonNode val = it . Val ( ) ;
//---
2026-03-26 10:26:25 -05:00
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 ;
}
2026-03-20 21:41:01 -05:00
//---
2026-03-26 10:26:25 -05:00
if ( display ! = NULL )
m_text_box . AddLine ( key + " : " + display ) ;
2026-03-20 21:41:01 -05:00
//---
it . Next ( ) ;
}
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