Exemplo n.º 1
0
 def test_parse_args_rejects_invalid_arguments(self, invalid_arg_set):
     rgx_anything_but_zero = r'[^0]'
     with self.assertRaisesRegex(
             SystemExit, rgx_anything_but_zero,
             msg='Executing _parse_args on a set of invalid args should raise SystemExit with a non-zero exit code.'
     ):
         main._parse_args(invalid_arg_set)
Exemplo n.º 2
0
 def test_parse_args_accepts_valid_arguments(self, valid_arg_set):
     try:
         main._parse_args(
             valid_arg_set)  # Test succeeds if no exception is raised.
     except SystemExit as ex:
         if ex.code != 0:  # Test also succeeds if SystemExit is raised with "successful" exit code of 0.
             raise
Exemplo n.º 3
0
 def test_parse_args_rejects_invalid_arguments(self, invalid_arg_set):
     rgx_anything_but_zero = r'[^0]'
     with self.assertRaisesRegex(
             SystemExit,
             rgx_anything_but_zero,
             msg=
             'Executing _parse_args on a set of invalid args should raise SystemExit with a non-zero exit code.'
     ):
         main._parse_args(invalid_arg_set)
Exemplo n.º 4
0
 def test_parsing_export(self) -> None:
     args = main._parse_args("export".split(" "))
     assert args
Exemplo n.º 5
0
 def test_parsing_remove(self) -> None:
     args = main._parse_args("remove domain.com".split(" "))
     assert args
Exemplo n.º 6
0
 def test_parsing_add(self) -> None:
     args = main._parse_args("add domain.com".split(" "))
     assert args
Exemplo n.º 7
0
            for feat1 in range(len(new_features)):
                for feat2 in range(len(old_features)):

                    # fs = features.FEATURES[(da, db)]
                    fs = (new_features[feat1][1], old_features[feat2][1])
                    X2 = [(fs[0](x), fs[1](x)) for x in X]

                    cls = sklearn.linear_model.LogisticRegression(
                        solver='liblinear')
                    cls.fit(X2, Y)

                    result = cls.score(X2, Y)
                    logging.info('{} and {}: {:.1f}%'.format(
                        new_features[feat1][0], old_features[feat2][0],
                        result * 100))
                    if result > results[(da, db)]["accuracy"]:
                        results[(da, db)]["accuracy"] = result
                        results[(da,
                                 db)]["features"] = (new_features[feat1][1],
                                                     old_features[feat2][1])

    write_best_features_txt_pickle(results, cases)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO, format='%(message)s')
    searching_best_features(main._parse_args())
    # a = read_latest_best_features_pickle()
    # print(a[(5,8)]["features"][0].__name__)

    # print(old_features)
Exemplo n.º 8
0
 def test_parse_args_accepts_valid_arguments(self, valid_arg_set):
     try:
         main._parse_args(valid_arg_set)  # Test succeeds if no exception is raised.
     except SystemExit as ex:
         if ex.code != 0:  # Test also succeeds if SystemExit is raised with "successful" exit code of 0.
             raise