Skip to content
This repository was archived by the owner on Jul 27, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions brew/stacking/stacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ..base import Ensemble
from ..combination.combiner import Combiner

from sklearn import cross_validation
from sklearn.model_selection import StratifiedKFold


class EnsembleStack(object):
Expand All @@ -28,8 +28,9 @@ def fit_layer(self, layer_idx, X, y):
n_classes = len(set(y)) - 1
n_classifiers = len(self.layers[layer_idx])
output = np.zeros((X.shape[0], n_classes * n_classifiers))
skf = cross_validation.StratifiedKFold(y, self.cv)
for tra, tst in skf:
skf = StratifiedKFold(n_splits=self.cv)

for tra, tst in skf.split(X, y):
self.layers[layer_idx].fit(X[tra], y[tra])
out = self.layers[layer_idx].output(X[tst], mode=self.mode)
output[tst, :] = out[:, 1:, :].reshape(
Expand Down