7

(avery) #1

Make your Arduino learn


TUTORIAL


Machine learning doesn’t have to require data centres: all you need is know-how and an Arduino!


Make your Arduino learn


ou’ve probably seen countless
news stories about new artificial
intelligence (AI) systems that can
learn like humans do. At the core
of these AI systems is something
called machine learning. Machine
learning is a technique that allows the internal rules of
a system to be automatically learnt using data, rather
than a programmer hard-coding in all of the rules.
There is a misconception that you always require
a lot of data and computing power to build these
machine learning systems. For example, it’s common
to hear about teams using millions of data points and
powerful servers in their machine learning efforts.
For these larger machine learning jobs, they need
those resources because they are trying to solve very
complex problems, like learning how to drive a car
around a busy city. For simpler applications such as
‘when to turn on a lamp’, the amount of resources
required can be relatively minuscule: so minuscule
that you can fit every aspect of the machine learning
process onto a single Arduino.

We’ll walk through how to build a simple ‘automatic
night light’ system (a system that measures the
ambient light in the room and turns on an LED, based
on some defined threshold) with a machine learning
twist; rather than hard-coding the ambient light
threshold for which to turn on the LED, the machine
learning system will learn when to turn on the LED
based on data collected regarding when the user has
manually turned the LED on or off.
You will start off by toggling the LED on or off, as
you normally would by simply using a button, and then
the system will begin to learn and perform the task
automatically. What’s especially powerful about this
system is that it can be given to many different people,
and it will learn each of their individual preferences
without them changing code or fiddling with a settings
knob, as in traditional night light systems. As well
as the system’s adaptability to different people, as
your own preferences change over time, so too will
the system’s. Behold, this is the power of machine
learning systems.
There are three main processes of machine learning
systems: data collection, training/learning, and
prediction. Larger-scale applications would normally
have these different tasks done separately (e.g. collect
and store user data using a web form and database,
then use servers to perform model training, then
finally save the trained model into a web application
that can be asked to make predictions on new data).
Our system will have all of the same processes, but
running on just one Arduino. Although these processes
run in the order: 1) collect data, 2) train model, 3) make
predictions, it is easier to explain the development of
these processes in reverse order.

PREDICTION
In order to solve a problem with machine learning, you
need to ‘phrase’ the problem with a set of variables
that need to be optimised. For example, in the real
world you might want to boil an egg perfectly – to do
this you need to find the optimal heat level and cooking
time. So, if we were using machine learning we would
need a variable for ‘heat_level’ and ‘cooking_time’,
and it is these variables that will get automatically

Y


Zack Akil


Zack is a data scientist
focusing on the big
problems, such as the
proper filming of
rugby matches.

ZackAkil

Below
Our final circuit
lighting up our
dark evenings
Free download pdf