Mobile price classifier on SageMaker
Trains a Random Forest mobile price classifier on SageMaker spot instances and serves it from an endpoint.
What it does
Mobile price data is split, uploaded to S3 and used by a custom scikit-learn training script run through the SageMaker SKLearn estimator on a spot ml.m5.large instance. The model artifact is wrapped as an SKLearnModel, deployed to a real-time ml.m4.xlarge endpoint, queried with test rows and then deleted.
What was built
- 01
Session uploads train and test CSVs to an S3 prefix used as the training input.
- 02
script.py parses hyperparameters with argparse, trains a RandomForestClassifier and saves model.joblib with a model_fn loader.
- 03
SKLearn estimator runs the script on ml.m5.large with spot instances and a one-hour max run.
- 04
SKLearnModel deploys to an ml.m4.xlarge endpoint; predictions are tested and the endpoint is deleted with boto3.
The pipeline, layer by layer
Four layers, one pipeline.
L1Data
- Mobile price CSV
- S3 upload
L2Training
- SageMaker spot training job
- Random Forest script
L3Model
- SKLearnModel artifact
L4Serving
- Real-time endpoint