Example #1
0
    def test_scenario6(self):
        """
            Scenario: Successfully extending the multi-label source file:
                Given I create BigML a multi-label source with "<label_separator>" label separator and <number_of_labels> labels from train "<data>" file with "<training_separator>" field separator and "<ml_fields>" as multi-label fields and objective "<objective>" and output in "<output_dir>"
                And I check that the source has been created
                Then I check the extended file "<local_file>" has been created
                And the headers of the local extended file are "<headers>"
                And the first row of the local extended file is "<first_row>"

                Examples:
                |label_separator |number_of_labels | data                   |training_separator | ml_fields | objective | output_dir                        |local_file         | headers | first_row |
                |:|7| ../data/multilabel_multi.csv |,  | type,class | class | ./scenario_mlm_6 | ./scenario_mlm_6/extended_multilabel_multi.csv |color,year,price,first_name,last_name,sex,class,type,class - Adult,class - Child,class - Pensioner,class - Retired,class - Student,class - Teenager,class - Worker,type - A,type - C,type - P,type - R,type - S,type - T,type - W | Blue,1992,"1208,6988040134",John,Higgins,Male,Worker:Adult,W:A:C:S:T:R:P,1,0,0,0,0,0,1,1,1,1,1,1,1,1
                |:|7| ../data/multilabel_multi2.csv |,  | Colors,Movies,Hobbies | Hobbies | ./scenario_mlm_7 | ./scenario_mlm_7/extended_multilabel_multi2.csv |Registration Date,Age Range,Gender,Height,Weight,Points,Colors,Movies,Hobbies,Colors - Black,Colors - Blue,Colors - Green,Colors - Grey,Colors - Orange,Colors - Pink,Colors - Purple,Colors - Red,Colors - White,Colors - Yellow,Movies - Action,Movies - Adventure,Movies - Comedy,Movies - Crime,Movies - Erotica,Movies - Fantasy,Movies - Horror,Movies - Mystery,Movies - Philosophical,Movies - Political,Movies - Romance,Movies - Satire,Movies - Thriller,Hobbies - Barbacue,Hobbies - Books,Hobbies - Chat,Hobbies - Cooking,Hobbies - Dance,Hobbies - Disco,Hobbies - Dolls,Hobbies - Family,Hobbies - Films,Hobbies - Fishing,Hobbies - Friends,Hobbies - Jogging,Hobbies - Music,Hobbies - Soccer,Hobbies - Toys,Hobbies - Travel,Hobbies - Videogames,Hobbies - Walking |2011-02-06,19-30,Female,140,47,11,White:Red,Comedy:Romance,Friends:Music,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0
        """
        print self.test_scenario6.__doc__
        examples = [
            [':', '7', 'data/multilabel_multi.csv', ',', 'type,class', 'class', 'scenario_mlm_6', 'scenario_mlm_6/extended_multilabel_multi.csv', 'color,year,price,first_name,last_name,sex,class,type,class - Adult,class - Child,class - Pensioner,class - Retired,class - Student,class - Teenager,class - Worker,type - A,type - C,type - P,type - R,type - S,type - T,type - W', 'Blue,1992,"1208,6988040134",John,Higgins,Male,Worker:Adult,W:A:C:S:T:R:P,1,0,0,0,0,0,1,1,1,1,1,1,1,1'],
            [':', '7', 'data/multilabel_multi2.csv', ',', 'Colors,Movies,Hobbies', 'Hobbies', 'scenario_mlm_7', 'scenario_mlm_7/extended_multilabel_multi2.csv', 'Registration Date,Age Range,Gender,Height,Weight,Points,Colors,Movies,Hobbies,Colors - Black,Colors - Blue,Colors - Green,Colors - Grey,Colors - Orange,Colors - Pink,Colors - Purple,Colors - Red,Colors - White,Colors - Yellow,Movies - Action,Movies - Adventure,Movies - Comedy,Movies - Crime,Movies - Erotica,Movies - Fantasy,Movies - Horror,Movies - Mystery,Movies - Philosophical,Movies - Political,Movies - Romance,Movies - Satire,Movies - Thriller,Hobbies - Barbacue,Hobbies - Books,Hobbies - Chat,Hobbies - Cooking,Hobbies - Dance,Hobbies - Disco,Hobbies - Dolls,Hobbies - Family,Hobbies - Films,Hobbies - Fishing,Hobbies - Friends,Hobbies - Jogging,Hobbies - Music,Hobbies - Soccer,Hobbies - Toys,Hobbies - Travel,Hobbies - Videogames,Hobbies - Walking', '2011-02-06,19-30,Female,140,47,11,White:Red,Comedy:Romance,Friends:Music,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0']
]
        for example in examples:
            print "\nTesting with:\n", example
            ml_pred.i_create_ml_source(self, label_separator=example[0], number_of_labels=example[1], data=example[2], training_separator=example[3], multi_label_fields=example[4], objective=example[5], output_dir=example[6])
            test_pred.i_check_create_source(self)
            ml_pred.i_check_local_file(self, path=example[7])
            ml_pred.i_check_headers_file(self, headers=example[8])
            ml_pred.i_check_first_row_file(self, first_row=example[9])
