This post was originally written on my Coil site, which is currently my main blogging platform. On there you will also see bonus content if you are a Coil subscriber.
So, I'm about to start a series of posts on machine learning and artificial intelligence. This set of posts will be somewhat technical but, the idea will be to introduce people to the concepts of machine learning and artificial intelligence and to de-mystify it a bit.
So hopefully the first few articles at least should be followable by people without any specific technical or programming experience. As the series progresses I will start to bring in python code showing some examples of using machine learning for various tasks.
So the first thing to cover... what even is it? We hear so much about artificial intelligence and everything from Terminator to Teslas come to mind. Some may even remember the 1980s film Wargames in which a young hacker (Matthew Broderick) accidentally breaks into a US defence computer controlling nuclear missiles. The film culminates with Broderick playing a game of tic-tac-toe with the computer and it learning that the best way to win is not to play at all. And hence nuclear armageddon is averted. This is a great simple example of machine learning, and an example I'll come back to.
Generally, in 'classical' computer programming, a programmer writes a series of instructions for the computer to follow. Those instructions are explicit in what to do and contain logical flow: e.g. "If the temperature is above 20 degrees then turn the heater off". This code is pretty simple to look at and reason with. But it requires the programmer to know what the logical statements are. In essence, all computer programs take some kind of input and produce some kind of output . In this case the temperature is the input , and the state of the switch that turns the heater on and off is the output .
In this case, it is pretty easy. The code would look something like this. It is a function that takes an input temperature and returns either 1 or 0 to represent the state the heater switch should be.
But what if instead we wanted to instead code something a bit more generic e.g. "If the temperature is too hot then turn the heater off". How do we define "too hot"? A computer is a pretty 'unfeeling' object. How does it know that "too hot" even means? Well, with machine learning we can try and teach it what that means.
This could be achieved by a branch of machine learning called "supervised learning" in which we give a program a set of known inputs and outputs called the training data and get it to learn the "bit in the middle". Here is what the training data could look like.
Can you spot the pattern here? Yes, it is what we described before, that if the input temperature is 20 or below, then output a 1, otherwise output a 0.
With a machine learning algorithm we could train it to learn the pattern so that we don't have to explicitly code the rule. This might seem strange with such a trivial example, but where machine learning excels is when we have much more complex input data and patterns we might not be able to spot as humans. What if our input data wasn't just temperature, but was temperature, humidity, number of people in the house, time of day, output temperature? And the output was what we feel whether the heater should be on or off? That would be very hard to try and write rules for explicitly. But if we had a whole lot of training data taken from actual human experience then the program could learn what the rules are. The goal is for it to learn a generic set of rules that it can then apply to input data it has not been trained on and come out with the right answer.
Hopefully this 'sets the scene' for what it is I will be writing about in these posts and give people a starting point.