-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
329 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from sklearn.datasets import load_iris | ||
from tpot.builtins import CategoricalSelector, ContinuousSelector | ||
from nose.tools import assert_equal, assert_raises | ||
|
||
iris_data = load_iris().data | ||
|
||
def test_CategoricalSelector(): | ||
"""Assert that CategoricalSelector works as expected.""" | ||
cs = CategoricalSelector() | ||
X_transformed = cs.transform(iris_data[0:16, :]) | ||
|
||
assert_equal(X_transformed.shape[1],2) | ||
|
||
|
||
def test_CategoricalSelector_2(): | ||
"""Assert that CategoricalSelector works as expected with threshold=5.""" | ||
cs = CategoricalSelector(threshold=5) | ||
X_transformed = cs.transform(iris_data[0:16, :]) | ||
|
||
assert_equal(X_transformed.shape[1],1) | ||
|
||
|
||
def test_CategoricalSelector_3(): | ||
"""Assert that CategoricalSelector works as expected with threshold=20.""" | ||
cs = CategoricalSelector(threshold=20) | ||
X_transformed = cs.transform(iris_data[0:16, :]) | ||
|
||
assert_equal(X_transformed.shape[1],7) | ||
|
||
|
||
def test_CategoricalSelector_4(): | ||
"""Assert that CategoricalSelector rasies ValueError without categorical features.""" | ||
cs = CategoricalSelector() | ||
|
||
assert_raises(ValueError, cs.transform, iris_data) | ||
|
||
|
||
def test_CategoricalSelector_fit(): | ||
"""Assert that fit() in CategoricalSelector does nothing.""" | ||
op = CategoricalSelector() | ||
ret_op = op.fit(iris_data) | ||
|
||
assert ret_op==op | ||
|
||
|
||
def test_ContinuousSelector(): | ||
"""Assert that ContinuousSelector works as expected.""" | ||
cs = ContinuousSelector(svd_solver='randomized') | ||
X_transformed = cs.transform(iris_data[0:16, :]) | ||
|
||
assert_equal(X_transformed.shape[1],2) | ||
|
||
|
||
def test_ContinuousSelector_2(): | ||
"""Assert that ContinuousSelector works as expected with threshold=5.""" | ||
cs = ContinuousSelector(threshold=5, svd_solver='randomized') | ||
X_transformed = cs.transform(iris_data[0:16, :]) | ||
assert_equal(X_transformed.shape[1],3) | ||
|
||
|
||
def test_ContinuousSelector_3(): | ||
"""Assert that ContinuousSelector works as expected with svd_solver='full'""" | ||
cs = ContinuousSelector(threshold=10, svd_solver='full') | ||
X_transformed = cs.transform(iris_data[0:16, :]) | ||
assert_equal(X_transformed.shape[1],2) | ||
|
||
|
||
def test_ContinuousSelector_4(): | ||
"""Assert that ContinuousSelector rasies ValueError without categorical features.""" | ||
cs = ContinuousSelector() | ||
|
||
assert_raises(ValueError, cs.transform, iris_data[0:10,:]) | ||
|
||
|
||
def test_ContinuousSelector_fit(): | ||
"""Assert that fit() in ContinuousSelector does nothing.""" | ||
op = ContinuousSelector() | ||
ret_op = op.fit(iris_data) | ||
|
||
assert ret_op==op |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.