The Steps of a First Machine Learning Project
Real machine learning projects, big or small, follow the same basic steps. You can learn all of them with a project small enough for a classroom. This guide walks through eight steps using one example: will a paper airplane fly farther than 5 meters?
It is a good first project because the data is about paper airplanes, not people, so nobody's personal information is involved, and everyone can help collect it.
Step 1: Pick a yes-or-no question a computer can learn from examples
Good first questions have three things:
- A yes-or-no answer (or a choice between a few categories). That answer is called the label: the answer we want the computer to learn.
- Facts you can measure that might help answer it. These are called features.
- Examples you can collect yourself, safely and without needing anyone's personal details.
Our question: "Will this plane fly farther than 5 meters?" The label is "yes" or "no". The features could be wing width, plane length, the number of folds and whether the nose is weighted with a paper clip.
Step 2: Collect and label your data, with permission
Each pupil folds a few planes, measures the features and throws each one in the same open space, gently and never toward people. Someone measures the distance and writes "yes" if it went past 5 meters and "no" if not.
Suppose the class collects 100 throws. Each throw is one row in a table, and each feature is a column. Tips for good data:
- Agree on how to measure before you start (wing width at the widest point, distance to where the plane first touches the floor).
- Throw from the same line every time.
- Write the label straight away, and check any you are unsure about.
If your project were about people, for example about how fast pupils can read, you would need their permission, and a parent's, first, and you would collect only what you need, with no names. Never put classmates' details into an online tool. The guide to data and datasets explains labeling and messy data in more detail.
Step 3: Split the data, and keep the test set secret
You cannot test a model fairly on the same throws it learned from, because it might just remember them. So split the rows into three groups before you do anything else:
- Training: the throws the model learns from.
- Validation: throws for checking and choosing while you work.
- Test: throws kept secret until the very end.
Shuffle the rows first so each group gets a fair mix. With 100 throws and a split of 70 for training and 15 for validation, the Dataset Size Calculator gives 70 training, 15 validation and 15 test throws. It also shows the table is tiny: 100 rows x 4 columns = 400 values, which at 8 bytes each is 3,200 bytes, well under 0.01 MB (it shows 0 MB).
Put the 15 test throws somewhere you will not look at them. That is the hardest rule to keep, and the most important.
Step 4: Choose a simple model first
A model is the kind of rule-finder you use. Start simple. You can always try something bigger later, and a simple model is easier to understand when it goes wrong.
The ML Algorithm Selector asks four questions. For our project the answers are: classification (yes or no), labeled data, a small dataset, and we want to be able to explain the result. It suggests a Decision Tree, Logistic Regression and Naive Bayes. As it says, these are starting points: always train a few and compare them on your own data. A decision tree is a good first try because you can read its questions, such as "is the wing wider than 8 cm?".
Step 5: Count what it must learn
Every model has some numbers or questions it must learn from the data. The fewer there are, the fewer examples it needs.
A simple model that gives each of our 4 features a weight, plus one extra number called a bias, has 4 + 1 = 5 numbers to learn. A small decision tree might learn just three or four questions. Both are sensible for 70 training throws. A huge model with thousands of numbers would simply memorize 70 throws, which is called overfitting.
Step 6: Check it will run
Before training, make sure your computer can handle it. For our 3,200-byte table there is nothing to worry about: a small model on data this size trains in moments on any laptop or school computer, or you could even work through a tiny decision tree on paper. Checking first matters more for big projects with millions of rows or pictures.
If you are writing code, the guide to a first machine learning program in Python shows a complete small example.
Step 7: Test honestly, and beat the lazy baseline
Train on the training throws. Use the validation throws to compare models and pick one. Then, once, open the secret test set and count how the chosen model does.
Here is a made-up result for the 15 test throws, 9 of which really went past 5 meters:
| Model says yes | Model says no | |
|---|---|---|
| Really yes (9) | 8 (right) | 1 (missed) |
| Really no (6) | 2 (false alarm) | 4 (right) |
The Model Accuracy Predictor works out accuracy, precision and recall from a table like this. Here accuracy is 12 right out of 15 = 0.8, precision is 8 / 10 = 0.8, and recall is 8 / 9 = 0.8889.
Now compare with a lazy baseline: a "model" that always guesses the commonest answer. Most test throws were "yes", so always saying "yes" gets 9 of 15 right, an accuracy of 0.6. Our model's 0.8 beats that, so it learned something real. If it had not beaten the lazy baseline, it would not be worth using. The guide to accuracy, precision and recall explains why this check matters so much.
Remember that 15 test throws is a small test. One more mistake would change the accuracy a lot, so treat the result as a rough guide.
Step 8: Check who it could be unfair to, then share what you found
Ask: was every kind of example in the data? If every plane was thrown by the same three pupils, or all were made from one kind of paper, the model may not work for other throwers or other paper. For projects about people this matters far more: a model that works for most people and fails for some is unfair to those it fails. Check the results for each group separately. The guide to AI bias and fairness shows how.
Finally, share what you found, including what went wrong. A good project report says:
- the question, and how the data was collected and labeled;
- how the data was split, and that the test set was only used once;
- the model's result and the lazy baseline's result;
- who or what was missing from the data;
- what surprised you, what did not work, and what you would try next.
Saying honestly what did not work is not a weakness in a report. It is what makes the report useful to the next person who tries.