% 加载并预处理训练数据
opts1 = detectImportOptions('附件一AE.xlsx', 'PreserveVariableNames', true);
train_data = readtable('附件一AE.xlsx', opts1);
train_data.Time = datetime(train_data.time, 'InputFormat', 'yyyy-MM-dd HH:mm:ss');
% 特征提取和标签准备
windowSize = 20;
numWindows = floor(height(train_data) / windowSize);
amplitudes = zeros(numWindows, 1);
noiseLevels = zeros(numWindows, 1);
labels = false(numWindows, 1);
for i = 1:numWindows
startIdx = (i-1) * windowSize + 1;
endIdx = startIdx + windowSize - 1;
windowData = train_data.AE(startIdx:endIdx);
amplitudes(i) = max(windowData) - min(windowData);
noiseLevels(i) = std(windowData);
labels(i) = any(strcmp(train_data.class(startIdx:endIdx), 'C'));
end
</
标签:startIdx,windowData,XGBoost,windowSize,RF,train,MATLAB,data,numWindows From: https://blog.csdn.net/2301_76574743/article/details/140560764