Using Amazon Machine Learning to Predict the Best Time of Day for Exercise – Pt 3: Automating the Model with Alexa

Integration with Alexa allows a user to obtain a workout recommendation (and create a machine learning model) all by voice command.

002[su_note note_color=”#d3d3d3″]Note: This is the third post about using Amazon Machine Learning to predict workout intensity. Check out Part 1 (Overview) and Part 2 (Building the Machine Learning Model) for background. A working model is available via web and Alexa. Code can be found/downloaded from my Hackster site.[/su_note]

After I was able to build a working model, I needed to come up a way to automate the model. I originally planned to allow access through my website, but decided to use Alexa in addition to the website link.

Note: The process of creating an Alexa skill isn’t too complicated (if you have experience building lambda functions). That being said, I suggest you start by building a sample skill – such as the Fact Skill example. Also, be sure to read and follow the certification requirements.

Alexa, AWS, and the exposed Fitbit APIs provided a mechanism to build a model and return results for a specific user – all initiated by voice.

Step 1 – Linking the user’s Fitbit account to the skill

A user has to link his/her Fitbit account to the skill before s/he can (a) build a specific machine learning model based on their history and (b) get a workout recommendation. Step 1 covers the logic for this functionality.

Click image to enlarge


Step 2 – Building a Machine Learning model for the user

The user, after successfully linking his/her Fitbit account, will need a custom machine learning model in order for the application to make recommendations. The machine learning data source (build from the user’s Fitbit activity history) and the prediction engine are automatically build using additional AWS Lambda functions.

Click image to enlarge


Step 3 – Finalizing the Machine Learning Model build

The creation of the data source and the creation and evaluation of the learning model can take between 20-40 minutes, so I created a second Lambda function to poll the status of the machine learning widgets in order to take actions needed to complete the models.

Click image to enlarge


Step 4 – Using the Model to make a recommendation

After the model is created, a user is then able to ask Alexa to make a workout recommendation. Alexa, using day-of data from the Fitbit platform, feeds the recommendation engine and returns a time of day for the optimal workout.

Click image to enlarge


The final result can be seen in the embedded video.

One thought on “Using Amazon Machine Learning to Predict the Best Time of Day for Exercise – Pt 3: Automating the Model with Alexa”

  1. Darian,
    Absolutely love your work on Alexa and the voice operator space! Would you have 15 minutes for a quick call for me to learn more about how you envision the future of the space unraveling? Would certainly appreciate your insights!


Leave a Reply