WEBVTT 00:00:01.240 --> 00:00:08.194 To create your AI activity timer, you  will train a machine learning, or ML, model 00:00:08.194 --> 00:00:13.080 to recognise when you’re doing  different movements or activities. 00:00:13.080 --> 00:00:18.960 You’ll then combine that model with some  ready-made code for an activity timer,   00:00:18.960 --> 00:00:26.800 before downloading it to your  micro:bit and using it in real life. 00:00:26.800 --> 00:00:33.960 Click ‘Open in micro:bit CreateAI’ to launch the project. 00:00:33.960 --> 00:00:41.120 This project comes with 6 samples of movement  data for walking, 6 samples of movement data   00:00:41.120 --> 00:00:47.200 for jumping up and down, and 6 samples of  movement data for staying fairly still. 00:00:47.200 --> 00:00:54.200 You will add more samples by  recording your own movement data. 00:00:54.200 --> 00:01:02.703 micro:bit CreateAI collects movement data samples using the accelerometer,   or movement sensor, on the micro:bit. 00:01:05.726 --> 00:01:09.734 You will wear a micro:bit and battery pack on your wrist or ankle 00:01:09.734 --> 00:01:15.120 so that you can move freely to record your own movement data samples. 00:01:15.120 --> 00:01:20.400 To get started, connect the  ankle-worn micro:bit to CreateAI.  00:01:20.400 --> 00:01:23.816 We call this the data collection micro:bit. 00:01:23.816 --> 00:01:31.640 If your computer has Bluetooth enabled then you will just need 1 micro:bit with a battery pack and a USB data lead. 00:01:31.640 --> 00:01:36.640 If you don’t have a Bluetooth connection,  you’ll be prompted to use 2 micro:bits. 00:01:36.640 --> 00:01:41.400 The second micro:bit will remain  connected to the USB cable and act as   00:01:41.400 --> 00:01:50.600 a radio link to the data collection micro:bit. Follow the instructions on screen to connect. 00:01:50.600 --> 00:01:57.817 Once your micro:bit is connected, you will see the lines on the live graph change as  you move your micro:bit about. 00:01:57.817 --> 00:02:02.297 You’re now ready to add your own movement data samples. 00:02:02.297 --> 00:02:06.263 As this project already includes some data samples, 00:02:06.263 --> 00:02:16.912 we suggest you just add 1 more sample for each action for now, and spend more time collecting and analysing data later. 00:02:16.912 --> 00:02:24.800 Make sure your data collection micro:bit is attached to the inside of the ankle, with button B on top. 00:02:24.800 --> 00:02:29.280 To add data to a specific action,  select it by clicking on it.  00:02:29.280 --> 00:02:34.440 You will get a 3 second countdown  before a 1 second recording starts.  00:02:34.440 --> 00:02:40.080 Click record and start moving right away  to ensure you get a clean data sample.  00:02:40.080 --> 00:02:43.960 A clean sample is one where you  are moving for the entire sample,   00:02:43.960 --> 00:02:48.593 you don’t start late or finish moving early. 00:02:48.593 --> 00:02:55.519 Next try adding an extra data sample to the ‘jumping’ data set and the ‘being still’ data set. 00:02:55.519 --> 00:03:05.040 Select them by clicking on the action, then click record and jump or stay quite still as you record the samples.  00:03:05.040 --> 00:03:16.521 You’ll notice on the 'being still' samples  that the x,y,z lines change places depending on the angle of the attached micro:bit. 00:03:16.521 --> 00:03:26.080 We don’t have a lot of data right now, but we do have enough to train our own  machine learning model using CreateAI.  00:03:26.080 --> 00:03:33.720 So click ‘Train model’ to use the  current data to build an ML model. 00:03:33.720 --> 00:03:41.363 The tool now builds a mathematical model that should recognise different actions when you move your micro:bit. 00:03:41.363 --> 00:03:45.646 As soon as the model has been trained, you will see the Testing model page. 00:03:45.646 --> 00:03:50.721 Now use the data collection micro:bit to test how well the model is working. 00:03:50.721 --> 00:03:59.720 It should still be connected to the tool, and you’ll see that as you move it, CreateAI is estimating what action you are doing. 00:04:02.360 --> 00:04:09.698 Try out each of the actions to see  both the estimated action and the certainty bar graph change. 00:04:11.257 --> 00:04:19.126 The % on the certainty bar graph shows how confident the model is that you are doing each action.  00:04:21.600 --> 00:04:26.520 You may notice your model is not estimating  some actions accurately, or maybe it is   00:04:26.520 --> 00:04:32.720 working well for one action but not the other,  so after exploring how it is currently working,   00:04:32.720 --> 00:04:40.360 it is a good idea to click on ‘Edit  data samples’ and improve your model.  00:04:40.360 --> 00:04:46.360 Machine learning models usually work best with  MORE data, so record some extra samples for each   00:04:46.360 --> 00:04:54.960 of the actions, or focus on collecting more data  for the action that was problematic in testing.  00:04:54.960 --> 00:05:01.935 You can record one sample at a time or  you can record 10 samples in sequence.  00:05:10.160 --> 00:05:23.081 Clean data samples also help an ML model work  better so examine your data set and identify any data samples that could confuse the model. 00:05:26.003 --> 00:05:29.640 You can delete these by pressing X. 00:05:30.840 --> 00:05:39.423 Once you’ve added more data and checked your data set, click ‘Train model’ again to use your amended data set.  00:05:40.483 --> 00:05:45.992 Then test the model again on the ‘Testing model’ page. 00:05:48.555 --> 00:05:54.640 Once you’re happy with how the ML model is behaving, you can use it with the ready-made project code.  00:05:54.640 --> 00:06:02.480 Click on ‘Edit in MakeCode’ to see the code  blocks in a special version of Microsoft MakeCode.  00:06:02.480 --> 00:06:09.560 You can always return to CreateAI using  the arrow in the top left of the screen.  00:06:09.560 --> 00:06:19.240 These code blocks use the model you  have created within an exercise timer.  00:06:19.240 --> 00:06:26.160 The code uses 3 variables to keep track  of how long you've been doing each action.  00:06:26.160 --> 00:06:33.680 When the program first runs it  sets these timer variables to 0.  00:06:33.680 --> 00:06:40.120 The 'on ML start' blocks are triggered when the ML  model decides you have started a specific action.  00:06:40.120 --> 00:06:49.250 They show different icons on the micro:bit's LED display depending on the action it has estimated you are doing. 00:06:50.289 --> 00:07:01.280 The 'on ML stop' blocks are triggered when the ML model decides you have finished an action,  in this case walking, jumping or being still.  00:07:01.280 --> 00:07:06.880 Code inside each block clears the screen and  adds the duration of the action that has just   00:07:06.880 --> 00:07:13.440 finished to the variable storing  the total times for each action.  00:07:13.440 --> 00:07:19.440 The ML model works with the code to allow you  to view the total time spent on each action.  00:07:19.440 --> 00:07:23.040 Press button A to see the estimate  of how long you were walking.  00:07:23.040 --> 00:07:28.160 Press button B to see how long the  model estimated you were jumping.  00:07:28.160 --> 00:07:34.080 To see the estimated duration you have  been still press A and B together.  00:07:34.080 --> 00:07:44.111 The timer counts in milliseconds, thousandths of a second, so the number shown is divided by 1000 to show a time in seconds. 00:07:44.111 --> 00:07:53.160 To make your AI activity timer run on your micro:bit, you just need to download this code to a micro:bit.  00:07:53.160 --> 00:08:00.642 If you don’t have another micro:bit available, simply replace the code currently on the data collection micro:bit with the project code. 00:08:01.646 --> 00:08:05.000 Now you can test the project out in real life. 00:08:05.000 --> 00:08:10.040 Do the correct icons display  when you are exercising or not?  00:08:10.040 --> 00:08:15.800 You can test if the timer code is working  well with the model in 3 easy steps: 00:08:15.800 --> 00:08:19.160 Press the reset button. Jump for 30 seconds. 00:08:19.160 --> 00:08:25.540 Then press button B. You should see the number 30 scroll across your display. 00:08:25.540 --> 00:08:28.560 You’re now ready to connect to CreateAI,   00:08:28.560 --> 00:08:34.560 collect your own data, use it to train, test and  improve a machine learning model, and then you   00:08:34.560 --> 00:08:40.600 can combine this model with the ready-made  code and try it out on your own micro:bit.  00:08:40.600 --> 00:08:48.379 If you’re looking for ways to personalise this even more try adding some different actions like running or dance steps. 00:08:48.379 --> 00:08:52.480 Enjoy!