-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from alan-turing-institute/fold-strategy
Fold strategy
- Loading branch information
Showing
5 changed files
with
74 additions
and
59 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 was deleted.
Oops, something went wrong.
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,59 @@ | ||
import numpy as np | ||
from sklearn.decomposition import KernelPCA | ||
from sklearn.decomposition import PCA | ||
from sklearn.model_selection import KFold | ||
from sklearn.model_selection import TimeSeriesSplit | ||
from sklearn.preprocessing import MinMaxScaler | ||
from sklearn.preprocessing import RobustScaler | ||
|
||
from autoemulate.compare import AutoEmulate | ||
|
||
# take fast fitting models for testing | ||
model_subset = ["SecondOrderPolynomial", "RadialBasisFunctions"] | ||
|
||
|
||
def test_scalers(): | ||
X = np.random.rand(100, 5) | ||
y = np.random.rand(100, 1) | ||
|
||
scalers = [MinMaxScaler(), RobustScaler()] | ||
|
||
for scaler in scalers: | ||
ae = AutoEmulate() | ||
ae.setup(X, y, scaler=scaler, model_subset=model_subset) | ||
ae.compare() | ||
ae.print_results() | ||
|
||
assert ae.best_model is not None | ||
|
||
|
||
def test_dimension_reducers(): | ||
X = np.random.rand(100, 10) | ||
y = np.random.rand(100, 1) | ||
|
||
dim_reducers = [PCA(n_components=5), KernelPCA(n_components=5)] | ||
|
||
for dim_reducer in dim_reducers: | ||
ae = AutoEmulate() | ||
ae.setup( | ||
X, y, reduce_dim=True, dim_reducer=dim_reducer, model_subset=model_subset | ||
) | ||
ae.compare() | ||
ae.print_results() | ||
|
||
assert ae.best_model is not None | ||
|
||
|
||
def test_cross_validators(): | ||
X = np.random.rand(100, 5) | ||
y = np.random.rand(100, 1) | ||
|
||
cross_validators = [KFold(n_splits=5), TimeSeriesSplit(n_splits=5)] | ||
|
||
for cross_validator in cross_validators: | ||
ae = AutoEmulate() | ||
ae.setup(X, y, cross_validator=cross_validator, model_subset=model_subset) | ||
ae.compare() | ||
ae.print_results() | ||
|
||
assert ae.best_model is not None |