Ciao,
Sto cercando di estrarre alcune delle statistiche dal report XGBoost utilizzando il codice JSL (anziché fare clic con il pulsante destro del mouse> trasforma in tabella dati). Lo faccio con alcune delle altre piattaforme (ad esempio albero potenziato e foresta di bootstrap) senza problemi, ma per qualche motivo ho difficoltà a farlo funzionare in XGBoost.
Nelle altre piattaforme, ho fondamentalmente uno script nella tabella che eseguo che utilizza una tabella di ottimizzazione, ma le adatta una alla volta ed estrae le statistiche man mano che procede. Ma modificare un approccio simile per lavorare con XGBoost non funziona. C'è qualcosa nel rapporto XGBoost che lo impedirebbe?
Ad esempio, per la modellazione della foresta bootstrap, posso fare qualcosa di simile a quanto segue:
Names Default To Here( 1 );
dt = Data Table( " " ); //this would be your data table used to train the model
dt_pars = Data Table( " " ); //this would be your tuning table with the parameters in it.
dt_results = dt_pars << Subset( All rows, Selected columns only( 0 ) ); //this basically duplicates the previous table for writing stats values
dt_results << New Column("Stat 1"); //for recording whichever stat you're interested in, e.g. Training R^2
dt_results << New Column("Stat 2"); //for recording whichever stat you're interested in, e.g. Validation R^2
//and so on with however many stats you want to get.
//This For Loop will run each row of the tuning table iteratively. This is really helpful for platforms that use a lot of RAM.
For( i = 1, i <= N Row( dt_pars ), i++,
NumTrees = dt_pars:Number Trees[i];
NumTerms = dt_pars:Number Terms[i];
PortBoot = dt_pars:Portion Bootstrap[i];
MinSplpTr = dt_pars:Minimum Splits per Tree[i];
MaxSplpTr = dt_pars:Maximum Splits per Tree[i];
MinSplSz = dt_pars:Minimum Size Split[i];
str = Eval Insert(
"report = (dt << Bootstrap Forest(
Y( :Y1 ), //whatever your response column is
X( :X1, :X2, :X3), //this is the list of all the x-factors
Minimum Size Split( ^MinSplSz^ ),
Validation Portion( 0.2 ),
Set Random Seed( ),
Method( \!"Bootstrap Forest\!" ),
Minimum Splits per Tree( ^MinSplpTr^ ),
Maximum Splits per Tree( ^MaxSplpTr^ ),
Portion Bootstrap( ^PortBoot^ ),
Number Terms( ^NumTerms^ ),
Number Trees( ^NumTrees^ ),
Early Stopping( 0 ),
Go,
invisible
)) << Report;"
);
Eval( Parse( str ) );
Stat_1 = report["Overall Statistics"][Number Col Box( 1 )] << Get; <U><STRONG>//this is where it doesn't work for the XGBoost report</STRONG></U>
//and so on for any other stats of interest
report << Close Window;
dt_results:Name("Stat 1")[i]=Stat_1[1];//saves the first in the list of Stat_1
dt_results:Name("Stat 2")[i]=Stat_1[2];//saves the second in the list of Stat_1
//continue on until you've recorded all the stats of interest in the dt_results data table.
);Il metodo sopra funziona molto bene se si desidera eseguire MOLTE esecuzioni di foreste di bootstrap senza consumare troppa RAM. È possibile registrare facilmente RSquare, RASE, N e così via dalla casella "Statistiche generali".
Quando eseguo uno script simile (sotto), viene visualizzato un errore in: report ["Outline Box"] [Number Col Box (1)] << Ottieni riga.
Names Default To Here( 1 );
dt = Data Table( " " ); //training data table
dt_pars = Data Table( " " ); //tuning parameter table
dt_results = dt_pars << Subset( All rows, Selected columns only( 0 ) ); //makes duplicate for writing output values to
//creates columns for the statistics to save in the results data table.
dt_results << New Column( "Stat1" );
dt_results << New Column( "Stat2" );
dt_results << New Column( "Stat3" );
dt_results << New Column( "Stat4" );
dt_results << New Column( "Stat5" );
dt_results << New Column( "Stat6 );
//this is the For Loop to run each row in the dt_pars tuning table one at a time.
For( i = 1, i <= N Row( dt_pars ), i++,
maxd = dt_pars:max_depth[i];
subsam = dt_pars:subsample[i];
colsambytree = dt_pars:colsample_bytree[i];
minchweight = dt_pars:min_child_weight[i];
al = dt_pars:alpha[i];
lam = dt_pars:lambda[i];
learnr = dt_pars:learning_rate[i];
iter = dt_pars:iterations[i];
str = Eval Insert(
"report = (dt << XGBoost(
Y( :Y1 ), //Response column
X( :X1, :X2, :X3, :X4),
Validation( :Validation), //validation column of choice
Fit(
max_depth( ^maxd^ ),
subsample( ^subsam^ ),
colsample_bytree( ^colsambytree^ ),
min_child_weight( ^minchweight^ ),
alpha( ^al^ ),
lambda( ^lam^ ),
learning_rate( ^learnr^ ),
iterations( ^iter^ )
),
SendToReport(
Dispatch( {}, \!"Launch\!", OutlineBox, {Close( 1 )} ),
Dispatch(
{\!"Launch\!", \!"Advanced Options\!"},
\!"\!",
TextEditBox,
{Fixed Size( 1, 72, 19 )}
),
Dispatch(
{\!"Launch\!", \!"Advanced Options\!"},
\!"\!",
Text Edit Box( 2 ),
{Fixed Size( 1, 72, 19 )}
),
Dispatch(
{\!"Launch\!", \!"Advanced Options\!"},
\!"\!",
Text Edit Box( 3 ),
{Fixed Size( 1, 72, 19 )}
),
Dispatch( {\!"Launch\!"}, \!"\!", PictureBox, {Set Summary Behavior( \!"Collapse\!" )} ),
Dispatch( {}, \!"Model 1\!", OutlineBox, {Close( 1 )} ),
Go,
invisible
)) << Report;"
);
Eval( Parse( str ) );
Stat_1= report["Compare"][Number Col Box(1)] << Get;
//and so on for the other stats to be saved
report << Close Window;
dt_results:Name( "Stat1" )[i] = Stat_1;//saves the value to the data table dt_results
//and so on for the other stats to record in the results data table.
); Sto cercando di ottenere le statistiche per ogni adattamento che viene visualizzato nel "Compare" [Table Box (1)], come Train RSquare e così via, ma il riferimento al Number Col Box sembra non funzionare - esso non importa quale sia il valore in () 1, 2, 3, 4, ecc. lanciano tutti lo stesso errore. Vorrei salvare i valori RSqaure, Corr e RMSE per l'addestramento e la convalida dopo ogni adattamento. Anche se lo provo sotto la casella "Modello 1", figlio "Attuale per previsto" e cerco la casella Col numero () - ad es. (12 o 13) - per i risultati dell'addestramento e della convalida, e prova per estrarre i valori lì, ottengo ancora un errore che viene generato nel file di registro.
L'errore che ottengo è:
oggetto non abbonabile nell'accesso o nella valutazione di "report [" Confronta "] [Number Col Box (1)]", report ["Compare"] [/ * ### * / Number Col Box (1)]
Nello script seguente, errore contrassegnato da / * ### * /
Stat_1 = report ["Compare"] [/ * ### * / Number Col Box (1)] << Get
So di non perdere nessuna parentesi o "colla"; nello script.
Non capisco perché posso estrarre valori da altri rapporti, ma non riesco a farlo con il rapporto XGBoost. C'è qualcosa che mi manca nel codice JSL?
Penso che ottenere i numeri dal riquadro "Modello 1" sarà migliore perché il riquadro "Confronta" non sempre mostra i valori Corr e RMSE, a meno che non li modifichi con il pulsante di scelta rapida ..
Eventuali pensieri / suggerimenti su questo sono molto apprezzati.
Grazie in anticipo,
DS