
Key takeaways
In the Vietnamese tale of Tam and Cam, a fairy sends a flock of sparrows to separate paddy from rice. In data-science terms, the birds solve a classification problem.
If the fairy first shows the birds labelled examples, that is supervised learning: accurate and easy to evaluate, but it needs labelling work and is only as good as its training set.
If the birds group similar grains on their own and Tam names the piles, that is unsupervised learning, or clustering: no labels needed, but no guarantee the clusters match what you want.
A confusion matrix, precision and recall show how well the birds did; which error costs more is a business question, not a technical one.
A Python experiment shows that 20 labelled grains are enough for 99.7% accuracy on an easy problem, that scaling features cuts K-Means errors from 71 to 4, and that on a hard problem more labelled data stalls at about 73% unless the birds can see new features.
The story does not end when the basket is sorted. Next season the grains change, the model fails silently, and someone has to monitor it and retrain it.
Once upon a time, in a fairy tale that has shaped generations of Vietnamese readers (Nguyễn Đổng Chi, 2000), there lived a gentle girl named Tam who suffered at the hands of her stepmother and her stepsister Cam. Vietnam's own Cinderella story reaches its cruellest point when the village holds a festival: the stepmother mixes paddy (unhusked rice) with husked rice in one basket and tells Tam she may go only after sorting it, "paddy with paddy, rice with rice". The task seems impossible. As Tam sits weeping, Bụt, the kindly old sage of Vietnamese folk tales, appears and, by magic, sends a flock of sparrows to help. In moments the birds have sorted every grain, and Tam can get ready for the festival. (In some versions the rice is mixed with beans rather than paddy; this article follows the popular version.)
The magic is wonderful. But what if we take off our fairy-tale glasses and look at the scene with the eyes of a twenty-first-century data scientist? The fairy's sparrows have, in essence, solved a classification problem: assigning each grain to one of two groups known in advance. And the way the fairy "directs" the flock maps neatly onto two foundational methods of machine learning: supervised learning and unsupervised learning.
The article "decodes" the magic in eight parts. Section 1 translates the story into the language of data. Section 2 retells the sorting as supervised learning, and Section 3 as unsupervised learning. Section 4 asks how accurately the birds sorted, using a confusion matrix. Section 5 tries both approaches in a few lines of Python, Section 6 discusses how many labelled grains are needed, Section 7 introduces other ways of learning beyond these two, and Section 8 follows the story into the next season, when the grains no longer look like last year's.
1. Framing the data problem
Before choosing a method, translate the story into data-science terms. Every data professional does this for every problem: name each component correctly. Table 1 shows the translation.
One could liken the fairy to a data engineer or a data scientist. Strictly, the role is closer to a data scientist: a data engineer builds the "pipelines" that get data to the right place, whereas here the fairy decides how to teach the birds and checks whether they got it right.
So which method did the fairy use to "train" the flock? There are two scenarios, and Figure 1 sets them side by side.

