Skip to content

Commit 142ed7b

Browse files
committed
Updated: Changes based on tomfaulhaber@ comments
1 parent cb51269 commit 142ed7b

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

kmeans_bring_your_own_model/kmeans_bring_your_own_model.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"---\n",
2626
"## Background\n",
2727
"\n",
28-
"Amazon SageMaker includes functionality to support a hosted notebook environment, distributed, serverless training, and real-time, autoscaling hosting. We think it works best when all three of these services are used together, but they can also be used independently. Some use cases may only require hosting. Maybe the model was trained prior to Amazon SageMaker existing, in a different service.\n",
28+
"Amazon SageMaker includes functionality to support a hosted notebook environment, distributed, managed training, and real-time, autoscaling hosting. We think it works best when all three of these services are used together, but they can also be used independently. Some use cases may only require hosting. Maybe the model was trained prior to Amazon SageMaker existing, in a different service.\n",
2929
"\n",
3030
"This notebook shows how to use a pre-existing model with an Amazon SageMaker Algorithm container to quickly create a hosted endpoint for that model.\n",
3131
"\n",
@@ -34,9 +34,9 @@
3434
"\n",
3535
"Let's start by specifying:\n",
3636
"\n",
37-
"* AWS region.\n",
38-
"* The IAM role arn used to give learning and hosting access to your data. See the documentation for how to specify these.\n",
39-
"* The S3 bucket that you want to use for training and model data."
37+
"- AWS region.\n",
38+
"- The IAM role arn used to give learning and hosting access to your data. See the documentation for how to create these. Note, if more than one role is required for notebook instances, training, and/or hosting, please replace the boto call with a the appropriate full IAM role arn string.\n",
39+
"- The S3 bucket that you want to use for training and model data."
4040
]
4141
},
4242
{

linear_time_series_forecast/linear_time_series_forecast.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
"cell_type": "markdown",
385385
"metadata": {},
386386
"source": [
387-
"Now let's kick off our training job in SageMaker's distributed, serverless training, using the parameters we just created. Because training is serverless, we don't have to wait for our job to finish to continue, but for this case, let's setup a while loop so we can monitor the status of our training."
387+
"Now let's kick off our training job in SageMaker's distributed, managed training, using the parameters we just created. Because training is managed (AWS handles spinning up and spinning down hardware), we don't have to wait for our job to finish to continue, but for this case, let's setup a while loop so we can monitor the status of our training."
388388
]
389389
},
390390
{

pca_kmeans_movie_clustering/pca_kmeans_movie_clustering.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
"cell_type": "markdown",
350350
"metadata": {},
351351
"source": [
352-
"Now let's kick off our training job in SageMaker's distributed, serverless training, using the parameters we just created. Because training is serverless, we don't have to wait for our job to finish to continue, but for this case, let's setup a while loop so we can monitor the status of our training."
352+
"Now let's kick off our training job in SageMaker's distributed, managed training, using the parameters we just created. Because training is managed (AWS handles spinning up and spinning down the hardware), we don't have to wait for our job to finish to continue, but for this case, let's setup a while loop so we can monitor the status of our training."
353353
]
354354
},
355355
{
@@ -644,7 +644,7 @@
644644
"cell_type": "markdown",
645645
"metadata": {},
646646
"source": [
647-
"Now invoke EASE for serverless training."
647+
"Now invoke Amazon SageMaker for managed training."
648648
]
649649
},
650650
{

r_bring_your_own/mars.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ train <- function() {
2929

3030
target <- training_params$target
3131

32-
if (is.null(training_params$degree)) {
32+
if (!is.null(training_params$degree)) {
3333
degree <- as.numeric(training_params$degree)}
3434
else {
3535
degree <- 2}

r_bring_your_own/plumber.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function() {
77
list(status='200', code='200')}
88

99

10-
#' Echo the parameter that was sent in
10+
#' Parse input and return prediction from model
1111
#' @param req The http request sent
1212
#' @post /invocations
1313
function(req) {

r_bring_your_own/r_bring_your_own.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@
116116
" # Read in hyperparameters\n",
117117
" training_params <- read_json(param_path)\n",
118118
"\n",
119-
" target <- training_params$target\n",
119+
" target <- training_params\$target\n",
120120
"\n",
121-
" if (is.null(training_params$degree)) {\n",
122-
" degree <- as.numeric(training_params$degree)}\n",
121+
" if (!is.null(training_params\$degree)) {\n",
122+
" degree <- as.numeric(training_params\$degree)}\n",
123123
" else {\n",
124124
" degree <- 2}\n",
125125
"\n",
@@ -139,11 +139,11 @@
139139
" \n",
140140
" # Generate outputs\n",
141141
" mars_model <- model[!(names(model) %in% c('x', 'residuals', 'fitted.values'))]\n",
142-
" attributes(mars_model)$class <- 'mars'\n",
142+
" attributes(mars_model)\$class <- 'mars'\n",
143143
" save(mars_model, factor_levels, file=paste(model_path, 'mars_model.RData', sep='/'))\n",
144144
" print(summary(mars_model))\n",
145145
"\n",
146-
" write.csv(model$fitted.values, paste(output_path, 'data/fitted_values.csv', sep='/'), row.names=FALSE)\n",
146+
" write.csv(model\$fitted.values, paste(output_path, 'data/fitted_values.csv', sep='/'), row.names=FALSE)\n",
147147
" write('success', file=paste(output_path, 'success', sep='/'))}\n",
148148
"```"
149149
]
@@ -158,7 +158,7 @@
158158
"# Setup scoring function\n",
159159
"serve <- function() {\n",
160160
" app <- plumb(paste(prefix, 'plumber.R', sep='/'))\n",
161-
" app$run(host='0.0.0.0', port=8080)}\n",
161+
" app\$run(host='0.0.0.0', port=8080)}\n",
162162
"```"
163163
]
164164
},
@@ -183,7 +183,7 @@
183183
"metadata": {},
184184
"source": [
185185
"### Serve\n",
186-
"`plumber.R` uses the [plumber](https://www.rplumber.io/) package to create a light weight http server for processing requests in hosting. Note the specific syntax, and see the plumber help docs for additional detail on more specialized use cases."
186+
"`plumber.R` uses the [plumber](https://www.rplumber.io/) package to create a lightweight HTTP server for processing requests in hosting. Note the specific syntax, and see the plumber help docs for additional detail on more specialized use cases."
187187
]
188188
},
189189
{
@@ -217,7 +217,7 @@
217217
" load(paste(model_path, 'mars_model.RData', sep='/'))\n",
218218
"\n",
219219
" # Read in data\n",
220-
" conn <- textConnection(gsub('\\\\\\\\n', '\\n', req$postBody))\n",
220+
" conn <- textConnection(gsub('\\\\\\\\n', '\\n', req\$postBody))\n",
221221
" data <- read.csv(conn)\n",
222222
" close(conn)\n",
223223
"\n",
@@ -292,7 +292,7 @@
292292
"cell_type": "markdown",
293293
"metadata": {},
294294
"source": [
295-
"_Note: Although we could, we'll avoid doing any preliminary transformations on the data, instead choosing to do those transformations inside the container. This is not typicall the best practice for model efficiency, but provides some benefits in terms of flexibility._"
295+
"_Note: Although we could, we'll avoid doing any preliminary transformations on the data, instead choosing to do those transformations inside the container. This is not typically the best practice for model efficiency, but provides some benefits in terms of flexibility._"
296296
]
297297
},
298298
{
@@ -369,7 +369,7 @@
369369
"cell_type": "markdown",
370370
"metadata": {},
371371
"source": [
372-
"Now let's kick off our training job on EASE, using the parameters we just created. Because training is serverless, we don't have to wait for our job to finish to continue, but for this case, let's setup a waiter so we can monitor the status of our training."
372+
"Now let's kick off our training job on EASE, using the parameters we just created. Because training is managed (AWS takes care of spinning up and spinning down the hardware), we don't have to wait for our job to finish to continue, but for this case, let's setup a waiter so we can monitor the status of our training."
373373
]
374374
},
375375
{
@@ -538,7 +538,7 @@
538538
"\n",
539539
"This notebook showcases a straightforward example to train and host an R algorithm in Amazon SageMaker. As mentioned previously, this notebook could also be written in R. We could even train the algorithm entirely within a notebook and then simply use the serving portion of the container to host our model.\n",
540540
"\n",
541-
"Other extensions could include setting up the R algorithm to train in parallel. Although R is not the easiest language to build distributed applications on top of, this is possible. In addition, running multiple versions of training simultaneously would allow for parallelized grid (or random) search for optimal hyperparamter settings. This would more fully realize the benefits of serverless training."
541+
"Other extensions could include setting up the R algorithm to train in parallel. Although R is not the easiest language to build distributed applications on top of, this is possible. In addition, running multiple versions of training simultaneously would allow for parallelized grid (or random) search for optimal hyperparamter settings. This would more fully realize the benefits of managed training."
542542
]
543543
}
544544
],

