Skip to content

Aktywność

AI sports data logger

Zaawansowany | MakeCode | Akcelerometr, Rejestrowanie danych, Wyświetlacz LED | Czyszczenie danych, Narzędzia wydajności, Uczenie maszynowe, Zbieranie danych, Zrozumienie AI

Stwórz rejestrator AI danych sportowych za pomocą micro:bit CreateAI, który będzie rejestrował, ile czasu Ty i inni spędzacie na bieganiu, chodzeniu i pozostawaniu w bezruchu.

Poradnik projektu krok po kroku

Krok 1: Zrozumieć to

Jak to działa?

W tym projekcie będziesz trenował model uczenia maszynowego (ML) do rozpoznawania, gdy biegniesz, idziesz lub pozostajesz w bezruchu.

Będziesz łączyć ten model z programem w MakeCode, który używa funkcji rejestrowania danych micro:bit do zapisywania czynności, jakie wykonujesz co sekundę.

Projekt ten może okazać się przydatny w takich dyscyplinach jak piłka nożna czy siatkówka, gdzie trzeba analizować, jak aktywni są poszczególni zawodnicy. Możesz również użyć go do monitorowania ilości czasu spędzonego na biegu lub chodzeniu podczas przerwy w szkole lub podczas treningu.

Czym jest uczenie maszynowe?

Uczenie maszynowe (ML) jest rodzajem sztucznej inteligencji (AI), w której bazując na danych komputery uczą się i podejmują decyzje.

Modele ML są trenowane przez ludzi, aby pomóc im w podejmowaniu takich decyzji, na przykład, aby rozpoznać różne "akcje", gdy poruszasz swój micro:bit na różne sposoby.

Co będę musiał zrobić?

Systemy AI potrzebują ludzi do projektowania, budowania, testowania i korzystania z nich. Zbierzesz dane, aby wytrenować model ML, przetestować go, ulepszyć i połączyć go z kodem komputerowym, aby stworzyć inteligentne urządzenie, które wykorzystuje AI. Aby to zrobić, użyjesz strony micro:bit i micro:bit CreateAI.

Krok 2: Utwórz

Czego potrzebujesz

  • micro:bit V2, kabel USB i zestaw baterii z 2 x bateriami AAA
  • Komputer (np. desktop, laptopa lub Chromebook) z dostępem do strony micro:bit CreateAI, za pomocą przeglądarki Chrome lub Edge
  • Jeśli twój komputer nie ma włączonego Bluetooth, potrzebujesz dodatkowego micro:bita V2
  • Pasek i uchwyt lub inny sposób przymocowania micro:bita do nadgarstka (np. elastyczne tasiemki lub gumki)
  • Możesz również znaleźć przydatne porady micro:bit CreateAI 

Zbierz próbki danych

Kiedy otworzysz projekt w micro:bit CreateAI, zobaczysz, że daliśmy Ci kilka próbek danych dla akcji "bieganie", "chodzenie" i "w bezruchu":

Możesz dodać własne próbki ruchu za pomocą czujnika ruchu lub akcelerometru micro:bita.

W micro:bit CreateAI, kliknij przycisk 'Połącz', aby połączyć zebrane dane, i postępuj zgodnie z instrukcjami.

Attach the data collection micro:bit to your left wrist like a watch, with the logo at the top. Click on the first action, ‘walking’, and click 'Record' to record your own data samples. Jeśli popełnisz błąd, możesz usunąć dowolne próbki, których nie chcesz. Możesz również nacisnąć przycisk B na micro:bicie, aby rozpocząć nagrywanie.

Jeśli chcesz nagrywać w sposób ciągły przez 10 sekund, aby otrzymać 10 próbek, kliknij trzy kropki obok przycisku nagrywania i wybierz tę opcję.

Now record your own data samples for the ‘running’ action, then the ‘still’ action, making sure for ‘still’ that you collect samples in different positions, such as facing up and down.

Trenuj i testuj model

Kliknij przycisk „Trenuj model”, aby trenować model, a następnie przetestować go. Try walking and see if ‘walking’ is the estimated action, then running to see if ‘running’ is the estimated action. Keep still and see if ‘still’ is estimated. Give your micro:bit to someone else to wear (making sure they put it on the same wrist and in the same orientation) and see if it works as well for them.