2. Scenario one: supervised learning, with the fairy as a dedicated teacher
In supervised learning, the model is "taught" with labelled data: every example comes with its answer, just as we study from a textbook with an answer key.
2.1. The fairy's three steps
Step 1: prepare the training data. Instead of letting the birds rush in, the fairy takes a small handful from the basket and carefully "labels" each grain. He holds one up and tells the birds: "This is paddy: longer, dark yellow husk, hard." Then another: "This is rice: shorter, white, translucent." This set of clearly identified grains is the training set.
Step 2: train the model. The birds "learn" from these examples, memorising the relationship between the features (size, shape, colour, hardness) and the labels (paddy, rice). The result is a rule, such as "long, dark grains are paddy", stored in the flock's "brain". That is the trained model.
Step 3: deploy and classify. Having "graduated" from the fairy's course, the birds are released into the whole basket. For each grain, they look at its features, compare them with the learned rule and predict: "This one is short and white… almost certainly rice." Into the rice basket it goes, and so on until the whole basket is sorted.
2.2. Strengths, weaknesses and a trap
The strength of this approach is that the birds know exactly what they are looking for, so accuracy is usually high. And because there are answers, the fairy can evaluate the result objectively by counting how many grains were sorted correctly (Section 4).
The weakness is the up-front effort of building a labelled dataset. A few dozen grains are easy; millions of emails, or millions of medical images that need a doctor to read them, can make labelling very expensive.
There is a trap that few notice: a model is only as good as its training set. Suppose the basket contains a little brown rice, almost as dark as paddy, but the handful the fairy picked happened to contain only white rice. The birds have never seen brown rice and will easily drop it into the paddy basket. This is selection bias: the model learns well on its training data but fails on cases absent from it. In practice, many face-recognition systems make far more errors for groups that appear rarely in their training data.
But what if the fairy has no time to teach grain by grain? That is the second scenario.
3. Scenario two: unsupervised learning, with the flock discovering on its own
In unsupervised learning, the model must find structure and patterns in data without any labels, like being handed a box of multicoloured LEGO bricks and told to sort them into groups with no instructions.
3.1. The flock's three steps
Step 1: receive raw data. The fairy simply appears, points at the basket and commands: "Birds, put grains that look alike into groups!" He never says what paddy or rice is. The birds have no information about the names of the grains.
Step 2: cluster. The birds compare grains with one another by their features. One bird starts with a short, white grain and gathers others that are also short and white; another picks up a long, dark, hard grain and looks for similar ones. Gradually clusters form. This is clustering.
Step 3: interpret the result. When the birds finish, Tam has several separate piles in front of her. The birds know only "pile one" and "pile two". It is Tam, a human, who looks and assigns meaning: "Ah, this pile is all short, white grains, so it's rice. That one is long, dark grains, so it's paddy."
3.2. Classification or clustering?
Step 3 reveals an important distinction. The output of unsupervised learning is clustering, not classification. Classification assigns items to groups named in advance; clustering creates groups itself, and people name them afterwards. Table 2 compares the two scenarios.
3.3. Strengths and weaknesses
The biggest strength is that no labelling is needed, and the model can find unexpected groups nobody thought of. The birds might create three clusters rather than two, and Tam discovers the third is empty, shrivelled grains, something the stepmother never mentioned. In business, this is how companies find customer segments they have never named.
The weakness is that nothing guarantees the clusters match the groups you need. Results depend heavily on which features are chosen and how "similarity" is measured. If the birds look only at colour, brown rice and paddy may end up in the same cluster. Section 5 shows how a small decision about measurement can change the result dramatically.
Whichever way the birds are taught, the final question remains: how well did they do?
4. Evaluation: how many grains did the birds get right?
In the story, the birds are perfect. In real life, no model is. Suppose the basket holds 1,000 grains, 500 paddy and 500 rice, and the birds' results are as in Table 3 (illustrative figures).
Table 3 is a confusion matrix: each cell counts grains by the pair "true type – predicted type". Three common metrics follow:
Accuracy = (480 + 490) / 1,000 = 97%: the share of grains sorted correctly.
Precision of the rice basket: of the 510 grains the birds put in the rice basket, 490 really are rice, about 96%. Precision answers: "How clean is the rice basket?"
Recall of the rice basket: of the 500 real rice grains, the birds picked 490, or 98%. Recall answers: "How much rice was missed?"
For Tam, which error is worse: paddy in the rice basket (cooked rice with husks in it) or rice in the paddy basket (losing a little rice)? If Tam hates biting on paddy most, she needs very high precision for the rice basket, even at the cost of missing a little more rice. The question "which error is more expensive?" is a business question, not a technical one, and it decides which metric to prioritise. In spam filtering, letting a spam message through does less harm than blocking an important email; in cancer screening, missing a case does far more harm than a false alarm.
Enough theory. Let the computer play the birds.
5. Trying it in Python
The code below simulates 1,000 grains with two features: length (mm) and colour brightness (0 dark to 1 light). Paddy is assumed to be longer and darker than rice. The code then tries both approaches: supervised learning with logistic regression and unsupervised learning with the K-Means algorithm (scikit-learn developers, n.d.). Both techniques are covered in depth by James et al. (2021) and Géron (2022).
```python from collections import Counter import numpy as np from sklearn.cluster import KMeans from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler
rng = np.random.default_rng(1)
paddy = np.column_stack([rng.normal(8.0, 0.6, 500), rng.normal(0.55, 0.08, 500)]) rice = np.column_stack([rng.normal(6.5, 0.5, 500), rng.normal(0.90, 0.05, 500)]) X = np.vstack([paddy, rice]) y = np.array(["paddy"] * 500 + ["rice"] * 500) X_scaled = StandardScaler().fit_transform(X) # put both features on the same scale
sample = np.r_[0:10, 500:510] birds = LogisticRegression().fit(X_scaled[sample], y[sample]) print("Supervised - accuracy:", round((birds.predict(X_scaled) == y).mean(), 3))
for name, data in [("unscaled", X), ("scaled", X_scaled)]: clusters = KMeans(n_clusters=2, n_init=10, random_state=0).fit_predict(data) print("Unsupervised,", name) for k in (0, 1): print(" Cluster", k, ":", dict(Counter(y[clusters == k].tolist()))) ```
The output:
`` Supervised - accuracy: 0.997 Unsupervised, unscaled Cluster 0 : {'paddy': 38, 'rice': 467} Cluster 1 : {'paddy': 462, 'rice': 33} Unsupervised, scaled Cluster 0 : {'paddy': 4, 'rice': 500} Cluster 1 : {'paddy': 496} ``
Figure 2 plots the K-Means results in both cases.

