Example #1
0
    def test_scenario2(self):
        """
            Scenario: Successfully creating a projection:
                Given I create a data source uploading a "<data>" file
                And I wait until the source is ready less than <time_1> secs
                And I create a dataset
                And I wait until the dataset is ready less than <time_2> secs
                And I create a pca
                And I wait until the pca is ready less than <time_3> secs
                When I create a projection for "<data_input>"
                Then the projection is "<projection>"

                Examples:
                | data                | time_1  | time_2 | time_3 | data_input    | projection  |
                | ../data/iris.csv | 10      | 10     | 10     | {"petal width": 0.5} | '{"PC-0": 0.46547, "PC-1": 0.13724, "PC-2": -0.01666, "PC-3": 3.28995, "PC-4": 4.60383, "PC-5": 2.22108}' |
        """
        print self.test_scenario2.__doc__
        examples = [
            ['data/iris.csv', '30', '30', '30', '{"petal width": 0.5}', '{"PC2": 0.1593, "PC3": -0.01286, "PC1": 0.91648, "PC6": 0.27284, "PC4": 1.29255, "PC5": 0.75196}']]
        for example in examples:
            print "\nTesting with:\n", example
            source_create.i_upload_a_file(self, example[0])
            source_create.the_source_is_finished(self, example[1])
            dataset_create.i_create_a_dataset(self)
            dataset_create.the_dataset_is_finished_in_less_than(self, example[2])
            pca_create.i_create_a_pca(self)
            pca_create.the_pca_is_finished_in_less_than(self, example[3])
            projection_create.i_create_a_projection(self, example[4])
            projection_create.the_projection_is(self, example[5])

        print "\nEnd of tests in: %s\n-------------------\n" % __name__
Example #2
0
    def test_scenario3(self):
        """
            Scenario: Successfully creating a batch projection:
                Given I create a data source uploading a "<data>" file
                And I wait until the source is ready less than <time_1> secs
                And I create a dataset
                And I wait until the dataset is ready less than <time_2> secs
                And I create a pca
                And I wait until the pca is ready less than <time_3> secs
                When I create a batch projection for the dataset with the pca
                And I wait until the batch projection is ready less than <time_4> secs
                And I download the created projections file to "<local_file>"
                Then the batch projection file is like "<projections_file>"

                Examples:
                | data             | time_1  | time_2 | time_3 | time_4 | local_file | predictions_file       |
                | ../data/iris.csv | 30      | 30     | 50     | 50     | ./tmp/batch_projections.csv |./data/batch_projections.csv |

        """
        print self.test_scenario3.__doc__
        examples = [
            ['data/iris.csv', '30', '30', '50', '50', 'tmp/batch_projections.csv', 'data/batch_projections.csv']]
        for example in examples:
            print "\nTesting with:\n", example
            source_create.i_upload_a_file(self, example[0])
            source_create.the_source_is_finished(self, example[1])
            dataset_create.i_create_a_dataset(self)
            dataset_create.the_dataset_is_finished_in_less_than(self, example[2])
            pca_create.i_create_a_pca(self)
            pca_create.the_pca_is_finished_in_less_than(self, example[3])
            batch_proj_create.i_create_a_batch_projection(self)
            batch_proj_create.the_batch_projection_is_finished_in_less_than(self, example[4])
            batch_proj_create.i_download_projections_file(self, example[5])
            batch_proj_create.i_check_projections(self, example[6])
