16
16
from sasctl .pzmm import ModelParameters as mp
17
17
import unittest
18
18
import uuid
19
- import xgboost
20
- import h2o
21
- import tensorflow as tf
22
- import statsmodels .formula .api as smf
23
19
import numpy as np
24
20
25
21
@@ -297,6 +293,7 @@ def test_overwrite(self):
297
293
298
294
class TestGenerateHyperparameters (unittest .TestCase ):
299
295
def test_xgboost (self ):
296
+ xgboost = pytest .importorskip ("xgboost" )
300
297
model = unittest .mock .Mock ()
301
298
model .__class__ = xgboost .Booster
302
299
attrs = {"save_config.return_value" : json .dumps ({"test" : "passed" })}
@@ -306,6 +303,7 @@ def test_xgboost(self):
306
303
assert Path (Path (tmp_dir .name ) / f"./prefixHyperparameters.json" ).exists ()
307
304
308
305
def test_xgboost_sklearn (self ):
306
+ xgboost = pytest .importorskip ("xgboost" )
309
307
model = unittest .mock .Mock ()
310
308
model .__class__ = xgboost .XGBModel
311
309
attrs = {"get_params.return_value" : json .dumps ({"test" : "passed" })}
@@ -315,6 +313,7 @@ def test_xgboost_sklearn(self):
315
313
assert Path (Path (tmp_dir .name ) / f"./prefixHyperparameters.json" ).exists ()
316
314
317
315
def test_h2o (self ):
316
+ h2o = pytest .importorskip ("h2o" )
318
317
model = unittest .mock .Mock ()
319
318
model .__class__ = h2o .H2OFrame
320
319
attrs = {"get_params.return_value" : json .dumps ({"test" : "passed" })}
@@ -324,6 +323,7 @@ def test_h2o(self):
324
323
assert Path (Path (tmp_dir .name ) / f"./prefixHyperparameters.json" ).exists ()
325
324
326
325
def test_tensorflow (self ):
326
+ tf = pytest .importorskip ("tensorflow" )
327
327
model = unittest .mock .Mock ()
328
328
model .__class__ = tf .keras .Sequential
329
329
attrs = {"get_config.return_value" : json .dumps ({"test" : "passed" })}
@@ -333,6 +333,7 @@ def test_tensorflow(self):
333
333
assert Path (Path (tmp_dir .name ) / f"./prefixHyperparameters.json" ).exists ()
334
334
335
335
def test_statsmodels (self ):
336
+ smf = pytest .importorskip ("statsmodels.formula.api" )
336
337
model = unittest .mock .Mock (
337
338
exog_names = ["test" , "exog" ], weights = np .array ([0 , 1 ])
338
339
)
0 commit comments