What’s machine learning? Not a framework. Not a different language. Not the latest “cool” thing around the Internet. Thread: Let me convince you that machine learning is the best thing since sliced bread 🍞.
Let’s start with a simple exercise: “Write a function that returns 0 if a supplied number is even or 1 if the number is odd.” If you are a developer, I’m sure you know how to write this function. It should be simple, right?
To avoid using a specific syntax, let’s represent this function as follows: y = f(X) Where: • X → The input number • y → The result (0 if even, 1 otherwise) • f → The function that does the work We can now get to the interesting part.
If you are a programmer, writing this function is simple. You know the relationship between X (the input number) and y (the output), so you can easily write the rules (the function.) In machine learning, we don’t write the rules. We learn them.
Imagine we had an algorithm that processes many samples (X → y), learns the relationship between them, and comes up with the correct rules. We call these samples “training data,” and they would like like this: • 2 → 0 • 5 → 1 • 8 → 0 • 4 → 0 • 3 → 1 • …
Let me stop here for a second. HOLLY CRAP! I’m talking about a function that we don’t need to write ourselves! We show it data, and the thing learns the rules that produce the correct solution. It’s the closest thing to magic that I know.
I like to compare machine learning with kids: They learn the patterns that lead to specific answers by looking at a bunch of examples. (I don’t know anything about biology, human behavior, or our brains, so please, don’t @ me explaining why this is a simplistic analogy.)
Getting back to the example… Nobody should use machine learning to determine whether a number is odd or even. We understand that problem, and writing a solution is very simple. But this is not always the case.
Sometimes, the rules of a problem aren’t obvious, or there are too many, or they change a lot. That’s where machine learning is a killer solution! Thinking about chess is a good way to illustrate this point.
It’s easy to write the rules of chess. It’s hard to write a program that knows how to beat any chess player. Imagine that you write such a program. How well do you think it will play? Your knowledge of the game will be a limiting factor.
Instead, machine learning will give us a different possibility: We can build a program that analyzes millions of games and comes up with the rules to take advantage of any situation. We can use real games played by the brightest people and kick everyone’s butt!
Of course, I’m making this sound easier than it actually is. Implementing a machine learning system takes a lot of work. It’s not harder than writing any other type of code, but it isn’t simpler either. It’s different. And powerful.
Recap so far: y = f(X) In classical programming, we have to write the function (f). In machine learning, we learn the function (f). ↑ If nothing else, remember this.
There’s one more thing: To learn a function, we need a lot of data. We also need that data to fully capture the relationship between the input X and the output y. This is not always the case.
A small change to our representation: y = f(X) + e That “e” is called “irreducible error.” It covers the case where the training data didn’t fully capture the relationship between X and y. In those cases, the results of the function will be close enough but not perfect.
This brings me to the final idea: There’s always a trade-off. If we know how to write the rules, that’s usually the best approach. We don’t need to worry about data or errors. But if we don’t, machine learning might be the answer (but it comes with downsides.)
Summary: • Machine learning is powerful. • It’s a different way to approach hard problems. • It’s really effective. The best thing you can do as a software developer: start incorporating machine learning into your bag of tricks.
I post threads like this every week. Stay tuned as I help you get to the core of practical machine learning. You can find the rest of my threads here: @svpino.