aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-03-07 12:50:24 -0500
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-03-07 12:50:24 -0500
commitf692eb7a8329e0b9f42ada5a105430906bfbbcbf (patch)
treea3e987ea4e5aea737f36033976dc8bb446903f28 /test
parentLower threshold to stop Travis from failing (diff)
downloadpygensvm-f692eb7a8329e0b9f42ada5a105430906bfbbcbf.tar.gz
pygensvm-f692eb7a8329e0b9f42ada5a105430906bfbbcbf.zip
Speed up unit tests
Diffstat (limited to 'test')
-rw-r--r--test/test_gridsearch.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/test/test_gridsearch.py b/test/test_gridsearch.py
index e5861d4..c723949 100644
--- a/test/test_gridsearch.py
+++ b/test/test_gridsearch.py
@@ -15,7 +15,13 @@ from sklearn.datasets import load_iris, load_digits
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import maxabs_scale
-from gensvm.gridsearch import GenSVMGridSearchCV, _validate_param_grid
+from gensvm.gridsearch import (
+ GenSVMGridSearchCV,
+ _validate_param_grid,
+ load_grid_tiny,
+ load_grid_small,
+ load_grid_full,
+)
class GenSVMGridSearchCVTestCase(unittest.TestCase):
@@ -211,9 +217,14 @@ class GenSVMGridSearchCVTestCase(unittest.TestCase):
""" GENSVM_GRID: Test with tiny grid """
X, y = load_iris(return_X_y=True)
X = maxabs_scale(X)
- X_train, X_test, y_train, y_test = train_test_split(X, y)
+ X_train, X_test, y_train, y_test = train_test_split(
+ X, y, random_state=123
+ )
- clf = GenSVMGridSearchCV(param_grid="tiny")
+ tiny = load_grid_tiny()
+ for x in tiny:
+ x["epsilon"] = [1e-5]
+ clf = GenSVMGridSearchCV(param_grid=tiny)
clf.fit(X_train, y_train)
score = clf.score(X_test, y_test)
@@ -225,9 +236,13 @@ class GenSVMGridSearchCVTestCase(unittest.TestCase):
""" GENSVM_GRID: Test with small grid """
X, y = load_iris(return_X_y=True)
X = maxabs_scale(X)
- X_train, X_test, y_train, y_test = train_test_split(X, y)
+ X_train, X_test, y_train, y_test = train_test_split(
+ X, y, random_state=123
+ )
- clf = GenSVMGridSearchCV(param_grid="small")
+ small = load_grid_small()
+ small["epsilon"] = [1e-5]
+ clf = GenSVMGridSearchCV(param_grid=small)
clf.fit(X_train, y_train)
score = clf.score(X_test, y_test)
@@ -239,9 +254,13 @@ class GenSVMGridSearchCVTestCase(unittest.TestCase):
""" GENSVM_GRID: Test with full grid """
X, y = load_iris(return_X_y=True)
X = maxabs_scale(X)
- X_train, X_test, y_train, y_test = train_test_split(X, y)
+ X_train, X_test, y_train, y_test = train_test_split(
+ X, y, random_state=123
+ )
- clf = GenSVMGridSearchCV(param_grid="full")
+ full = load_grid_full()
+ full["epsilon"] = [1e-5]
+ clf = GenSVMGridSearchCV(param_grid=full)
clf.fit(X_train, y_train)
score = clf.score(X_test, y_test)