JSL スクリプトをより効率的にして、「スライディング ウィンドウ」をサンプリングするこんにちは、
私は、データ テーブルを「スライディング ウィンドウ」でサンプリングするスクリプトを作成しようとしています (「幅」が設定された行数をサンプリングし、次に 1 行上に移動して次のセットをサンプリングし、結果として行 1 ~ 10、2 ~ 11、3 ~ 12 などのデータ セットが生成されます)。データ テーブルをサンプリングして、パターン分析に使用できる新しいデータ セットを作成します。
私のスクリプトは動作していますが、大規模なデータベースではうまく動作せず、分析が遅くなったり (1 時間以上)、JMP がクラッシュしたりします。改善方法について何か提案はありますか?
ありがとう!
// Define the window size (number of rows) and the increment (how much the standardised time should increase by)
windowSize = 9;
increment = 91;
// Get the number of rows in the data table
dt = Open("$SAMPLE_DATA/Time Series/GNP.jmp");
dt << Add Rows(windowSize);
numRows = N Rows(dt);
// Create a list to store the subsets
subsets = {};
standTimeMatrix = J(windowSize, 1, 0); // Pre-allocate matrix for Stand Time
// Fill the Stand Time matrix
dt << begin data update;
For(j = 1, j <= windowSize, j++,
standTimeMatrix[j, 1] = 1 + (j - 1) * increment;
);
// Loop through the data table to create the sliding windows
For(i = 1, i <= numRows - windowSize + 1, i++,
// Get the subset of data for the current window
subset = dt << Subset(Rows(i::i + windowSize - 1));
// Add the window number to the subset
windowNumberColumn = Repeat(i, windowSize);
subset << New Column("Window Number", Numeric, Continuous, Set Values(windowNumberColumn));
// Add the "Standardised Time" column to the subset
subset << New Column("Standardised Time", Numeric, Continuous, Set Values(standTimeMatrix));
// Add the subset to the list
Insert Into(subsets, subset);
);
// Create a new table for concatenation
newTable = New Table("All Data");
// Run the concatenations using the subsets list
For(i = 1, i <= N Items(subsets), i++,
newTable << Concatenate(
subsets[i],
append to first table(1)
);
// Close the subset table after concatenation to free up memory
Close(subsets[i], No Save);
);
自動化とスクリプトRe: JSL スクリプトをより効率的にして「スライディング ウィンドウ」をサンプリングするこれがあなたが望んでいること(スクリプトとは異なる結果)を実行しているのか、「大規模なデータベース」が何なのかはわかりませんが、おそらく次のようなものが機能するでしょう。
Names Default To Here(1);
size = 10;
dt = Open("$SAMPLE_DATA/Time Series/GNP.jmp", Invisible);
dt_results = dt << Clone;
dt_results << Show Window(0);
dt_results << Delete Rows(1::N Rows(dt_results));
dt_results << New Column("Idx", Numeric, Ordinal);
dt_results << New Column("Rows", Numeric, Ordinal);
cols = dt << Get Column Names("String");
i = 0;
While(i + size <= N Rows(dt),
old_rows = (1+i)::(i+size);
dt_temp = dt << Subset(Rows(old_rows), Selected Columns(0), Invisible);
dt_temp << New Column("Idx", Numeric, Ordinal, Set Each Value(i + 1));
dt_temp << New Column("Rows", Numeric, Ordinal, Values(old_rows));
dt_results << Concatenate(dt_temp,
"Append to first table"
);
Close(dt_temp, no save);
i++;
);
dt_results << Show Window(1);Re: JSL スクリプトをより効率的にして「スライディング ウィンドウ」をサンプリングする補助テーブルを作成する必要はないのでしょうか?
Col Moving Average では、スライディング ウィンドウ内の値を比較するための設定がいくつか提供されます。

次のステップは何ですか?