xgboost_customer_churn/xgboost_customer_churn.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
"cell_type": "markdown",
258258
"metadata": {},
259259
"source": [
260-
"Now that we've cleaned up our dataset, let's determine which algorithm to use. As mentioned above, there appear to be some variables where both high and low (but not intermediate) values are predictive of churn. In order to accommodate this in an algorithm like linear regression, we'd need to generate polynomial (or bucketed) terms. Instead, let's attempt to model this problem using gradient boosted trees. Amazon SageMaker provides an XGBoost container that we can use to train in a serverless, distributed setting, and then host as a real-time prediction endpoint. XGBoost uses gradient boosted trees which naturally account for non-linear relationships between features and the target variable, as well as accommodating complex interactions between features.\n",
260+
"Now that we've cleaned up our dataset, let's determine which algorithm to use. As mentioned above, there appear to be some variables where both high and low (but not intermediate) values are predictive of churn. In order to accommodate this in an algorithm like linear regression, we'd need to generate polynomial (or bucketed) terms. Instead, let's attempt to model this problem using gradient boosted trees. Amazon SageMaker provides an XGBoost container that we can use to train in a managed, distributed setting, and then host as a real-time prediction endpoint. XGBoost uses gradient boosted trees which naturally account for non-linear relationships between features and the target variable, as well as accommodating complex interactions between features.\n",
261261
"\n",
262262
"Amazon SageMaker XGBoost can train on data in either a CSV or LibSVM format. For this example, we'll stick with CSV. It should:\n",
263263
"- Have the predictor variable in the first column\n",
@@ -324,7 +324,7 @@
324324
"---\n",
325325
"## Train\n",
326326
"\n",
327-
"Moving onto training, we'll need to specify the following parameters to take advantage of Amazon SageMaker's serverless training:\n",
327+
"Moving onto training, we'll need to specify the following parameters to take advantage of Amazon SageMaker's managed training:\n",
328328
"1. The role for Amazon SageMaker to use\n",
329329
"1. Our training job name\n",
330330
"1. The `xgboost` algorithm EC2 Container Repository location\n",

xgboost_direct_marketing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ This folder contains two notebooks:
44

55
*xgboost_direct_marketing.ipynb:* is an introduction to machine learning for less technical users. The task is the same as the Amazon ML [tutorial](http://docs.aws.amazon.com/machine-learning/latest/dg/tutorial.html), but showcases the flexibility of running this analysis in a notebook environment.
66

7-
*xgboost_direct_marketing_sagemaker.ipynb:* is very similar, but utilizes Amazon Amazon SageMaker concepts beyond the hosted notebook environment, relying on serverless, distributed training and creating a hosted endpoint for realtime predictions.
7+
*xgboost_direct_marketing_sagemaker.ipynb:* is very similar, but utilizes Amazon Amazon SageMaker concepts beyond the hosted notebook environment, relying on managed, distributed training and creating a hosted endpoint for realtime predictions.

xgboost_direct_marketing/xgboost_direct_marketing.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@
709709
"\n",
710710
"## Extensions\n",
711711
"\n",
712-
"This example was contained within the Notebook environment entirely. As data sizes grow, utilizing other Amazon SageMaker features such as distributed, serverless training and our hyperparameter optimization service makes more sense. In addition, if the model needs to be used to provide real-time, online predictions, Amazon SageMakers's auto-scaling hosting should be used. Please check out the other Amazon SageMaker direct marketing notebook for a more functionally detailed walkthrough of those features."
712+
"This example was contained within the Notebook environment entirely. As data sizes grow, utilizing other Amazon SageMaker features such as distributed, managed training and our hyperparameter optimization service makes more sense. In addition, if the model needs to be used to provide real-time, online predictions, Amazon SageMakers's auto-scaling hosting should be used. Please check out the other Amazon SageMaker direct marketing notebook for a more functionally detailed walkthrough of those features."
713713
]
714714
}
715715
],

