提高JSL效率:如何在每次運行後關閉plot窗口,讓JSL運行的更快而不壓垮PC。我目前有一張大桌子來運行多項式擬合。
1. 目標:生成多項式擬合參數並導出為表格。
2.問題:使用下面的JSL,運行整個表需要很長時間。所以我只能將表分成小組來運行以避免 PC crash。
3.原因:下表需要先擬合多項式曲線,然後生成匯總表,最後將所有類導出到1個表中。
假設有100k類,需要很長時間擬合多項式曲線,然後導出到表中。
4. 需要幫助:有人可以幫我修改 JSL 嗎? 用多項式曲線使其適合每個類,然後導出到表格,然後關閉多項式曲線窗口。 這將節省內存繼續運行所有 100k 類加起來只導出 100k 類的表,而不生成 100k 的繪圖窗口。
謝謝您的幫助。
dt = Current Data Table();
biv = Bivariate( Y( :weight ), X( :age ), Fit Polynomial( 2, {Line Color( {47, 193, 29} )} ), By( :class ) );
rbiv = biv << report;
Summarize( groups = by( class ) ); // A list of all by-groups
n = N Items( groups );
//Create output table and fill with estimates
dtOut = New Table( "Polynominal parameters",
New Column( "class", Character ),
New Column( "T", numeric ),
New Column( "T2", numeric ),
addrows( n )
);
For( j = 1, j <= n, j++,
Estimates = rbiv[j]["Polynomial Fit Degree=2"]["Parameter Estimates"][1][3] << get as matrix;
:class[j] = groups[j];
:T[j] = Estimates[2];
:T2[j] = Estimates[3];
);
Re: Improve JSL efficiency: 如何在每次運行後關閉 plot 窗口,使 JSL 運行得更快而不會壓壞 PC。這是我對並行分配的嘗試。我還在學習它是如何工作的。
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
summarize(dt, ages = By(:age));
::results = J(nitems(ages), 3, -1);
driver = ::results[0, 1];
age_rows = {};
for(i=1, i<=nitems(ages), i++,
insert into(age_rows, dt << Get Rows Where(:age == Num(ages[i])));
);
y = dt:height << Get Values();
x = dt:weight << Get Values();
m = mean(x);
Parallel Assign({a = ages, ar = age_rows, y = y, x = x, m = m},
driver[i] = (
rows = ar[i];
ys = y[rows];
xs = x[rows];
xs2 = xs||(xs-m)^2;
print(i, ys, xs2);
batch interactive(1);
Try({b, vb} = Least Squares Solve(ys, xs2));
batch interactive(0);
::results[i, 0] = b`
);
);
show(::results);Re: Improve JSL efficiency: 如何在每次運行後關閉 plot 窗口,使 JSL 運行得更快而不會壓壞 PC。如果您不關心實際情節,還有其他幾種方法。我有時會看到減速只是為了渲染大量的地塊。
1.不用平台計算。
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
summarize(dt, ages = By(:age));
dtOut = New Table( "Polynominal parameters",
New Column( "class", Character ),
New Column( "T", numeric ),
New Column( "T2", numeric ),
addrows(nitems(ages))
);
for(i=1, i<=nitems(ages), i++,
rows = dt << Get Rows Where(:age == Num(ages[i]));
y = dt:height[rows];
x = dt:weight[rows];
x2 = x||(x-ColMean(dt:weight))^2;
{b, vb} = Least Squares Solve(y, x2);
dtOut:class[i] = ages[i];
dtOut:T[i] = b[2];
dtOut:T2[i] = b[3];
);
2. 不用按變量繪製一堆圖表,你可以按變量繪製一組圖表(我有時得到過這種幫助)。
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
Group By(:age),
Fit Polynomial( 2 ),
invisible
);
report(biv)["Parameter Estimates"][TableBox(1)] << Make Combined Data Table
而 <Re: Improve JSL efficiency: 如何在每次運行後關閉 plot 窗口,使 JSL 運行得更快而不會壓壞 PC。
非常感謝,這是比我原來的解決方案更好的解決方案。
我添加了一個 For 循環以將大表子集化為小表並使用您的腳本來解決我的問題。
Re: Improve JSL efficiency: 如何在每次運行後關閉 plot 窗口,使 JSL 運行得更快而不會壓壞 PC。嘗試使用此代碼開始:
dt1 = Current Data Table();
// launch Bivariate with more than one By group, save list of analysis layer references
biv = dt1 << Bivariate( Y( :weight ), X( :age ), By( :sex ), Fit Polynomial( 2 ) );
// obtain first report layer reference and save
rbiv = biv[1] << Report;
// use first reference to send table box message
dt2 = rbiv["Parameter Estimates"][TableBox(1)] << Make Combined Data Table;
// process results as a data table
然後添加代碼以修改數據表以滿足您的需要。
Re: Improve JSL efficiency: 如何在每次運行後關閉 plot 窗口,使 JSL 運行得更快而不會壓壞 PC。謝謝回复。
可以幫忙根據上面的jsl修改嗎?
不清楚該怎麼做...
Re: Improve JSL efficiency: 如何在每次運行後關閉 plot 窗口,使 JSL 運行得更快而不會壓壞 PC。您不需要遍歷每個類。 將 << Make Combined Data Table 發送到第一個參數估計大綱中的表格框。