你好
我正在嘗試使用JSL代碼從XGBoost報告中提取一些統計信息(而不是右鍵單擊>製成數據表)。我使用其他平台(例如增強樹和引導森林)進行此操作時沒有任何問題,但是由於某些原因,我很難使它在XGBoost中工作。
在其他平台上,我基本上在運行的表中有一個腳本,該腳本使用調優表,但每次都適合一個腳本,並在運行時提取統計信息。但是修改與XGBoost一起使用的類似方法不起作用。XGBoost報告中是否有某些東西可以防止這種情況發生?
例如,對於引導森林建模,我可以執行以下操作:
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.
);如果要在不佔用太多RAM的情況下運行MANY引導林運行,則上述方法非常有效。您可以從“總體統計”概述框中輕鬆記錄RSquare,RASE,N等。
當我運行類似的腳本(如下)時,它將在以下位置引發錯誤:report [“ Outline Box”] [Number Col Box(1)] <<獲取行。
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.
); 我正在嘗試獲取“比較” [Table Box(1)]中出現的每種擬合的統計信息,例如Train Rquare等,但是對Number Col Box的引用似乎不起作用-它()1、2、3、4等中的值無關緊要 他們都拋出相同的錯誤。每次擬合後,我想保存RSqaure,Corr和RMSE值以進行培訓和驗證。 即使我在“模型1”輪廓框下嘗試它,也要在子級“ Actual by Predicted”下嘗試,並尋找Number Col Box()-例如(12或13)作為訓練結果和驗證結果,然後嘗試提取那裡的值,我仍然會在日誌文件中引發錯誤。
我得到的錯誤是:
對象無法訪問或評估'report [“ Compare”] [Number Col Box(1)]',report [“ Compare”] [/ * ### * / Number Col Box(1)]
在以下腳本中,錯誤標記為/ * ### * /
Stat_1 = report [“ Compare”] [/ * ### * / Number Col Box(1)] <<獲取
我知道我沒有遺漏任何括號或“膠水”;在腳本中。
我不明白為什麼我可以從其他報表中提取值,但似乎無法使用XGBoost報表來做到這一點。JSL代碼中缺少什麼嗎?
我想從“模型1”輪廓框中獲取數字會更好,因為“比較”輪廓框並不總是顯示Corr和RMSE值-除非您使用熱鍵進行修改。
對此有任何想法/建議,不勝感激。
提前致謝,
DS
你好 @DS ,XGBoost輸出對象及其報告尚不能直接編寫腳本。 我認為您當前可以提取輸出編號的唯一方法是直接引用輸出窗口,例如,分配w = window(“ ”),其中<title>是JMP分配給XGBoost輸出的窗口的名稱。 然後,您可以通過將w當作報告來訪問顯示樹中的任何內容。 要顯示完整的顯示樹,請右鍵單擊頂部的XGBoost展示三角形>編輯>顯示樹結構。