Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Commit

Permalink
updating tests/test_selection_dynamic.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dvro committed Oct 6, 2016
1 parent 42bbe7c commit 997ffed
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions test/test_selection_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,15 @@
from brew.generation.bagging import *
from brew.selection.dynamic.knora import *

Xtra = np.random.random((100, 2))
ytra = np.random.randint(0,2,100)

Xval = np.random.random((40,2))
yval = np.random.randint(0,2,40)

Xtst = np.random.random((30,2))
ytst = np.random.randint(0,2,30)

N=1000
N=10000
X, y = datasets.make_hastie_10_2(n_samples=N, random_state=1)
for i, yi in enumerate(set(y)):
y[y == yi] = i

Xtra, Xtst, ytra, ytst = train_test_split(X, y, test_size=0.10)
Xtra, Xval, ytra, yval = train_test_split(Xtra, ytra, test_size=0.30)

bag = Bagging(base_classifier=DecisionTreeClassifier(), n_classifiers=5)
bag = Bagging(base_classifier=DecisionTreeClassifier(), n_classifiers=100)
bag.fit(Xtra, ytra)

class KNORA_UNION_VALID(KNORA):
Expand Down Expand Up @@ -88,7 +79,7 @@ class TestKNORA_E():
def test_simple(self):
selector_pred = KNORA_ELIMINATE(Xval=Xval, yval=yval)
selector_true = KNORA_ELIMINATE_VALID(Xval=Xval, yval=yval)
for x in Xtst[:10]:
for x in Xtst:
pool_pred, w_pred = selector_pred.select(bag.ensemble, x)
pool_true, w_true = selector_true.select(bag.ensemble, x)
assert w_pred == w_true
Expand All @@ -102,7 +93,7 @@ class TestKNORA_U():
def test_simple(self):
selector_pred = KNORA_UNION(Xval=Xval, yval=yval)
selector_true = KNORA_UNION_VALID(Xval=Xval, yval=yval)
for x in Xtst[:10]:
for x in Xtst:
pool_pred, w_pred = selector_pred.select(bag.ensemble, x)
pool_true, w_true = selector_true.select(bag.ensemble, x)
assert len(pool_pred) == len(pool_true)
Expand Down

0 comments on commit 997ffed

Please sign in to comment.