def test_load_model(self): standardizer = Standardizer(name='TestStandardizer') standardizer.load(self.base_path) h5py.File.assert_called_once_with(os.path.join(self.base_path, 'processors/TestStandardizer.h5'), 'r') pickle.loads.assert_called_once_with('Model') self.assertEquals('Model', standardizer._model)
def test_save_model(self): standardizer = Standardizer(name='TestStandardizer') standardizer.save(self.base_path) h5py.File.assert_called_once_with(os.path.join(self.base_path, 'processors/TestStandardizer.h5'), 'w') self.h5f.create_dataset.assert_called_once_with('data', data=np.array('Model dump'))
def test_fit_method(self): standardizer = Standardizer() standardizer.fit(self.X) StandardScaler.fit.assert_called_once_with(self.X['features']) self.assertNotEquals(standardizer._model, None)
def test_fit_run(self): standardizer = Standardizer() Y = standardizer.fit_run(self.X) np.testing.assert_array_equal(StandardScaler.fit.call_args[0][0], self.features) np.testing.assert_array_equal(StandardScaler.transform.call_args[0][0], self.features) self.assertNotEquals(standardizer._model, None) np.testing.assert_equal(Y['features'], [[0, 1], [2, 3]])
def test_describe(self): description = Standardizer(name='test_standardizer').__str__() self.assertEquals(description, '{\'type\': \'Standard Scaler\', \'name\': \'test_standardizer\'}')
def test_run(self): standardizer = Standardizer() Y = standardizer.run(self.X) np.testing.assert_array_equal(StandardScaler.transform.call_args[0][0], self.features) np.testing.assert_equal(Y['features'], [[0, 1], [2, 3]])
def test_constructor_calls_sklearn_constructor(self): Standardizer() StandardScaler.__init__.assert_called_once()