Three lessons follow.
First, with only 20 labelled grains, supervised learning classified 99.7% correctly. The two types of grain in the simulation differ clearly, so a few examples are enough for the birds to learn the boundary.
Second, unsupervised learning still separated two groups without labels, but on unscaled data it misassigned 71 grains. The left half of Figure 2 shows why: K-Means measures "similarity" by distance, and length in millimetres (varying by a few mm) swamps brightness (varying by a few hundredths). The algorithm looks almost only at length and cuts the groups with a nearly vertical line, ignoring the very clear difference in colour.
Third, after scaling both features to the same scale, K-Means misassigned only 4 grains. How you prepare the data matters as much as which algorithm you choose.
One final note: K-Means only returns "cluster 0" and "cluster 1". We know which cluster is rice because we compared it with the true labels, just as Tam had to look at the piles to name them. In practice, when there are no true labels to compare, interpreting clusters requires domain knowledge.
6. How many sample grains does the fairy need?
The example in Section 5 looks too easy: just 20 labelled grains and almost perfect accuracy. Is that always so? Figure 3 answers with a simulation: varying the number of labelled grains from 2 to 500, repeated 200 times with random handfuls, for two problems. The easy problem is paddy versus rice as above. The hard problem is two rice varieties with almost the same length and colour.

Figure 3 shows two things. On the easy problem, just two sample grains (one of each) reach about 98%; more data barely helps. On the hard problem, accuracy rises from about 60% to about 70% with 20 grains, then plateaus around 73% even with hundreds more.
The second finding is the important lesson: when two types of grain really are alike in the features the birds can see, no amount of extra teaching overcomes that limit. To do better, the fairy must let the birds see new features: smell, stickiness when bitten, the shape of the grain's tip. Real projects are the same. When a model has plateaued, collecting more of the same data is usually less effective than finding new information about the objects. So "How much data do we need?" has no universal answer; it depends on how hard the problem is and how good the features are.
7. Beyond these two ways of learning
Supervised and unsupervised learning are the two foundational ways of learning, but not the only ones. Three others are used increasingly, and each can be retold with the fairy's story, as Table 4 shows.
Self-supervised learning deserves a word more, because it underlies large language models such as ChatGPT, Claude and Gemini. Nobody labels billions of sentences; the model hides the next word and guesses it, and the text itself provides the answer. In form this is supervised learning (there is an answer to compare with); in origin it uses data nobody labelled. The boundaries between ways of learning are not as rigid as textbook definitions suggest.
The ways of learning differ mainly in one respect: how much the machine is told about the right answer. Choosing one therefore starts with asking what kind of data the business already has, not which algorithm is fashionable. With historical data and known answers, supervised learning applies; it creates most of the business value of machine learning today because it answers questions with measurable outcomes. With only unlabelled data, unsupervised learning can find groups, but an algorithm always returns clusters, even when they mean nothing commercially, and a person still decides which clusters deserve action. Reinforcement learning is harder to use than it looks. AlphaGo, the first program to beat a professional Go player on a full board, learned from human games and then from tens of millions of positions in games against itself (Silver et al., 2016). A business cannot try a million prices on real customers.
Table 5 summarises the main concepts for quick reference.
8. Next season: the life cycle of a model
The fairy tale ends when the birds finish sorting. A real machine-learning project does not: the day a model goes live is when most of the cost begins. This section carries the story into the next season.
8.1. Six steps, one loop
Figure 4 lays out the steps of a machine-learning project as a life cycle in which the last step loops back to the middle.

