JMP > JSL > 다중 호출 모델에 대한 스크립트 가속(N > 2000)?안녕하세요 JMP 커뮤니티입니다.
내 데이터 세트의 크기가 커지고 있고 얼마 전에 만든 기본 스크립트(아래 참조)가 속도 관점에서 따라가지 못하고 있습니다.
더 나은 속도를 위해 이러한 유형의 스크립트를 최적화하는 방법에 대한 아이디어를 듣고 싶습니다. 예를 들어 "연결"과 같은 작업은 상대적으로 느리고 이러한 유형의 작업에 대해 행렬로 작업하는 것이 합리적일 수 있습니다.
Names Default to Here (1);
dt = Current Data Table ();
CList = dt << Get Column Names (string);
dtoutl = New Table ("LSM OUTPUT", "invisible");
dtoutp = New Table ("PVal OUTPUT", "invisible");
For (i = 1, i<= 2000, i++,
fm = dt << Fit Model(
Y( Column (i) ),
Effects( :VISIT, :TREATMENT, :VISIT * :TREATMENT, Column (i+2000) ),
Personality( "Standard Least Squares" ),
Emphasis( "Minimal Report" ),
Run(
Column (i) << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
Parameter Estimates( 1 ), Scaled Estimates( 0 ),
Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
Plot Residual by Predicted( 0 ), Plot Studentized Residuals( 0 ),
Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
Box Cox Y Transformation( 0 ), {:VISIT * :TRT01A <<
{LSMeans Contrast( [0 0 1 -1 0 0, 0 0 0 0 1 -1] )}}}
)
);
fmr = report (fm);
table_list = fmr << xpath ("//OutlineBox [text() = 'VISIT*TREATMENT']//TableBox");
temp_lsm = table_list [1];
temp_pval = table_list [2];
temp_tbl_lsm = temp_lsm << Make into Data Table (invisible (1));
temp_tbl_pval = temp_pval << Make into Data Table (invisible (1));
temp_tbl_lsm << New column ("ID", character, nominal, << set each value (CList [i]));
temp_tbl_pval << New column ("ID", character, nominal, << set each value (CList [i]));
fmr << close window;
dtoutl << Concatenate (Data table (temp_tbl_lsm), "Append to First Table");
Wait (0);
dtoutp << Concatenate (Data table (temp_tbl_pval), "Append to First Table");
Close (temp_tbl_lsm, NoSave);
Close (temp_tbl_pval, NoSave);
);
dtoutl << Bring Window to Front;
dtoutp << Bring Window to Front;
모든 피드백을 환영합니다.
최상의,
TS
스크립팅Re: JMP > JSL > 다중 호출 모델에 대한 스크립트 가속(N > 2000)?안녕하세요 JMP 커뮤니티입니다.
저는 분석 출력 테이블의 긴 컬렉션을 집계하기 위한 저장소로 행렬을 실험했으며 지금까지 실행 시간을 ~5배까지 가속화했습니다(아래 참조). 유일한 사소한 불편은 (분명히) 행렬이 텍스트를 보유하지 않기 때문에 캡처된 출력 테이블에 대한 주석을 다시 작성해야 한다는 것입니다.
Names Default to Here (1);
st = Today();
dt = Current Data Table ();
dts = dt << Summary( Group( :VISIT, :TRT01A ), Freq( "None" ), Weight( "None" ), invisible );
annot_lsm = {};
met_l = {};
annot_pv = {};
CList = dt << Get Column Names (string);
For (j = 1, j <= N Rows (dts), j++,
insert into (annot_lsm, dts:VISIT [j] || ", " || dts:TRT01A [j]);
);
annot_pv = annot_lsm;
annot_pv = Concat To(annot_pv, {"Estimate","Std Error", "t Ratio", "Prob>|t|", "SS", "Lower 95%", "Upper 95%"});
Close (dts, NoSave);
mtx_lsm = [];
mtx_pval = [];
For (i = 1, i<= 2000, i++, //2000
fm = dt << Fit Model(
Y( Column (i) ),
Effects( :VISIT, :TRT01A, :VISIT * :TRT01A, Column (i+2000) ),
Personality( "Standard Least Squares" ),
Emphasis( "Minimal Report" ),
Run(
Column (i) << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
Parameter Estimates( 1 ), Scaled Estimates( 0 ),
Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
Plot Residual by Predicted( 0 ), Plot Studentized Residuals( 0 ),
Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
Box Cox Y Transformation( 0 ), {:VISIT * :TRT01A <<
{LSMeans Contrast( [0 0 1 -1 0 0, 0 0 0 0 1 -1] )}}}
)
);
fmr = report (fm);
insert into (met_l, CList [i]);
table_list = fmr << xpath ("//OutlineBox [text() = 'VISIT*TRT01A']//TableBox");
temp_lsm = table_list [1];
temp_pval = table_list [2];
temp_mtx_lsm = temp_lsm << Get as Matrix;
temp_mtx_pval = temp_pval << Get as Matrix;
fmr << close window;
mtx_lsm = mtx_lsm |/ temp_mtx_lsm;
mtx_pval = mtx_pval |/ temp_mtx_pval ;
);
dtoutl = as Table (mtx_lsm);
dtoutp = as Table (mtx_pval);
dtoutl << new column ("COMP", Character, Nominal);
dtoutl << new column ("MET_ID", Character, Nominal);
dtoutl:Col1 << set name ("LSMEAN");
dtoutl:Col2 << set name ("STDERR");
dtoutl:Col3 << set name ("UPPER CI");
dtoutl:Col4 << set name ("LOWER CI");
dtoutl << Begin Data Update;
For Each Row( dtoutl, :COMP = annot_lsm[Sequence( 1, N Items (annot_lsm), 1, 1 )] );
For each row( dtoutl, :MET_ID = met_l[Sequence (1,N Items (met_l), 1, 6)] );
dtoutl << End Data Update;
dtoutp << new column ("LABEL", Character, Nominal);
dtoutp << new column ("MET_ID", Character, Nominal);
dtoutp << Begin Data Update;
For Each Row( dtoutp, :LABEL = annot_pv[Sequence( 1, N Items (annot_pv), 1, 1 )] );
For each row( dtoutp, :MET_ID = met_l[Sequence (1,N items (met_l), 1, 13)] );
dtoutp << End Data Update;
Re: JMP > JSL > 다중 호출 모델에 대한 스크립트 가속(N > 2000)?5X는 훌륭합니다!
도움이 될 수 있는 플랫폼에 대한 보이지 않는 옵션이 있을 수도 있습니다.
(JSL 프로파일러를 사용해보십시오. 다음 제안은 기본이 아닐 수 있습니다. 시간의 1% 미만을 사용하여 더 빠르게 만드는 것은 의미가 없습니다...)
그래도 충분하지 않은 경우 루프의 마지막 두 명령문이 다음으로 살펴볼 수 있습니다. 귀하의 JSL이 점차적으로 더 큰 크기로 배열을 2000번 재할당하고 있다고 생각합니다. J(nr,nc,initvalue) 함수를 사용하여 배열을 미리 할당하고 mtx_lsm[a::b,0] = temp_mtx_lsm[0,0]과 같이 배열에 저장할 수 있다면 시간을 절약할 수 있습니다. .
편집: 이것은 재할당할 뿐만 아니라 데이터도 복사하기 때문에 잠재적으로 N^2 문제입니다. 1000 실행에서 2000 실행으로 이동하면 데이터 양의 4배(2배 아님)가 복사됩니다.
Re: JMP > JSL > 다중 호출 모델에 대한 스크립트 가속(N > 2000)?안녕하세요 @Craige_Hales ,
제안해 주셔서 감사합니다. 추천해주신 방법 덕분에 속도를 33% 더 향상시켰습니다.
아직 완벽해야 하는 약간의 조정이 있지만 총 실행 시간은 약 450초로 시작하여 초기 변경 시 91초로 줄였으며 지금은 61초로 줄였습니다.
최상의
TS