当前位置:网站首页>Deep learning to achieve cross validation (image, signal processing)
Deep learning to achieve cross validation (image, signal processing)
2022-07-22 17:34:00 【Dragon Guardian】
When we write articles , I'm always afraid that my results can't get enough credibility , Set in time seed But it often fails , So we will adopt the method of cross validation , It is their own results that are more reliable , General with 5 Most of them are 10% off , This article mainly introduces the implementation method , With image processing 、 Signal recognition and other deep learning as the basic background .
First , As before , Read out the training set , Test the set and preprocess ( According to your own project )
after , Fusion training set 、 Test set , In order to re divide , Cross validation .
X = np.append(train_set.X,test_set.X,axis=0) # The training set and the test set are spliced
y = np.append(train_set.y,test_set.y,axis=0) # Label stitching
After that, adopt index addressing , Just divide the index position , that will do .
i = 1
KF = KFold(n_splits=6, shuffle=True, random_state=100)
for train_index, test_index in KF.split(dataset.X):
np.save("F:/ Data used for EEG signal classification /SSVEP/SSVEP_Classify/k_fold_index/subject_{}/train_index_{}".format(subject_id, i), train_index)
np.save("F:/ Data used for EEG signal classification /SSVEP/SSVEP_Classify/k_fold_index/subject_{}/test_index_{}".format(subject_id, i), test_index)
i=i+1
This is a 6 Examples of folding ,shuffle Represents whether to disrupt the data for division ,random_state It is used to reproduce the partition , Be similar to seed
Then cycle to save to the specified location ( Program segment is an example , Change according to your project address when adopting )
After the division , To check whether the division is completed or whether the division is correct , Can be read .
index = [1, 2, 3, 4, 5, 6]
for i in index:
print('*' * 25, ' The first ', i, ' fold ', '*' * 25)
train_index = np.load("F:/ Data used for EEG signal classification /SSVEP/SSVEP_Classify/k_fold_index/subject_{}/train_index_{}.npy".format(subject_id, i))
test_index = np.load("F:/ Data used for EEG signal classification /SSVEP/SSVEP_Classify/k_fold_index/subject_{}/test_index_{}.npy".format(subject_id, i))
print("train_index:{},test_index:{}".format(train_index, test_index))
after , Allocate data according to the indicators just divided
train_set_X = dataset.X[train_index] # Training set
train_set_y = dataset.y[train_index] # Test set
test_set_X = dataset.X[test_index] # Training set label
test_set_y = dataset.y[test_index] # Test set label
The follow-up work is set in the form of circulation , For example, I am a 6 fold , Then set it to
index = [1, 2, 3, 4, 5, 6]
for i in index:
Then carry out the same operation as before when cross validation is not used
边栏推荐
- PostgreSQL determines whether it is empty coalesce
- An annotation implementation method writes the returned data to the cache (facet, redis Implementation)
- How to solve the problem of uncontrollable win11 flashing white screen?
- 牛客网 Fibonacci数列
- LCD notes (1) LCD hardware operation principle of different interfaces
- "New capabilities" of rongyun Super Group
- Go language learning diary [XXXI] interaction between golang and PgSQL
- 牛客网 替换空格
- Openeuler is ambitious, open source huizhichuang future | 2022 open atom global open source summit openeuler sub forum is about to open
- Information security CISP certification - what are your concerns?
猜你喜欢
奇瑞星途产品规划曝光,2.0t涡轮增压发动机,年底推出
How to use js to realize calculator and timer functions
Qianxin joined the Euler open source community to jointly promote the application of commercial passwords
NFTFi赛道版图概览
How to implement Apache's built-in AB stress testing tool
matlab混频器的实现
FPGA之红外遥控
2022年暑假ACM热身练习3(部分题目总结)
How to reinstall win11 system online with one click?
会议OA项目
随机推荐
OSPF特殊区域综合实验
Add asynchronous task processing model task to flask framework
Sql语言(基础一)
Infrared remote control of FPGA
马斯克“变脸”﹕Q2出售75%BTC 套现近10亿美元
【C】 Branch and loop statements
[matrix multiplication] external matrix multiplication
【C】分支和循环语句
ACM warm-up exercise 3 in 2022 summer vacation (summary of some topics)
ES6 related interview question 2
Pytorch deep learning practice-b station Liu erden-day1
IO流的分类和方法
并发程序的噩梦——数据竞争
[reprint] UE4 interview Basics (I)
"New capabilities" of rongyun Super Group
VR全景在各行各业是如何展示?如何落地应用的?
【学习笔记之菜Dog学C】深入理解数组与指针
Distributed computing framework map/reduce
mysql约束之_自增长约束_auto_increment
【外部排序】快排思想完成外部排序