当前位置:网站首页>K-fold cross validation
K-fold cross validation
2022-06-25 20:05:00 【Orange cedar】
import os
import cv2
import random
import shutil
import numpy as np
def get_data_crop(k):
# Get all patient sequence names and all training file names
name_list, file_list = [], []
for root, dirs, files in os.walk('./img'):
for f in files:
if f.split('-')[-2] not in name_list:
name_list.append(f.split('-')[-2])
# print(name_list)
file_list.append(root + '/' + f)
random.shuffle(name_list)
#k Crossover verification
for i in range(0,2):
print('name_list:',len(name_list))
fold_size = len(name_list) // k
test_name = name_list[i*fold_size:(i+1)*fold_size]
train_file, test_file = [], []
print('len(test_name):',len(test_name))
print(test_name)
for file in file_list:
print(file.split('/')[-1].split('-')[-2])
if file.split('/')[-1].split('-')[-2] in test_name:
try:
shutil.copy(file,'.\\C\\K10\\test_'+str(i+1)+'\\M\\'+file.split('/')[-1])
shutil.copy(file.replace('img','compound'), '.\\C\\K10\\test_' + str(i+1) + '\\I\\' + file.split('/')[-1])
except Exception:
os.makedirs('.\\C\\K10\\test_'+str(i+1)+'\\M\\')
shutil.copy(file, '.\\C\\K10\\test_'+str(i+1) +'\\M\\' +file.split('/')[-1])
os.makedirs('.\\C\\K10\\test_'+ str(i+1) + '\\I\\')
shutil.copy(file.replace('img', 'compound'),'.\\C\\K10\\test_' + str(i+1) + '\\I\\' + file.split('/')[-1])
else:
try:
shutil.copy(file, '.\\C\\K10\\train_' + str(i+1) +'\\M\\'+file.split('/')[-1])
shutil.copy(file.replace('img', 'compound'),'.\\C\\K10\\train_' + str(i+1) + '\\I\\' + file.split('/')[-1])
except Exception:
print(file)
print(i+1)
os.makedirs('.\\C\\K10\\train_'+str(i+1) +'\\M\\')
shutil.copy(file, '.\\C\\K10\\train_'+str(i+1) + '\\M\\' +file.split('/')[-1])
os.makedirs('.\\C\\K10\\train_' + str(i+1) + '\\I\\' )
shutil.copy(file.replace('compound', 'img'),'.\\C\\K10\\train_' + str(i+1) + '\\I\\' + file.split('/')[-1])
get_data_crop(10)
边栏推荐
- Now meditation: crash service and performance service help improve application quality
- Uni app through uni Navigateto failed to pass parameter (pass object)
- Processing method for uniapp or applet onload not receiving parameters
- Hdoj topic 2005 day
- ActiveMQ--CVE-2016-3088
- Wechat applet connects to the server to display mqtt data information
- Two types of attribute injection methods
- Redis core article: the secret that can only be broken quickly
- Connect the local browser to the laboratory server through mobaxterm
- <C>. Figure guessing game
猜你喜欢

rmi-registry-bind-deserialization

Web components - Basics

Determine whether it is a web page opened on wechat

Two types of attribute injection methods

Panda weekly -2022/02/18

<C>. function

Principles of MySQL clustered index and non clustered index

Vulnhub range - the planes:venus

Uni app through uni Navigateto failed to pass parameter (pass object)

Wechat applet cloud function does not have dependency option installed
随机推荐
PAT B1056
Jsonp function encapsulation
PAT B1051
<C>. tic-tac-toe
打新债网上开户安全吗,需要注意什么
在打新債開戶證券安全嗎?低傭金靠譜嗎
RPM package installation command
Is it safe to open an online account for new bonds? What should be paid attention to
PAT B1059
From now on, I will blog my code
III Implementation principle of vector
<C>. function
The native JS mobile phone sends SMS cases. After clicking the button, the mobile phone number verification code is sent. The button needs to be disabled and re enabled after 60 seconds
2.16([Usaco2005 Nov]Ant Counting)
Redis practice: smart use of data types to achieve 100 million level data statistics
Huawei in application review test requirements
PAT B1066
Clickhouse disables automatic clearing of tables / columns, that is, disables TTL
6、 Configuration resolution of hikariconfig
PHP little knowledge record