Model prediction
As mentioned in the last note in the previous section, as this is a batch model, the steps are similar for model scoring for fetching the data from the offline store. However, depending on which customers need to be scored (maybe all), you might filter out the dataset. Once you filter out the dataset, the rest of the steps are again straightforward, which is to load the model, run predictions, and store the results.
The following is a sample code block for loading the model, running predictions, and also storing the results back in S3 for consumption:
import boto3
from datetime import date
s3 = boto3.client('s3')
s3.download_file(s3_bucket_name, f"model-repo/customer-churn-v0.0", "customer-churn-v0.0")
features = churn_data.drop(['customerid', 'churn'], axis=1)
loaded_model = joblib.load('/content/customer-churn-v0.0')
prediction = loaded_model.predict(features)
prediction.tolist...