Esempio n. 1
0
def train(config, train_data, validation_data, artifact_dir):
    """Barrage deep learning train.

    Supported filetypes:

        1. .csv

        2. .json

    Args:

        config: filepath to barrage config [REQUIRED].

        train-data: filepath to train data [REQUIRED].

        validation-data: filepath to validation data [REQUIRED].

    Note: artifact-dir cannot already exist.
    """
    cfg = io_utils.load_json(config)
    records_train = io_utils.load_data(train_data)
    records_validation = io_utils.load_data(train_data)
    BarrageModel(artifact_dir).train(cfg, records_train, records_validation)
Esempio n. 2
0
def predict(score_data, artifact_dir, output):
    """Barrage deep learning predict.

    Supported filetypes:

        1. .csv

        2. .json

    Args:

        score-data: filepath to score data [REQUIRED].

        artifact-dir: location to load artifacts [REQUIRED].
    """
    records_score = io_utils.load_data(score_data)
    scores = BarrageModel(artifact_dir).predict(records_score)
    io_utils.save_json(scores, output)
Esempio n. 3
0
def test_load_data(artifact_path, sample_dict):
    expected = pd.DataFrame([sample_dict])

    expected.to_json(os.path.join(artifact_path, "unit_test.json"))
    result = io_utils.load_data("unit_test.json", artifact_path)
    assert result.equals(expected)

    expected.to_csv(os.path.join(artifact_path, "unit_test.csv"), index=False)
    result = io_utils.load_data("unit_test.csv", artifact_path)
    assert result.equals(expected)

    with pytest.raises(FileNotFoundError):
        io_utils.load_data("test_unit.42", artifact_path)

    expected.to_json(os.path.join(artifact_path, "unit_test.foo"))
    with pytest.raises(ValueError):
        io_utils.load_data("unit_test.foo", artifact_path)