def stack(self, k=5, stratify=False, shuffle=True, seed=100, full_test=True):
        """Stack a single model. You should rarely be using this method. Use `ModelsPipeline.stack` instead.

        Parameters
        ----------
        k : int, default 5
        stratify : bool, default False
        shuffle : bool, default True
        seed : int, default 100
        full_test : bool, default True
            If `True` then evaluate test dataset on the full data otherwise take the mean of every fold.

        Returns
        -------
        `Dataset` with out of fold predictions.
        """
        train = None
        test = []

        if self.use_cache:
            pdict = {'k': k, 'stratify': stratify, 'shuffle': shuffle, 'seed': seed, 'full_test': full_test}
            dhash = self._dhash(pdict)
            c = Cache(dhash, prefix='s')
            if c.available:
                logger.info('Loading %s\'s stack results from cache.' % self._name)
                train = c.retrieve('train')
                test = c.retrieve('test')
                y_train = c.retrieve('y_train')
                return Dataset(X_train=train, y_train=y_train, X_test=test)
            elif not self.dataset.loaded:
                self.dataset.load()

        for i, fold in enumerate(self.dataset.kfold(k, stratify=stratify, seed=seed, shuffle=shuffle)):
            X_train, y_train, X_test, y_test, train_index, test_index = fold
            logger.info('Calculating %s\'s fold #%s' % (self._name, i + 1))
            if full_test:
                prediction = reshape_1d(self._predict(X_train, y_train, X_test, y_test))
            else:
                xt_shape = X_test.shape[0]
                x_t = concat(X_test, self.dataset.X_test)
                prediction_concat = reshape_1d(self._predict(X_train, y_train, x_t))
                prediction, prediction_test = tsplit(prediction_concat, xt_shape)
                test.append(prediction_test)

            if train is None:
                train = np.zeros((self.dataset.X_train.shape[0], prediction.shape[1]))

            train[test_index] = prediction

        if full_test:
            logger.info('Calculating %s\'s test data' % self._name)
            test = self._predict(self.dataset.X_train, self.dataset.y_train, self.dataset.X_test)
        else:
            test = np.mean(test, axis=0)

        test = reshape_1d(test)

        if self.use_cache:
            c.store('train', train)
            c.store('test', test)
            c.store('y_train', self.dataset.y_train)

        return Dataset(X_train=train, y_train=self.dataset.y_train, X_test=test)
def stack ( self , k = 5 , stratify = False , shuffle = True , seed = 100 , full_test = True ) : train = None test = [ ] if self . use_cache : pdict = { 'k' : k , 'stratify' : stratify , 'shuffle' : shuffle , 'seed' : seed , 'full_test' : full_test } dhash = self . _dhash ( pdict ) c = Cache ( dhash , prefix = 's' ) if c . available : logger . info ( 'Loading %s\'s stack results from cache.' % self . _name ) train = c . retrieve ( 'train' ) test = c . retrieve ( 'test' ) y_train = c . retrieve ( 'y_train' ) return Dataset ( X_train = train , y_train = y_train , X_test = test ) elif not self . dataset . loaded : self . dataset . load ( ) for i , fold in enumerate ( self . dataset . kfold ( k , stratify = stratify , seed = seed , shuffle = shuffle ) ) : X_train , y_train , X_test , y_test , train_index , test_index = fold logger . info ( 'Calculating %s\'s fold #%s' % ( self . _name , i + 1 ) ) if full_test : prediction = reshape_1d ( self . _predict ( X_train , y_train , X_test , y_test ) ) else : xt_shape = X_test . shape [ 0 ] x_t = concat ( X_test , self . dataset . X_test ) prediction_concat = reshape_1d ( self . _predict ( X_train , y_train , x_t ) ) prediction , prediction_test = tsplit ( prediction_concat , xt_shape ) test . append ( prediction_test ) if train is None : train = np . zeros ( ( self . dataset . X_train . shape [ 0 ] , prediction . shape [ 1 ] ) ) train [ test_index ] = prediction if full_test : logger . info ( 'Calculating %s\'s test data' % self . _name ) test = self . _predict ( self . dataset . X_train , self . dataset . y_train , self . dataset . X_test ) else : test = np . mean ( test , axis = 0 ) test = reshape_1d ( test ) if self . use_cache : c . store ( 'train' , train ) c . store ( 'test' , test ) c . store ( 'y_train' , self . dataset . y_train ) return Dataset ( X_train = train , y_train = self . dataset . y_train , X_test = test )
Stack a single model. You should rarely be using this method. Use `ModelsPipeline.stack` instead.

        Parameters
        ----------
        k : int, default 5
        stratify : bool, default False
        shuffle : bool, default True
        seed : int, default 100
        full_test : bool, default True
            If `True` then evaluate test dataset on the full data otherwise take the mean of every fold.

        Returns
        -------
        `Dataset` with out of fold predictions.