Ulepsz swój model

Większość modeli można ulepszyć dzięki większej liczbie danych. Jeśli model wymaga poprawy, kliknij „Edytuj próbki danych”.

You can delete any data samples which you think don’t fit or add more samples from yourself and other people.

Ponownie trenuj i testuj model.

Umieść model i kod na swoim micro:bicie

W micro:bit CreateAI kliknij "Edytuj w MakeCode", aby zobaczyć kod projektu w edytorze MakeCode.

Możesz zmodyfikować kod lub wypróbować go taki, jaki jest. Dołącz swój micro:bit za pomocą kabla USB, kliknij przycisk „Pobierz” na ekranie MakeCode i postępuj zgodnie z instrukcjami dotyczącymi przeniesienia do niego modelu AI i bloków kodu.

Podłącz pakiet bateriię do micro:bita i załóż go, gotowy do testu.

Zbierz swoje dane

Najpierw naciśnij jednocześnie przyciski A i B, aby usunąć wszystkie stare dane z micro:bita. Zresetuj timer naciskając przycisk resetowania na tylnej stronie micro:bita. Naciśnij przycisk A, aby rozpocząć rejestrowanie i przycisk B, aby je zatrzymać.

Twoje dane pozostaną na micro:bicie nawet jeśli odłączysz baterie lub naciśniesz przycisk resetowania.

Analizuj swoje dane

Odłącz pakiet baterii i podłącz micro:bit z powrotem do komputera. micro:bit pojawia się jako dysk USB o nazwie MICROBIT. Spójrz na dysk MICROBIT i otwórz plik MY_DATA, aby zobaczyć tabelę Twoich danych w przeglądarce internetowej:

Data table from AI sports data logger

The time stamps in the log represent the amount of time that has passed since your micro:bit was powered on or reset.

Click on Visual preview to see a graph of your data:

Graph generated by CreateAI sports data logger

You can also click on the Copy button and then paste your data into a spreadsheet.

Jak działają bloki kodu

This program uses a variable called ‘logging’. A variable in a computer program is a container for storing data which can be accessed and updated while the program is running. In this program, the variable ‘logging’ controls if the micro:bit is logging or not and can be set to ‘true’ or ‘false’. Variables that can be set to these two values are called ‘Boolean’ variables.

When the program starts, the variable ‘logging’ is set to false. A show icon block is used to display a ‘no’ icon on the LED display to indicate the micro:bit is not logging. The set columns and set timestamp blocks create labels for the data logging table your micro:bit will produce.

The on button A pressed block is used to set logging to ‘true’ and show a ‘yes’ icon on the LED display. The on button B pressed block is used to set logging to ‘false’ and show a ‘no’ icon on the LED display. And the on buttons A + B pressed block sets logging to ‘false’, displays a skull icon, and deletes any log.

Finally, an ‘every’ block is used to check every 1,000 milliseconds or second if the micro:bit is logging. If it is, an ‘if then else’ block is used with ‘is ML detected’ and ‘log data’ blocks to record a 0 if you are still, a 1 if you are walking and a 2 if you are running in your data logging table. If the micro:bit cannot detect what you are doing, it records a -1 in the table. Bigger numbers are used for more active actions, so the resulting data logging graph gives you a clear visual record of how active you have been.

Ewaluacja

How accurate is the AI sports logger in tracking your movements? How could you improve its accuracy? Who would find this device particularly useful? How does it compare to the Step counter or the Movement data logger projects?

Krok 3: Rozszerzenie

  • Add a fourth action such as ‘throwing’ for sports like netball or tennis.

Data from the AI sports data logger in an Excel spreadsheet containing a formula to count activity 1 (walking)

Excel spreadsheet with formula to count certain activity cells

  • Add up how much time you spent on each activity. You could do this saving your data as a CSV file, opening it in a spreadsheet and using a formula such as =COUNTIF(B2:B70,1) Where B2:B70 is the range of the activity cells, and 1 is the activity number meaning ‘walking’.