Created
December 31, 2019 18:21
-
-
Save korkridake/b53de425960de1f2303a8feb12853f5f to your computer and use it in GitHub Desktop.
AWS SageMaker Estimators (https://sagemaker.readthedocs.io/en/stable/estimators.html)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################################### | |
# Initatiate the Session | |
##################################################################################### | |
sess = sagemaker.Session() | |
##################################################################################### | |
# Ensure that you specify the right locations of the XGBoost algorithm containers | |
##################################################################################### | |
xgb = sagemaker.estimator.Estimator(container, | |
role, | |
train_instance_count=1, | |
train_instance_type='ml.m4.xlarge', | |
output_path='s3://{}/{}/output'.format(bucket, prefix), | |
sagemaker_session=sess) | |
##################################################################################### | |
# Specify a few parameters like what type of training instances we'd like to use and | |
# how many, as well as our XGBoost hyperparameters. | |
##################################################################################### | |
xgb.set_hyperparameters(max_depth=5, | |
eta=0.2, | |
gamma=4, | |
min_child_weight=6, | |
subsample=0.8, | |
silent=0, | |
objective='binary:logistic', | |
num_round=100) | |
#################################################################################### | |
# Run the Model | |
#################################################################################### | |
xgb.fit({'train': s3_input_train, 'validation': s3_input_validation}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment