'슬라이딩 창' 샘플링을 위해 JSL 스크립트를 더 효율적으로 만듭니다.안녕하세요,
'슬라이딩 윈도우'를 사용하여 데이터 테이블을 샘플링하는 스크립트를 만들려고 합니다('너비' 세트의 행 수를 샘플링한 후 한 행 위로 이동하여 다음 세트를 샘플링하여 데이터 세트가 생성됨). 행 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 이동 평균은 슬라이딩 창 내에서 값을 비교하기 위한 몇 가지 설정을 제공합니다.

당신의 다음 단계는 무엇입니까?