def test_stratified_validation_shuffle_split():
 skip_if_no_sklearn()
 from pylearn2.cross_validation.subset_iterators import StratifiedValidationShuffleSplit
 n = 60
 y = np.concatenate((np.zeros((n / 2), dtype=int), np.ones((n / 2), dtype=int)))
 cv = StratifiedValidationShuffleSplit(y)
 for (train, valid, test) in cv:
  assert (np.unique(np.concatenate((train, valid, test))).size == n)
  assert (valid.size == (n * cv.test_size))
  assert (test.size == (n * cv.test_size))
  assert (np.count_nonzero(y[valid]) == ((n / 2) * cv.test_size))
  assert (np.count_nonzero(y[test]) == ((n / 2) * cv.test_size))

def test_stratified_validation_shuffle_split ( ) : skip_if_no_sklearn ( ) from pylearn2 . cross_validation . subset_iterators import StratifiedValidationShuffleSplit n = 60 y = np . concatenate ( ( np . zeros ( ( n / 2 ) , dtype = int ) , np . ones ( ( n / 2 ) , dtype = int ) ) ) cv = StratifiedValidationShuffleSplit ( y ) for ( train , valid , test ) in cv : assert ( np . unique ( np . concatenate ( ( train , valid , test ) ) ) . size == n ) assert ( valid . size == ( n * cv . test_size ) ) assert ( test . size == ( n * cv . test_size ) ) assert ( np . count_nonzero ( y [ valid ] ) == ( ( n / 2 ) * cv . test_size ) ) assert ( np . count_nonzero ( y [ test ] ) == ( ( n / 2 ) * cv . test_size ) )
test stratifiedvalidationshufflesplit .