Beispiel #1
0
    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)
Beispiel #2
0
    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'))
Beispiel #3
0
    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)
Beispiel #4
0
    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]])
Beispiel #5
0
 def test_describe(self):
     description = Standardizer(name='test_standardizer').__str__()
     self.assertEquals(description, '{\'type\': \'Standard Scaler\', \'name\': \'test_standardizer\'}')
Beispiel #6
0
 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]])
Beispiel #7
0
 def test_constructor_calls_sklearn_constructor(self):
     Standardizer()
     StandardScaler.__init__.assert_called_once()