Machine Learning Demystified — Part I
With machine learning, you can train a computer on how to find a solution on its own rather than just programming it to do so. This can be tremendously helpful and present you with fresh opportunities for solving issues that cannot be resolved through programming alone. I discuss the idea of machine learning against conventional computer programming in this two-part article and demonstrate with useful examples how the two are applicable to certain tasks.
Traditional Programming Paradigm
Software engineers all across the world rely heavily on explicit coding. You consider the problem you’re trying to solve or the scenario you’re working on, and you describe the solution by creating the rules that govern how a program behaves.
In traditional programming, rules are identified and expressed using a programming language like Java, C++, or Python to solve a problem.
Consider this example
Think about activity detection. Let’s say you want to create a mobile application that analyses data from sensors on a watch, phone, or other devices to identify a person’s activities. You could, for instance, create a rule that says they are likely walking if their speed is below a specific threshold using the speed data.
You have the data. You’ve got a rule. You can then get an answer. By expanding on that rule, you can use this to detect whether they are running.
For instance, if the speed is less than 4 miles per hour, the person is walking. If not, they’re trotting or running. Awesome! That still functions.
You could definitely go even further to see if they’re biking. If the speed is less than 4, they are walking. Otherwise, they’re running if the speed is below 12. Otherwise, we can claim that they are biking.
But then how would you handle golfing? What rule could you write that determines that they’re actually playing golf? Also, by now, you’ve probably realized that the other rules are also a little bit naive. You can’t just go by speed alone. You might run downhill faster than your bike uphill, for instance.
Machine Learning Paradigm
You can recall that traditional programming is when you create rules in a programming language and these rules act on data and provide you with answers.
With activity detection, we had created rules to figure out the user’s activity, be it walking, biking, or running, but then we hit a wall with golfing. Not only that, but we can also see that our algorithm was a little bit naive. Our rules don’t really work that well — there is more than just speed to consider!
For example, you might run downhill faster than you bike uphill. And as a result, your app might fail when written with rules like this. Machine learning can help solve this problem. And it can be represented with a simple rearrangement of the diagram.
What if you provided the answers along with the data and had a computer determine the rules that would match them together, rather than trying to determine the rules that operate on the data to give you an answer? Once it has done this, it may use those rules to analyze subsequent data and get the answers.
Accordingly, in our activity detection scenario, we may collect a lot of sensor data and tag it with the activity the consumer is engaged in. The computer may now be able to deduce the rules governing what constitutes walking, running, biking, and, yes, even golfing by comparing portions of the data with the label that identifies the activity. The relationship between the data and its labels will first be inferred by the computer. In order to achieve this, a neural network is randomly initialized. It then assesses how accurate or inaccurate that guess is.
The terminology often used here is loss. Higher loss is roughly analogous to lower accuracy.
So then you can measure the results of your guess, and you can then use the data from the accuracy measurement to figure out your next guess, optimizing based on what you already know.
And if you then repeat the process with the logic being that each subsequent guess gets better than the previous one, then your model becomes more and more accurate. It’s learning from experience what the best guess might be.
The diagram describes machine learning from a high level.
NOTE: The word “answers” represents “labels”, and that is generally used for the term that describes your data. But the rest still stands.
You start with label data and go through the process previously mentioned. And you end up with a set of rules that matches that data to those labels. This constructs a model, and from this model, you can then give it new data, and it will figure out how closely that data fits the set of labels.
And it will return you something called a set of inferences, and these are the probabilities that the data matches each specific label.
There is a relationship that matches the X to the Y, a rule that you can figure out. The second part of this article discusses how to apply code to figure out the relationship between two sets of data, using both traditional programming and machine learning.
Yours, Ashtone Onyango