Exemplo n.º 1
0
def test_hyperparameter_tuning_job_kwargs(model):
    job = HyperparameterTuningJob(
        model=model,
        identifier="job1",
        data={
            "estimator": "tests.resources.estimators.DummyEstimator",
            "max_jobs": 10,
            "max_parallel_jobs": 4,
            "objective_type": "Maximize",
        },
    )

    job.run()
    assert job.estimator.kwargs["max_jobs"] == 10
    assert job.estimator.kwargs["max_parallel_jobs"] == 4
    assert job.estimator.kwargs["objective_type"] == "Maximize"
Exemplo n.º 2
0
def test_job_invalid_estimator(estimator):
    model = Model("model1", data={})
    with pytest.raises(DescriptorError):
        HyperparameterTuningJob(
            model=model,
            identifier="job1",
            data={
                "estimator": estimator,
                "hyperparameters": {
                    "hp1": 123
                },
            },
        )
Exemplo n.º 3
0
def test_hyperparameter_ranges_missing_parameter_type(model):
    with pytest.raises(DescriptorError):
        HyperparameterTuningJob(
            model=model,
            identifier="job1",
            data={
                "estimator": "tests.resources.estimators.DummyEstimator",
                "hyperparameter_ranges": {
                    "property1": {
                        "values": [1.0, 2.0]
                    },
                },
            },
        )
Exemplo n.º 4
0
def test_job_estimator():
    model = Model("model1", data={})
    job = HyperparameterTuningJob(
        model=model,
        identifier="job1",
        data={
            "estimator": "tests.resources.estimators.DummyEstimator",
            "hyperparameters": {
                "hp1": 123
            },
        },
    )

    assert job.estimator.model == "model1"
    assert job.estimator.job == "job1"
    assert job.estimator.hyperparameters["hp1"] == 123
Exemplo n.º 5
0
    def __init__(self, name: str, data: dict()) -> None:
        self.name = name
        self.data = data
        self.jobs = dict()

        self._load_jobs(
            self.data,
            "training-jobs",
            lambda model, identifier, data: TrainingJob(model, identifier, data),
        )

        self._load_jobs(
            self.data,
            "hyperparameter-tuning-jobs",
            lambda model, identifier, data: HyperparameterTuningJob(
                model, identifier, data
            ),
        )
Exemplo n.º 6
0
def hyperparameter_tuning_job(model):
    return HyperparameterTuningJob(
        model=model,
        identifier="job1",
        data={
            "estimator": "tests.resources.estimators.DummyEstimator",
            "hyperparameter_ranges": {
                "property1": {
                    "type": "categorical",
                    "values": [1.0, 2.0]
                },
                "property2": {
                    "type": "integer",
                    "min_value": 1.0,
                    "max_value": 2.0
                },
                "property3": {
                    "type": "continuous",
                    "min_value": 3.0,
                    "max_value": 4.0
                },
            },
        },
    )