Beispiel #1
0
def run_train(
    forecaster: Estimator,
    train_dataset: Dataset,
    hyperparameters: dict,
    validation_dataset: Optional[Dataset],
) -> Predictor:
    num_workers = (
        int(hyperparameters["num_workers"])
        if "num_workers" in hyperparameters.keys()
        else None
    )
    shuffle_buffer_length = (
        int(hyperparameters["shuffle_buffer_length"])
        if "shuffle_buffer_length" in hyperparameters.keys()
        else None
    )
    num_prefetch = (
        int(hyperparameters["num_prefetch"])
        if "num_prefetch" in hyperparameters.keys()
        else None
    )
    if isinstance(forecaster, GluonEstimator):
        return forecaster.train(
            training_data=train_dataset,
            validation_data=validation_dataset,
            num_workers=num_workers,
            num_prefetch=num_prefetch,
            shuffle_buffer_length=shuffle_buffer_length,
        )
    else:
        return forecaster.train(
            training_data=train_dataset, validation_data=validation_dataset,
        )
def test_item_id_info(dataset: Dataset, estimator: Estimator):
    predictor = estimator.train(dataset)
    forecasts = predictor.predict(dataset)
    for data_entry, forecast in zip(dataset, forecasts):
        assert (not "item_id"
                in data_entry) or data_entry["item_id"] == forecast.item_id
        assert (not "info"
                in data_entry) or data_entry["info"] == forecast.info
Beispiel #3
0
def run_train(
    forecaster: Estimator,
    train_dataset: Dataset,
    validation_dataset: Optional[Dataset],
) -> Predictor:
    log.metric("train_dataset_stats", train_dataset.calc_stats())

    return forecaster.train(train_dataset, validation_dataset)
Beispiel #4
0
def run_train(
    forecaster: Estimator,
    train_dataset: Dataset,
    validation_dataset: Optional[Dataset],
) -> Predictor:
    return forecaster.train(
        training_data=train_dataset, validation_data=validation_dataset
    )