簡體   English   中英

Python 1D CNN model - train_test_split 中的錯誤

[英]Python 1D CNN model - Error in train_test_split

我正在嘗試通過處理心電圖信號來診斷睡眠呼吸暫停來構建一維 CNN model。

我正在使用 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,而且是 fit-transform。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM