Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
128 views
in Technique[技术] by (71.8m points)

python - My data wont loaded into train_test_split

Below show the datasets code I used to load my datasets (161 folders , 500 data each folder)

  folders = glob.glob('C:/Users/Pc/Desktop/datasets/*')
imagenames_list = []

for folder in folders:
    for f in glob.glob(folder+'/*.jpg'):
        imagenames_list.append(f)
        
read_images = []
for image in imagenames_list:
    read_images.append(cv2.imread(image, cv2.IMREAD_GRAYSCALE))
    
images = np.array(read_images)

Below show the train_test_split code used in my datasets

from sklearn.model_selection import train_test_split

X, y = np.random.random((80500,10)), np.random.random((80500,))

p = 0.2
new_p = (p*y.shape[0])/((1-p)*y.shape[0])

X, X_val, y, y_val = train_test_split(X, y, test_size=p)
X_train, X_test, y, y_test = train_test_split(X, y, test_size=new_p)

print([i.shape for i in [X_train, X_test, X_val]])

However, I found out that my train test split code won't link to my datasets, is there any way I can make to let the train_test_Split work well in my datasets? How do I assign the variables in the first part of the code?

question from:https://stackoverflow.com/questions/66058463/my-data-wont-loaded-into-train-test-split

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...