How Machines Learn From Data
Rules versus learned patterns, the steps of a machine learning project, and the first judgment call.
Objective
By the end of this lesson, you can explain the difference between a rule and a learned pattern, and list the steps of a machine learning project.
Rules versus patterns
There are two ways to make a computer decide something.
Rules. A person writes the logic. "If the temperature is below 32 degrees Fahrenheit, warn about ice." Rules are clear and easy to check.
Learned patterns. You give the computer many examples with answers. It finds the pattern on its own. This is machine learning: software that improves at a task by studying examples instead of following hand-written rules.
Here is a simple rule in Python. You can run it on this page. The first run downloads Python into your browser. That takes a moment and uses some data, so the code is also shown below for reading.
temperature_f = 28
if temperature_f < 32:
print("Ice warning")
else:
print("No ice warning")
When a rule is better
Use a rule when the logic is known, stable, and easy to explain. Water freezes at 32 degrees. You do not need a model to learn that.
Use machine learning when the pattern is real but too messy to write down. How much power a region uses tomorrow depends on weather, the day of the week, holidays, and more. That is a good fit for a model.
Judgment check: if a simple rule works, use the rule. It is easier to explain, test, and fix.
The steps of a project
Every project in this course follows the same path:
- Question. What decision will this help with? Who makes it?
- Data. Where does it come from? Who is in it, and who is missing?
- Prepare. Clean it, fix gaps, and shape it into a table.
- Explore. Chart it. Look before you model.
- Model. Train on part of the data.
- Test. Check on data the model has never seen.
- Review. Who is affected if it is wrong? Is it fair? Should it ship?
A national example
Quiz: Rule or model?
Go deeper: Machine Learning, Minus the Hype: A Practical Playbook to Ship Useful Models
Discussion
Ask. Answer. Build together.
Loading…