Esempio n. 1
0
class TestGreenGuardPipeline(TestCase):
    """Tests for `TimeSeriesClassifier`."""

    PIPELINE_NAME = find_pipelines()[0]

    @patch('greenguard.pipeline.MLPipeline')
    def test_fit(self, pipeline_class_mock):
        """fit prepare the pipeline to make predictions based on the given data."""
        # Run
        instance = GreenGuardPipeline(self.PIPELINE_NAME, 'accuracy')
        instance.fit('an_X', 'a_y', 'readings')

        # Asserts
        pipeline_mock = pipeline_class_mock.return_value
        pipeline_class_mock.assert_called_once_with(
            load_pipeline(self.PIPELINE_NAME))
        assert instance._pipeline == pipeline_mock

        pipeline_mock.fit.assert_called_once_with('an_X',
                                                  'a_y',
                                                  readings='readings')

        assert instance.fitted

    @patch('greenguard.pipeline.MLPipeline')
    def test_predict(self, pipeline_mock):
        """predict produces results using the pipeline."""
        # Run
        instance = GreenGuardPipeline(self.PIPELINE_NAME, 'accuracy')
        instance.fitted = True
        instance.predict('an_X', 'readings')

        # Asserts
        pipeline_mock.return_value.predict.assert_called_once_with(
            'an_X', readings='readings')
Esempio n. 2
0
def test_find_pipelines(gpp_mock, fa_mock):
    primitives = discovery.find_pipelines('pattern', {'a': 'filter'})

    fa_mock.assert_called_once_with(gpp_mock.return_value,
                                    discovery.load_pipeline, 'pattern',
                                    {'a': 'filter'})

    assert primitives == fa_mock.return_value
Esempio n. 3
0
def get_pipelines():
    """Get a list of the available datatracer pipelines.

    Returns:
        list:
            List of the names of the available datatracer pipelines.
    """
    return discovery.find_pipelines('datatracer')