The first five steps in Figure 4 match what this article has described: the fairy defines the problem (separating paddy from rice), picks a handful of sample grains, teaches the birds, counts their mistakes with a confusion matrix, and releases them on the real basket. The sixth step, monitoring, is the one a fairy tale does not need and every real system does. A group of Google engineers observed that in real machine-learning systems, the code that actually learns and predicts is a small fraction; the rest is data collection and verification, configuration, serving infrastructure and monitoring (Sculley et al., 2015). They called the hidden cost of shortcuts taken to ship fast technical debt: every shortcut today becomes maintenance cost tomorrow.
8.2. When next season's grains are different
Suppose that next year the stepmother switches to a new rice variety whose paddy is shorter and lighter, closer to husked rice. The birds keep sorting by what they learned last year, so they start leaving paddy in the rice bowl. Nobody raises an alarm: the birds sort as fast as ever, and only the rice bowl fills with more stray paddy. This is data drift: the world changes and the model does not. Models fail silently; they do not stop, they simply predict worse and worse.
For an online shop's fraud model, minimum monitoring has three parts. First, track the share of orders flagged each week, because a sudden change signals drift. Second, compare predictions with real labels when they arrive, for example when the bank reports chargebacks. Third, set in advance a drop in recall that triggers retraining. All three need a named owner, because a task that "everyone" looks after usually ends up looked after by no one.
8.3. Questions before spending money
Table 6 turns the concepts in this article into questions to ask a data team or vendor before approving a machine-learning project. A vague answer to any question marks something to clarify before spending money.
The last question in Table 6 is the one most often skipped, because it never appears in a demo; it only shows up months after the model has gone live.
Conclusion: what magic really happened?
Given the perfect result and miraculous speed in the story, the fairy's magic most likely worked like supervised learning: the sparrows were a well-trained model that knew exactly what paddy and rice were. If the fairy wanted to challenge the flock a little more, he could have used unsupervised learning, letting the birds work out the basket's structure on their own and leaving Tam to name each pile.
But to retell the story accurately for today's data science, the real magic is not in the birds. It lies in what the fairy does before and after: choosing a representative handful of samples, deciding which features the birds should look at, measuring those features on the same scale, and checking whether the rice basket still has husks in it. Those are also the tasks that take up most of a data professional's time.
A seemingly simple folk tale holds a deep connection to the foundations of modern artificial intelligence. It shows that the idea of "teaching" another being to recognise and sort the world has long existed in human imagination. Next time you reread a fairy tale, you may find another technological idea hiding inside it.
References
Géron, A. (2022). Hands-on machine learning with Scikit-Learn, Keras, and TensorFlow (3rd ed.). O'Reilly Media. https://www.oreilly.com/library/view/hands-on-machine-learning/9781098125967/
James, G., Witten, D., Hastie, T., & Tibshirani, R. (2021). An introduction to statistical learning (2nd ed.). Springer. https://www.statlearning.com/
Nguyễn Đổng Chi. (2000). Kho tàng truyện cổ tích Việt Nam [A treasury of Vietnamese folk tales]. Nhà xuất bản Giáo dục. https://www.amazon.com/s?k=Kho+t%C3%A0ng+truy%E1%BB%87n+c%E1%BB%95+t%C3%ADch+Vi%E1%BB%87t+Nam+Nguy%E1%BB%85n+%C4%90%E1%BB%95ng+Chi&i=stripbooks
scikit-learn developers. (n.d.). Clustering: K-Means. https://scikit-learn.org/stable/modules/clustering.html#k-means
Sculley, D., Holt, G., Golovin, D., Davydov, E., Phillips, T., Ebner, D., Chaudhary, V., Young, M., Crespo, J.-F., & Dennison, D. (2015). Hidden technical debt in machine learning systems. Advances in Neural Information Processing Systems, 28, 2503–2511. https://proceedings.neurips.cc/paper/2015/hash/86df7dcfd896fcaf2674f757a2463eba-Abstract.html
Silver, D., Huang, A., Maddison, C. J., Guez, A., Sifre, L., van den Driessche, G., Schrittwieser, J., Antonoglou, I., Panneershelvam, V., Lanctot, M., Dieleman, S., Grewe, D., Nham, J., Kalchbrenner, N., Sutskever, I., Lillicrap, T., Leach, M., Kavukcuoglu, K., Graepel, T., & Hassabis, D. (2016). Mastering the game of Go with deep neural networks and tree search. Nature, 529(7587), 484–489. https://doi.org/10.1038/nature16961

