JMP> JSL>複数のCallto Fitモデルのスクリプトアクセラレーション(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;
すべてのフィードバックは大歓迎です。
一番、
NS
スクリプティングRe:JMP> JSL>複数のCallto Fitモデルのスクリプトアクセラレーション(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>複数のCallto Fitモデルのスクリプトアクセラレーション(N> 2000)?5Xは素晴らしいですね!
役立つかもしれないプラットフォームのための目に見えないオプションもあるかもしれません。
(JSLプロファイラーを試してください。次の提案はベースから大きく外れている可能性があります。 1%未満の時間を使用して何かを高速化する意味はありません...)
それでも十分でない場合は、ループの最後の2つのステートメントが次に確認する場所になる可能性があります。 あなたの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>複数のCallto Fitモデルのスクリプトアクセラレーション(N> 2000)?やあ@Craige_Hales 、
提案をありがとう。 お勧めの方法のおかげで、速度がさらに33%向上しました。
まだいくつかの調整が必要ですが、合計実行時間は約450秒で、最初の変更で91秒になり、現在は61秒になっています。
一番
NS
Re:JMP> JSL>複数のCallto Fitモデルのスクリプトアクセラレーション(N> 2000)?いいね! コミュニティは、そこにたどり着くためにあなたが何をしたかを見たいと思っていると思います。あるいは、さまざまな変更がどれほど重要であったかを要約したいと思います。
@DonMcCormack