Example #3
0
    def test_scenario7(self):
        """
            Scenario: Successfully comparing remote and local predictions
                      with raw date input for PCAs:
                Given I create a data source uploading a "<data>" file
                And I wait until the source is ready less than <time_1> secs
                And I create a dataset
                And I wait until the dataset is ready less than <time_2> secs
                And I create a PC
                And I wait until the PCA is ready less than <time_3> secs
                And I create a local PCA
                When I create a projection for "<input_data>"
                Then the projection is "<projection>"
                And I create a local projection for "<data_input>"
                Then the local projection is "<projection>"

                Examples:
                | data | time_1  | time_2 | time_3 | input_data | projection


        """
        examples = [
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"1910-05-08T19:10:23.106","cat-0":"cat2","target-2":0.4}',
                '{"PC8": -1.54293, "PC9": -0.94836, "PC2": 0.78176, "PC3": -0.62082,\
              "PC1": 0.89614, "PC10": 1.06575, "PC11": 1.3211, "PC4": 1.90088, \
              "PC5": 0.24197, "PC7": -0.37701, "PC6": 2.25007}'
            ],
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"1920-06-30T20:21:20.320","cat-0":"cat1","target-2":0.2}',
                '{"PC8": 0.3148, "PC9": -0.61742, "PC2": 0.93411, "PC3": 1.80286,\
               "PC1": 0.36425, "PC10": 0.7364, "PC11": 2.25863, "PC4": -1.50319,\
               "PC5": 0.17088, "PC7": 0.51738, "PC6": 0.42403}'
            ],
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"1932-01-30T19:24:11.440","cat-0":"cat2","target-2":0.1}',
                '{"PC8": -0.86728, "PC9": -1.85164, "PC2": 2.13206, "PC3": 0.58449,\
               "PC1": 0.28379, "PC10": 2.05465, "PC11": 0.44372, "PC4": 1.27236,\
               "PC5": 0.99468, "PC7": -0.32496, "PC6": 0.52217}'
            ],
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"1950-11-06T05:34:05.602","cat-0":"cat1" ,"target-2":0.9}',
                '{"PC8": 2.49563, "PC9": -0.57774, "PC2": -0.76354, "PC3": 0.19215,\
               "PC1": 0.99197, "PC10": -1.21017, "PC11": 1.55778, "PC4": -0.24013,\
               "PC5": -0.38492, "PC7": 1.82607, "PC6": 0.3736}'
            ],
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"1969-7-14 17:36","cat-0":"cat2","target-2":0.9}',
                '{"PC8": -0.41111, "PC9": -5.32959, "PC2": -1.25322, "PC3": 2.93113,\
               "PC1": 2.07444, "PC10": 4.8808, "PC11": 0.4185, "PC4": 3.13876,\
               "PC5": 3.70259, "PC7": 0.55665, "PC6": 5.16873}'
            ],
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"2001-01-05T23:04:04.693","cat-0":"cat2","target-2":0.01}',
                '{"PC8": -1.10654, "PC9": -0.34137, "PC2": 1.73362, "PC3": -0.34799,\
               "PC1": 2.32583, "PC10": 0.94566, "PC11": 0.53787, "PC4": 2.77385,\
               "PC5": -0.1017, "PC7": 0.20156, "PC6": -0.44476}'
            ],
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"2011-04-01T00:16:45.747","cat-0":"cat2","target-2":0.32}',
                '{"PC8": -0.514, "PC9": 0.38349, "PC2": -0.27037, "PC3": -1.82588,\
               "PC1": 1.05737, "PC10": 0.08607, "PC11": -0.97078, "PC4": 2.10426,\
               "PC5": 1.86843, "PC7": 1.55632, "PC6": 0.42395}'
            ],
            [
                'data/dates2.csv', '20', '30', '60',
                '{"time-1":"1969-W29-1T17:36:39Z","cat-0":"cat1","target-2":0.87}',
                '{"PC8": 2.05525, "PC9": 1.50754, "PC2": 6.27524, "PC3": 7.74224,\
               "PC1": 5.30354, "PC10": -6.40442, "PC11": 6.90365, "PC4": -1.44431,\
               "PC5": 2.16179, "PC7": 1.35718, "PC6": 5.02426}'
            ]
        ]
        show_doc(self.test_scenario7, examples)
        for example in examples:
            print "\nTesting with:\n", example
            source_create.i_upload_a_file(self, example[0])
            source_create.the_source_is_finished(self, example[1])
            dataset_create.i_create_a_dataset(self)
            dataset_create.the_dataset_is_finished_in_less_than(
                self, example[2])
            pca_create.i_create_a_pca(self)
            pca_create.the_pca_is_finished_in_less_than(self, example[3])
            projection_create.i_create_a_projection(self, example[4])
            projection_create.the_projection_is(self, example[5])
            compare_predictions.create_local_pca(self)
            compare_predictions.i_create_a_local_projection(self, example[4])
            compare_predictions.the_local_projection_is(self, example[5])