xgboost_direct_marketing/xgboost_direct_marketing_sagemaker.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@
389389
"cell_type": "markdown",
390390
"metadata": {},
391391
"source": [
392-
"Now we'll copy the file to S3 for Amazon SageMaker's serverless training to pickup."
392+
"Now we'll copy the file to S3 for Amazon SageMaker's managed training to pickup."
393393
]
394394
},
395395
{
@@ -415,7 +415,7 @@
415415
"\n",
416416
"There are several intricacies to understanding the algorithm, but at a high level, gradient boosted trees works by combining predictions from many simple models, each of which tries to address the weaknesses of the previous models. By doing this the collection of simple models can actually outperform large, complex models. Other Amazon SageMaker notebooks elaborate on gradient boosting trees further and how they differ from similar algorithms.\n",
417417
"\n",
418-
"`xgboost` is an extremely popular, open-source package for gradient boosted trees. It is computationally powerful, fully featured, and has been successfully used in many machine learning competitions. Let's start with a simple `xgboost` model, trained using Amazon SageMaker's serverless, distributed training framework.\n",
418+
"`xgboost` is an extremely popular, open-source package for gradient boosted trees. It is computationally powerful, fully featured, and has been successfully used in many machine learning competitions. Let's start with a simple `xgboost` model, trained using Amazon SageMaker's managed, distributed training framework.\n",
419419
"\n",
420420
"First we'll need to specify training parameters. This includes:\n",
421421
"1. The role to use\n",
@@ -723,7 +723,7 @@
723723
"\n",
724724
"## Extensions\n",
725725
"\n",
726-
"This example analyzed a relatively small dataset, but utilized Amazon SageMaker features such as distributed, serverless training and highly available, autoscaling model hosting, which could easily be applied to much larger problems. Please check out the other Amazon SageMaker direct marketing notebook for a more detailed walkthrough of improvements that could be made to the model (in particular tuning the model for better accuracy) and discussion of gradient boosting versus similar algorithms."
726+
"This example analyzed a relatively small dataset, but utilized Amazon SageMaker features such as distributed, managed training and highly available, autoscaling model hosting, which could easily be applied to much larger problems. Please check out the other Amazon SageMaker direct marketing notebook for a more detailed walkthrough of improvements that could be made to the model (in particular tuning the model for better accuracy) and discussion of gradient boosting versus similar algorithms."
727727
]
728728
}
729729
],

0 commit comments

Comments
 (0)