JMPコミュニティの皆様、こんにちは。
私のJSLスクリプトでは、次のように新しい列を次々と生成することがよくあります。
...
DT << New Column( "Some Name1", Numeric, "Continuous", Formula( Some Formula1 ) );
DT << New Column( "Some Name2", Numeric, "Continuous", Formula( Some Formula2 ) );
DT << New Column( "Some Name3", Numeric, "Continuous", Formula( Some Formula3 ) );
...
通常、私のデータテーブルは非常に大きく、1億行に達することもあります。使用する数式には、Col Mean() 、 コル最大値()などの統計関数が含まれていることが多く、行数が増えるほど処理速度が低下します。新しい列の中には互いに依存するものがあるかもしれませんが、現時点では依存していないものと仮定してください。
スクリプトを実行すると、JMP 19.1 が私の CPU (16 コア、32 スレッド) のわずか 3~4% しか使用していないことがわかります。
サブセットを作成したり、サブセットの結果をマージしたりすることなく、並列処理などによって計算を高速化することは可能でしょうか?JMPのJSLを使用して、同一のデータテーブル上で並列処理を行うことはできますか?
そうでない場合、「部分集合の数式計算とマージを繰り返す」というアプローチを試してみる価値はあると思いますか?
乾杯
ロブ
計算内容(および数式が必要かどうか)によっては、サマリーテーブルを作成し、そこで計算を行い、その結果を元のテーブルに反映させるという方法も考えられます。
行列の並列化を管理するためのツールとして、Parallel Assign があります。
少数の入力列に基づいて多数の新しい列を作成する場合や、使用できる関数が非常に限られている場合を除き、これが実際に処理速度を向上させるかどうかは確信が持てません。
以下に例を示します。
Names default to here(1);
dt = Open("$Sample_data/Pollen.jmp");
//first a simple demo of parallel assign to calculate column means
moutmeans = J(n col(dt), 1, .); //blank matrix that will be populated
mdata = dt << get as matrix; //input data as a matrix
Parallel Assign(
{ mdata = mdata }, //variables needed in the 'worker thread'
moutmeans[a, b] = mean(mdata[0,a]); //this fills in one cell
);
show(moutmeans); //col means are here
// Now for new columns
//mdata = mdata[1::2,0]; //a way to start small if you add show()
nrows = nrow(mdata);
cnames = dt << get column names(); //used to find position of columns in matrix
// Write formulas for each columns using column names as placeholders
// to be replaced by matrix values later, this would work for pretty simple logic
formulas = Eval List({
Expr(edge + nub + 10),
Eval Expr(nub - Expr( col mean(dt:nub) ) ) //note this col mean evaluates now
});
newcnames = {"a","b"}; //new column names used later
mout = J(nrows, length(formulas), .); //empty matrix to populate
Parallel Assign(
{
mdata = mdata,
formulas = formulas,
cnames = cnames
},
mout[a, b] = (
f = formulas[b];
//assign values to all potential variables used in matricies
//(bad idea if lots of unused columns)
for(i=1, i<= n items(cnames), i++,
//Make a list with the variable to assign and value to assign it to,
// then replace the list with assign
Eval( Substitute(
Eval List( {as name( name expr( cnames[i] ) ), mdata[a,i]} ),
Expr({}),
Expr( assign() )
) );
);
eval(f);
);
);
//put new columns in table
for each({c,i}, newcnames, dt << New Column(c,Numeric,Continuous, << Set Values(mout[0,i])));
//add columns to double check it worked
dt << New Column("a-check", Numeric, "Continuous", Format("Best", 12), Formula(:edge + :nub + 10));
dt << New Column("b-check", Numeric, "Continuous", Format("Best", 12), Formula(:nub - Col Mean(:nub)));
すべての列が作成されるまで数式の評価を抑制し、その後「数式の実行」を使用してみるのも良いでしょう。
( @Ryan_Gilmore 、 @Robbbb ) dt<
投票したい希望リスト項目はこちらです
背景式評価