你好
我正在尝试使用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展示三角形>编辑>显示树结构。