The K-fold verification proposed in this paper is the Stratifiedkfold method in the Sklearn package in Python.
The idea of the method is described: http://scikit-learn.org/stable/modules/cross_validation.html
Stratifiedkfold Is a variation of K-fold which returns stratified Folds:each set contains approximately the same percentage of samples of each target class as the complete set.
Translation
Stratifiedkfold is the one that sets each sample in the data set Data composition, split by equal means.
Other Partitioning methods See:http://scikit-learn.org/stable/modules/cross_validation.html
Gossip less, directly on the code.
"Stud Wire Source"
Import numpyimport h5pyimport sklearnfrom sklearn import cluster,cross_validationfrom sklearn.cluster Import Agglomerativeclusteringfrom sklearn.cross_validation Import stratifiedkfold## generates a random matrix and saves #arr = Numpy.random.random ( [200,400]) #labvec = [] #for i in Numpy.arange (0,200): # j = i%10# arr[i,j*20:j*20+20] = arr[i,j*20:j*20+20]+10# Labvec.append (j) #arr = arr. T#file = h5py. File (' Arr.mat ', ' W ') #file. Create_dataset (' arr ', data = arr) #file. Close () #file = h5py. File (' Labvec.mat ', ' W ') #file. Create_dataset (' Labvec ', data = Labvec) #file. Close () # Read to open files Myfile=h5py. File (' Arr.mat ', ' r ') arr = myfile[' arr '][:]myfile.close () arr = arr. Tmyfile=h5py. File (' Labvec.mat ', ' r ') Labvec = myfile[' Labvec '][:]myfile.close () SKF = Stratifiedkfold (Labvec, 4) Train_set = []test_ set = []for train, Test in SKF: train_set.append (train) test_set.append (test)
See:
http://scikit-learn.org/stable/modules/cross_validation.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python's Sklearn cross-validation data splitting