Skip to content

Commit 738720e

Browse files
author
Jordan Stomps
committed
removing leftovers from migration
1 parent a7d4bfe commit 738720e

1 file changed

Lines changed: 1 addition & 91 deletions

File tree

tests/test_models.py

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
import scripts.utils as utils
1313
# models
1414
from models.LogReg import LogReg
15-
from models.SSML.CoTraining import CoTraining
16-
from models.SSML.LabelProp import LabelProp
17-
from models.SSML.ShadowNN import ShadowNN
18-
from models.SSML.ShadowCNN import ShadowCNN
1915
# testing write
2016
import joblib
2117
import os
@@ -166,90 +162,4 @@ def test_LogReg():
166162
model_file = joblib.load(filename+ext)
167163
assert model_file.best['params'] == model.best['params']
168164

169-
os.remove(filename+ext)
170-
171-
172-
# check default parameter settings
173-
model = ShadowCNN()
174-
assert model.params == {'binning': 1, 'batch_size': 1}
175-
assert model.model is not None
176-
assert model.eaat is not None
177-
assert model.optimizer is not None
178-
179-
X, Ux, y, Uy = train_test_split(spectra,
180-
labels,
181-
test_size=0.5,
182-
random_state=0)
183-
X_train, X_test, y_train, y_test = train_test_split(X,
184-
y,
185-
test_size=0.2,
186-
random_state=0)
187-
188-
# normalization
189-
normalizer = StandardScaler()
190-
normalizer.fit(X_train)
191-
192-
X_train = normalizer.transform(X_train)
193-
X_test = normalizer.transform(X_test)
194-
Ux = normalizer.transform(Ux)
195-
196-
params = {'layer1': 2,
197-
'kernel': 3,
198-
'alpha': 0.1,
199-
'xi': 1e-3,
200-
'eps': 1.0,
201-
'lr': 0.1,
202-
'momentum': 0.9,
203-
'binning': 20,
204-
'batch_size': 4,
205-
'drop_rate': 0.1}
206-
207-
# default behavior
208-
model = ShadowCNN(params=params, random_state=0)
209-
losscurve, evalcurve = model.train(X_train, y_train, Ux, X_test, y_test)
210-
211-
# testing train and predict methods
212-
pred, acc = model.predict(X_test, y_test)
213-
214-
# test for agreement between training and testing
215-
# (since the same data is used for diagnostics in this test)
216-
assert evalcurve[-1] == acc
217-
218-
# Shadow/PyTorch reports accuracies as percentages
219-
# rather than decimals
220-
# uninteresting test if Shadow predicts all one class
221-
# TODO: make the default params test meaningful
222-
assert np.count_nonzero(pred == y_test) > 0
223-
224-
# testing hyperopt optimize methods
225-
space = params
226-
space['binning'] = scope.int(hp.quniform('binning',
227-
10,
228-
20,
229-
1))
230-
data_dict = {'trainx': X_train,
231-
'testx': X_test,
232-
'trainy': y_train,
233-
'testy': y_test,
234-
'Ux': Ux
235-
}
236-
model.optimize(space, data_dict, max_evals=2, verbose=True)
237-
238-
assert model.best['accuracy'] >= model.worst['accuracy']
239-
assert model.best['status'] == 'ok'
240-
241-
# testing model plotting method
242-
filename = 'test_plot'
243-
model.plot_training(losscurve=model.best['losscurve'],
244-
evalcurve=model.best['evalcurve'],
245-
filename=filename)
246-
os.remove(filename+'.png')
247-
248-
# testing model write to file method
249-
filename = 'test_LogReg'
250-
ext = '.joblib'
251-
model.save(filename)
252-
model_file = joblib.load(filename+ext)
253-
assert model_file.best['params'] == model.best['params']
254-
255-
os.remove(filename+ext)
165+
os.remove(filename+ext)

0 commit comments

Comments
 (0)