def run_training():

    data = load_data(file_name='train_data.csv')
    X, y = resample_classes(data)
    pipeline.CHD_pipe.fit(X, y)
    _logger.info(f'saving model version: {_version}')
    save_pipeline(pipeline_to_save=pipeline.CHD_pipe)
def test_prediction_endpoint_val_200(flask_test_client):

    test_data = load_data(file_name=config.TEST_DATA)
    post_json = test_data.to_json(orient='records')

    response = flask_test_client.post('/v1/predict/log_reg',
                                      json=json.loads(post_json))

    assert response.status_code == 200
    response_json = json.loads(response.data)
    assert response_json.get('errors') is None
    assert len(response_json.get('predictions')) == 1
def test_prediction_endpoint(flask_test_client):

    test_data = load_data(file_name=model_config.TEST_DATA)
    post_json = test_data.to_json(orient='records')
    response = flask_test_client.post('/v1/predict/log_reg',
                                      json=json.loads(post_json))

    assert response.status_code == 200
    response_json = json.loads(response.data)
    prediction = response_json['predictions']
    response_version = response_json['version']
    assert isinstance(prediction[0][1], float)
    assert response_version == _version
def capture_predictions() -> None:
    """ Save test data predictions to .csv file"""

    new_dict = {}
    saved_file = 'test_predictions.csv'
    test_data = load_data(file_name='test_data.csv')
    predictions = make_prediction(input_data=test_data)
    array = predictions.get('predictions')[0]
    version = predictions.get('version')
    new_dict['predictions'] = array
    new_dict['version'] = version
    preds_df = pd.DataFrame(new_dict)

    #save the file into package repo
    preds_df.to_csv(f'{config.PACKAGE_ROOT}/{saved_file}', index=False)
Пример #5
0
def test_make_single_prediction():
    test_data = load_data(file_name='test_data.csv')
    subject = make_prediction(input_data=test_data)

    assert subject is not None
    assert isinstance(subject.get('predictions')[0], np.ndarray)