Python 1D CNN 模型 - train_test_split 中的错误

Python 1D CNN model - Error in train_test_split

我正在尝试通过处理 ECG 信号来构建 1D CNN 模型来诊断睡眠呼吸暂停。

我正在使用 sklearn 库并在 train_test_split 中遇到错误。这是我的代码:

# loading the file
with open("ApneaData.csv") as csvDataFile:
    csvReader = csv.reader(csvDataFile)
    for line in csvReader:
        lis.append(line[0].split())  # create a list of lists

# making a list of all x-variables
for i in range(1, len(lis)):
    data.append(list(map(int, lis[i])))

# a list of all y-variables (either 0 or 1)
target = Extract(data)  # sleep apn or not

# converting to numpy arrays
data = np.array(data)
target = np.array(target)

# stacking data into 3D
loaded = dstack(data)
change = dstack(target)


trainX, testX, trainy, testy = train_test_split(loaded, change, test_size=0.3)

我收到错误:

With n_samples=1, test_size=0.3 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.

我不明白我做错了什么? 任何帮助将不胜感激。

可能 sklearn 将您的数据理解为 1xN 矩阵,并将其视为具有 N 个特征的 1 个样本。所以你需要转置它并得到Nx1。

这是 sklearn 函数的典型情况,不仅 train_split,而且适合变换。