def test_trainer_dataframe():
    session = create_sagemaker_session(describe_training_result=_describe_training_result(),
                                       metric_stats_results=_metric_stats_results())
    trainer = TrainingJobAnalytics("my-training-job", ["train:acc"], sagemaker_session=session)

    df = trainer.dataframe()
    assert df is not None
    assert len(df) == 3
    assert min(df['value']) == 77.1
    assert max(df['value']) == 97.1

    # Export to CSV and check that file exists
    tmp_name = "/tmp/unit-test-%s.csv" % uuid.uuid4()
    assert not os.path.isfile(tmp_name)
    trainer.export_csv(tmp_name)
    assert os.path.isfile(tmp_name)
    os.unlink(tmp_name)
Exemplo n.º 2
0
def test_trainer_dataframe():
    describe_training_result = {
        'TrainingStartTime': datetime.datetime(2018, 5, 16, 1, 2, 3),
        'TrainingEndTime': datetime.datetime(2018, 5, 16, 5, 6, 7),
    }
    metric_stats_results = {
        'Datapoints': [
            {
                'Average': 77.1,
                'Timestamp': datetime.datetime(2018, 5, 16, 1, 3, 3),
            },
            {
                'Average': 87.1,
                'Timestamp': datetime.datetime(2018, 5, 16, 1, 8, 3),
            },
            {
                'Average': 97.1,
                'Timestamp': datetime.datetime(2018, 5, 16, 2, 3, 3),
            },
        ]
    }
    session = sagemaker_session(
        describe_training_result=describe_training_result,
        metric_stats_results=metric_stats_results)
    trainer = TrainingJobAnalytics("my-training-job", ["train:acc"],
                                   sagemaker_session=session)

    df = trainer.dataframe()
    assert df is not None
    assert len(df) == 3
    assert min(df['value']) == 77.1
    assert max(df['value']) == 97.1

    # Export to CSV and check that file exists
    tmp_name = "/tmp/unit-test-%s.csv" % uuid.uuid4()
    assert not os.path.isfile(tmp_name)
    trainer.export_csv(tmp_name)
    assert os.path.isfile(tmp_name)
    os.unlink(tmp_name)