Solution: Train and Evaluate ML Model
Let's take a look at the solution for this exercise.
We'll cover the following
Solution
Here are the steps required to reproduce this solution:
- Run the
train.py
script to train a model and generate the data files that you’ll upload to Amazon S3 in the next step. - Create a bucket to store the train/ test data used for training the model. The Lambda function will be aware of this location. The value of the environment variable
DATA_PATH
iss3://BUCKET_NAME/
. Replace theBUCKET_NAME
with a bucket name of your choice. - By default, a Lambda function has no permissions except for persisting its logs. For the Lambda function to list and read data from the previously created bucket, the default Lambda role permissions created automatically by Serverless have already been adjusted (see
iam
block inprovider
section). This gives the Lambda function additional minimal privileges for listing all buckets, and basic data operations on the created bucket. - Substitute
SERVERLESS_ORG
,AWS_BUCKET_NAME
andDATA_PATH
, and then deploy your own service. - Test the service in your Lambda’s test window by providing the following payload where
partition
is equal totest
ortrain
. How different is the score?
{
"partition": "test"
}
Playground
Use the following widget to perform the abovementioned steps.
Get hands-on with 1400+ tech skills courses.