0:00:00.680,0:00:05.440 To make your AI storytelling friend, [br]you’ll train a machine learning, 0:00:05.440,0:00:11.120 or ML, model to recognise when [br]a toy moves in different ways. 0:00:11.120,0:00:16.280 You’ll then combine this model with code [br]to make different sounds and show different 0:00:16.280,0:00:20.856 icons on the micro:bit’s LED display. 0:00:20.856,0:00:28.480 Then you’ll download the model and the code to a micro:bit and use it on your toy to help tell a story. 0:00:28.480,0:00:34.264 Our story is about a bear called Lucy, but [br]you can change the project to fit your own. 0:00:34.264,0:00:40.360 [MUSIC][br]This is Lucy the bear. 0:00:40.360,0:00:47.520 She wants to be a gymnast when she grows up, so every [br]day when she wakes up, she practices her jumping. 0:00:47.520,0:00:54.640 She jumps as high as the ceiling.[br]Then after breakfast she practices her rolling. 0:00:54.640,0:00:59.920 She rolls round and round until [br]her whole world is spinning. 0:01:01.469,0:01:06.490 Then she takes a break and has a little nap. 0:01:10.048,0:01:18.760 To start making your AI storytelling friend, click ‘Open in micro:bit  CreateAI’ to launch the project. 0:01:18.760,0:01:23.829 This project comes with 8 samples [br]of movement data for three different actions: 0:01:23.829,0:01:28.959 jumping, rolling and sleeping. 0:01:28.959,0:01:38.120 micro:bit CreateAI collects movement data samples using the accelerometer, the micro:bit’s movement sensor. 0:01:38.120,0:01:43.560 To add your own data samples, you need [br]to make a data collection micro:bit. 0:01:43.560,0:01:50.160 If your computer has Bluetooth enabled, then [br]you'll just need 1 micro:bit and a USB data lead. 0:01:50.160,0:01:54.840 If you don’t have a Bluetooth connection, [br]you’ll need to use 2 micro:bits. 0:01:54.840,0:01:59.554 Follow the instructions on screen to connect. 0:01:59.554,0:02:06.777 Once your data collection micro:bit is connected,[br]attach it to your toy like this. 0:02:06.777,0:02:15.400 You’ll see the lines on the live graph[br]change as you move your toy.[br]As this project already includes quite a lot 0:02:15.400,0:02:25.000 of data samples, we suggest you add 1 sample for [br]each action for now and collect more data later. 0:02:25.000,0:02:29.440 Click on the ‘jumping’ action so [br]you can add more data samples to it. 0:02:29.440,0:02:33.600 You will get a countdown before [br]a 1 second recording starts. 0:02:33.600,0:02:39.800 Click record and start moving your toy immediately [br]to make sure you get a clean data sample. 0:02:39.800,0:02:43.440 A clean sample is one where you’re [br]moving for the entire sample, 0:02:43.440,0:02:50.800 you don’t start late or finish moving early.[br]Next try adding an extra data sample to the 0:02:50.800,0:02:57.115 ‘rolling’ and ‘sleeping’ actions. 0:02:57.115,0:03:07.520 You’ll notice that when your toy is asleep, the x,y, and z lines change places depending on the orientation of the micro:bit. 0:03:07.520,0:03:14.600 Click ‘Train model’ to build the ML model.[br]The tool now builds a mathematical 0:03:14.600,0:03:19.960 model that should recognise different [br]actions when you move your micro:bit. 0:03:19.960,0:03:25.640 As soon as the model has been trained, [br]you’ll see the Testing model page. 0:03:25.640,0:03:30.760 Your data collection micro:bit can now be [br]used to test how well the model is working. 0:03:30.760,0:03:35.880 It should still be connected to the tool, and [br]you’ll see that as you move it, CreateAI is 0:03:35.880,0:03:40.317 estimating what action you are doing. 0:03:40.317,0:03:47.027 Move your toy in different ways to see [br]the estimated action and the certainty bar graph change. 0:03:47.400,0:03:56.160 The percentage shows how certain, or confident, [br]the model is that you are doing each action. 0:03:56.160,0:04:00.760 You may notice your model is not [br]estimating some actions accurately. 0:04:00.760,0:04:07.920 In that case it’s a good idea to click on [br]‘Edit data samples’ and improve your model. 0:04:07.920,0:04:13.960 Machine learning models usually work best with [br]more data, so record some extra samples for each 0:04:13.960,0:04:22.400 of the actions, or focus on collecting more data [br]for the action that was problematic in testing. 0:04:22.400,0:04:28.360 Clean data samples also help an ML model [br]work better so examine your data set and 0:04:28.360,0:04:38.200 identify any samples that could confuse the [br]model. You can delete these by pressing X. 0:04:38.200,0:04:44.920 Once you’ve added more data and checked your [br]data set, click ‘Train model’ again. Then test 0:04:44.920,0:04:50.003 the model again on the ‘Testing model’ page. 0:04:50.003,0:04:57.120 Once you’re happy with how the ML model is behaving, you can use it with [br]the ready-made project code. 0:04:57.120,0:05:06.120 Click on ‘Edit in MakeCode’ to see the code [br]blocks in a special version of Microsoft MakeCode. 0:05:06.120,0:05:10.040 You can return to see your [br]data in CreateAI at any time 0:05:10.040,0:05:19.720 using the arrow in the top left of the screen.[br]These blocks use the model you’ve created in code. 0:05:19.720,0:05:24.880 The ‘on ML… start’ blocks react [br]when the ML model decides your 0:05:24.880,0:05:31.320 toy is making a particular movement, or action.[br]Depending on the action, the code shows different 0:05:31.320,0:05:38.600 icons on the micro:bit’s LED display output [br]and plays different sounds on its speaker. 0:05:38.600,0:05:46.360 If it’s not sure what action your toy is doing – [br]if the action is ‘unknown’ – it clears the screen. 0:05:46.360,0:05:53.320 And when each action stops, the code [br]stops the micro:bit making any sound. 0:05:53.320,0:05:56.640 To make the code and the ML [br]model run on your micro:bit, 0:05:56.640,0:05:59.640 you just need to download it to a micro:bit. 0:06:00.280,0:06:06.320 Press ‘Download’ and follow [br]the instructions on screen. 0:06:06.320,0:06:10.640 Now test the finished project on [br]a micro:bit attached to your toy. 0:06:10.640,0:06:16.200 Do the correct sounds play and icons display [br]when your toy makes different movements? 0:06:16.200,0:06:19.800 Does it work equally well when [br]someone else moves the toy? 0:06:19.800,0:06:26.880 If not, you can go back and collect more [br]data from them and re-train the model. 0:06:26.880,0:06:30.960 Congratulations, you’ve trained your toy [br]to react to different kinds of movement 0:06:30.960,0:06:36.600 using data you have collected, training an AI [br]machine learning model, and combining it with 0:06:36.600,0:06:43.480 code to make an interactive storytelling toy![br]What other actions, or movements might your toy 0:06:43.480,0:06:51.795 make, perhaps as part of telling a story? Can [br]you add them using the micro:bit and CreateAI?