Example #2
0
    def test_scenario6(self):
        """
            Scenario: Successfully extending the multi-label source file:
                Given I create BigML a multi-label source with "<label_separator>" label separator and <number_of_labels> labels from train "<data>" file with "<training_separator>" field separator and "<ml_fields>" as multi-label fields and objective "<objective>" and output in "<output_dir>"
                And I check that the source has been created
                Then I check the extended file "<local_file>" has been created
                And the headers of the local extended file are "<headers>"
                And the first row of the local extended file is "<first_row>"

                Examples:
                |label_separator |number_of_labels | data                   |training_separator | ml_fields | objective | output_dir                        |local_file         | headers | first_row |
                |:|7| ../data/multilabel_multi.csv |,  | type,class | class | ./scenario_mlm_6 | ./scenario_mlm_6/extended_multilabel_multi.csv |color,year,price,first_name,last_name,sex,class,type,class - Adult,class - Child,class - Pensioner,class - Retired,class - Student,class - Teenager,class - Worker,type - A,type - C,type - P,type - R,type - S,type - T,type - W | Blue,1992,"1208,6988040134",John,Higgins,Male,Worker:Adult,W:A:C:S:T:R:P,1,0,0,0,0,0,1,1,1,1,1,1,1,1
                |:|7| ../data/multilabel_multi2.csv |,  | Colors,Movies,Hobbies | Hobbies | ./scenario_mlm_7 | ./scenario_mlm_7/extended_multilabel_multi2.csv |Registration Date,Age Range,Gender,Height,Weight,Points,Colors,Movies,Hobbies,Colors - Black,Colors - Blue,Colors - Green,Colors - Grey,Colors - Orange,Colors - Pink,Colors - Purple,Colors - Red,Colors - White,Colors - Yellow,Movies - Action,Movies - Adventure,Movies - Comedy,Movies - Crime,Movies - Erotica,Movies - Fantasy,Movies - Horror,Movies - Mystery,Movies - Philosophical,Movies - Political,Movies - Romance,Movies - Satire,Movies - Thriller,Hobbies - Barbacue,Hobbies - Books,Hobbies - Chat,Hobbies - Cooking,Hobbies - Dance,Hobbies - Disco,Hobbies - Dolls,Hobbies - Family,Hobbies - Films,Hobbies - Fishing,Hobbies - Friends,Hobbies - Jogging,Hobbies - Music,Hobbies - Soccer,Hobbies - Toys,Hobbies - Travel,Hobbies - Videogames,Hobbies - Walking |2011-02-06,19-30,Female,140,47,11,White:Red,Comedy:Romance,Friends:Music,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0
        """
        print self.test_scenario6.__doc__
        examples = [
            [':', '7', 'data/multilabel_multi.csv', ',', 'type,class', 'class', 'scenario_mlm_6', 'scenario_mlm_6/extended_multilabel_multi.csv', 'color,year,price,first_name,last_name,sex,class,type,class - Adult,class - Child,class - Pensioner,class - Retired,class - Student,class - Teenager,class - Worker,type - A,type - C,type - P,type - R,type - S,type - T,type - W', 'Blue,1992,"1208,6988040134",John,Higgins,Male,Worker:Adult,W:A:C:S:T:R:P,1,0,0,0,0,0,1,1,1,1,1,1,1,1'],
            [':', '7', 'data/multilabel_multi2.csv', ',', 'Colors,Movies,Hobbies', 'Hobbies', 'scenario_mlm_7', 'scenario_mlm_7/extended_multilabel_multi2.csv', 'Registration Date,Age Range,Gender,Height,Weight,Points,Colors,Movies,Hobbies,Colors - Black,Colors - Blue,Colors - Green,Colors - Grey,Colors - Orange,Colors - Pink,Colors - Purple,Colors - Red,Colors - White,Colors - Yellow,Movies - Action,Movies - Adventure,Movies - Comedy,Movies - Crime,Movies - Erotica,Movies - Fantasy,Movies - Horror,Movies - Mystery,Movies - Philosophical,Movies - Political,Movies - Romance,Movies - Satire,Movies - Thriller,Hobbies - Barbacue,Hobbies - Books,Hobbies - Chat,Hobbies - Cooking,Hobbies - Dance,Hobbies - Disco,Hobbies - Dolls,Hobbies - Family,Hobbies - Films,Hobbies - Fishing,Hobbies - Friends,Hobbies - Jogging,Hobbies - Music,Hobbies - Soccer,Hobbies - Toys,Hobbies - Travel,Hobbies - Videogames,Hobbies - Walking', '2011-02-06,19-30,Female,140,47,11,White:Red,Comedy:Romance,Friends:Music,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0']
]
        for example in examples:
            print "\nTesting with:\n", example
            ml_pred.i_create_ml_source(self, label_separator=example[0], number_of_labels=example[1], data=example[2], training_separator=example[3], multi_label_fields=example[4], objective=example[5], output_dir=example[6])
            test_pred.i_check_create_source(self)
            ml_pred.i_check_local_file(self, path=example[7])
            ml_pred.i_check_headers_file(self, headers=example[8])
            ml_pred.i_check_first_row_file(self, first_row=example[9])