예제 #1
0
 def runner(self):
     self.root.setup()  # Loading configuration (if exists)
     db_url = self.root.db_url
     dir_plot = self.args.directory
     config = yaml.load(self.args.config)
     db_engine = create_engine(db_url)
     return AuditionRunner(config, db_engine, dir_plot)
예제 #2
0
def test_Audition():
    with testing.postgresql.Postgresql() as postgresql:
        db_engine = create_engine(postgresql.url())
        ensure_db(db_engine)
        init_engine(db_engine)

        num_model_groups = 10
        model_types = [
            "classifier type {}".format(i) for i in range(0, num_model_groups)
        ]
        model_groups = [
            ModelGroupFactory(model_type=model_type)
            for model_type in model_types
        ]
        train_end_times = [
            datetime(2013, 1, 1),
            datetime(2014, 1, 1),
            datetime(2015, 1, 1),
            datetime(2016, 1, 1),
        ]

        models = [
            ModelFactory(model_group_rel=model_group,
                         train_end_time=train_end_time)
            for model_group in model_groups
            for train_end_time in train_end_times
        ]
        metrics = [
            ("precision@", "100_abs"),
            ("recall@", "100_abs"),
            ("precision@", "50_abs"),
            ("recall@", "50_abs"),
            ("fpr@", "10_pct"),
        ]

        class ImmediateEvalFactory(EvaluationFactory):
            evaluation_start_time = factory.LazyAttribute(
                lambda o: o.model_rel.train_end_time)

        for model in models:
            for (metric, parameter) in metrics:
                ImmediateEvalFactory(model_rel=model,
                                     metric=metric,
                                     parameter=parameter)

        session.commit()

        with tempfile.TemporaryDirectory() as td:
            with mock.patch('os.getcwd') as mock_getcwd:
                mock_getcwd.return_value = td
                AuditionRunner(config_dict=config,
                               db_engine=db_engine,
                               directory=td).run()
                assert len(os.listdir(os.getcwd())) == 6
예제 #3
0
파일: cli.py 프로젝트: leegudala/triage
 def runner(self):
     db_url = self.root.db_url
     dir_plot = self.args.directory
     config = yaml.load(self.args.config)
     db_engine = create_engine(db_url)
     return AuditionRunner(config, db_engine, dir_plot)