GIFSQ ID: FTN-0089
Artificial Intelligence in Food Industry
Unit 1: What Artificial Intelligence Is and Where It Fits in Food
Note
Unit 1: What Artificial Intelligence Is and Where It Fits in Food
A question to start with
A bakery makes bread in the same way every morning: flour, water, yeast, salt, mixing, proving, baking. One week the loaves come out different each day, some pale, some dark, some flat. The baker checks the oven temperature, the flour, the yeast, and the mixing time, and finds nothing clearly wrong. Then a new system is switched on. It records the temperature of the dough, the humidity in the room, the age of the flour, and the colour of every loaf that leaves the oven. After a few weeks it starts to warn the baker: when the room is humid and the flour is old, shorten the proving time by a few minutes. The loaves become steady again. No new oven was bought, and no new recipe was written. What changed was the use of records that were already there, turned into a warning at the right moment. That is the heart of this subject: machines that learn from food data and help people make better food decisions.
Artificial intelligence, usually shortened to AI, is the name for computer systems that carry out tasks which normally need human judgement: recognising a pattern, making a prediction, sorting things into groups, or choosing an action. A calculator adds numbers, and a spreadsheet stores numbers. An AI system looks at many examples and finds a rule in them, then uses that rule on new examples it has never seen. In food, the examples are things a food business already produces every day: temperatures, weights, colours, taste scores, lab results, sales records, and photographs of products.
This subject is about AI in the food industry, and it stays close to real food work. It does not ask you to become a computer programmer. It asks you to understand what AI can do with food data, where it helps, where it fails, and how a food professional works with it. Every unit follows the same path: a plain explanation, a food example, a check of your own understanding, and a small activity you can try with ordinary tools.
Questions to think about
- A sorting machine rejects a tomato that looks fine to your eye. How would you decide whether the machine or your eye is right?
- A bakery, a dairy plant, and a grain store all collect temperature records. What could each of them learn from those records that a person watching one day at a time would miss?
- If a computer predicts that a batch of yoghurt will spoil two days early, what should a food professional do before acting on that prediction?
Think about the tomato question before you read on
Neither the machine nor your eye is right by itself. The test is a set of tomatoes whose true quality is already known, checked by cutting, tasting, and lab testing. Run both the machine and the human on that set, count the mistakes each one makes, and compare. A machine that is right more often, and makes the same kind of judgement every time, is useful even when it disagrees with one person on one tomato. The decision is made with measured results, not with a feeling about which one to trust.
What AI means in plain words
AI is a broad name, and it helps to split it into three plain ideas. First, a system takes in data: numbers, words, pictures, or sounds. Second, it finds a pattern in that data, either from rules written by a person or from examples it has been shown. Third, it uses that pattern to do something: sort, predict, warn, or recommend. A system that only follows fixed rules, such as "if the temperature passes a set limit, sound an alarm", is a simple automatic system, not AI. It becomes AI when the limit, the rule, or the judgement itself is learned from data and can change as more data arrives.
Consider a cold store for apples. A fixed alarm rings when the temperature rises above a set value. An AI system looks at the temperature record, the humidity, the door opening times, and the history of spoilage, and learns that spoilage rises fastest when warm air enters just after a delivery on a humid day. It then warns the manager before the temperature limit is even reached, and suggests closing a door or moving a pallet. The alarm reacts to one number. The AI system reacts to a pattern across many numbers.
Three words appear again and again in this subject, and they are worth fixing now. Data is the record of what happened: measurements, photographs, labels, sales. A model is the pattern a computer has learned from data, kept in a form the computer can use again. A prediction is what the model says about a new case: this loaf will be dark, this milk will sour soon, this tomato belongs in the top grade. A model is never perfect. It is judged by how often its predictions are right on new cases, and by what its mistakes cost.
The diagram shows the five steps in order. The steps point to the diagram: step 4, testing on new cases, is the step that separates a system that works from a system that only remembers its training examples.
Quick self-check
Question: A fridge alarm rings at a fixed temperature. Is that AI?
No. It follows one fixed rule written by a person, and it never learns. It becomes AI only when the warning itself is learned from past data, such as learning which combinations of temperature, humidity, and door openings lead to spoilage.
Question: What is the difference between data and a model?
Data is the record of what happened. A model is the pattern learned from that data, stored so the computer can use it on new cases. Data is the past; a model is a way of using the past to judge the future.
Where AI already fits in food work
AI fits wherever food work produces records and repeats a judgement. That covers most of a food business. In farming and storage, it reads weather and soil records and helps plan harvest and storage. In processing, it watches temperatures, pressures, and flow rates and warns when a process drifts. In quality control, it looks at photographs of products and sorts them by size, colour, or damage. In safety, it reads lab results and supplier records and flags batches that need a closer check. In the supply chain, it reads sales records and helps plan how much to make and where to send it. In product development, it reads recipe records and taste panel scores and suggests the next recipe to try.
None of these uses replaces the food professional. Each one changes the job: instead of watching one gauge, the person watches a system that watches many gauges, and instead of sorting every tomato by hand, the person checks the sorter's mistakes and teaches it with better examples. The skill that matters most is judgement about data: knowing which records are trustworthy, which question the system is really answering, and what to do when its answer disagrees with a lab test or with experience.
A useful way to sort AI uses in food is by the question they answer. Some answer a sorting question: which grade is this fruit? Some answer a prediction question: will this batch keep for five days or seven? Some answer a warning question: is this process drifting out of control? Some answer a planning question: how much should we make tomorrow? The rest of this subject takes one kind of question at a time, so that each tool is learned in the place where it belongs.
Quick self-check
Question: Name three places in a food business where records are already collected every day.
Any three of these count: temperature logs in a cold store, weights at reception, lab results, production line speeds, sales records, customer complaints, photographs of finished products. The point is that AI in food usually starts from records a business already keeps, not from new equipment alone.
Question: Why does AI change the food professional's job instead of removing it?
Because someone must still decide which data to trust, which question to ask, and what to do when the system is wrong. The machine finds the pattern; the person carries the responsibility for the food, the safety, and the decision.
Data: the raw material of AI
Every AI system is only as good as its data. In food, data comes in several forms. Numbers are the most common: temperatures, weights, pH values, moisture percentages, counts of microbes. Photographs are data too: a picture of a loaf, a tomato, or a pack seal carries information about colour, shape, and damage. Words are data: a label, a complaint, a taste panel note. Time is data: the hour a batch was made, the day a delivery arrived, the season a crop was harvested.
Good food data has four qualities. It is accurate: the thermometer was calibrated and the weight was recorded correctly. It is complete: missing days and missing batches leave holes the model cannot fill. It is labelled: someone has recorded which batches were good and which were spoiled, so the computer can learn the difference. It is representative: it covers the full range of real conditions, including hot days, old flour, and tired operators, not only the easy days. A model trained only on perfect days will fail on the first difficult day, and that failure will happen in real production, not in a test.
Bad data causes a particular kind of failure. If every spoiled batch in the records came from one supplier, the model may learn to blame the supplier instead of learning the real cause, such as a storage temperature that was also different. If the labels are wrong, if a batch marked good was in fact spoiled, the model learns the wrong lesson and repeats it confidently. This is why the first job in any AI project in food is not building a model. It is checking the records, cleaning them, and making sure the labels are true.
Quick self-check
Question: A model is trained only on summer data. What happens in winter?
It is likely to fail, because winter conditions fall outside the range it learned from. Cold rooms behave differently, raw materials change, and the patterns of spoilage shift. Representative data must cover all seasons and conditions the system will meet in real use.
Question: Why does a wrong label matter more than a missing record?
A missing record is a hole the model can work around. A wrong label teaches the model a false lesson, and the model will then apply that false lesson to new cases with confidence. Wrong labels are worse than missing data.
How a model learns, in one simple picture
Imagine a teacher showing a child many photographs of apples and oranges and naming each one. After enough examples, the child can name a new fruit it has never seen. A computer model learns in a similar way, except the examples are numbers and the naming is a calculation. The model is shown many examples, each with its correct label, and it adjusts itself a little at a time until its answers match the labels most of the time. This is called supervised learning, and Unit 2 explains it in full.
Other models learn without labels. They are shown many examples and asked to find groups in them: these yoghurts cluster together, those cluster apart. That is useful when nobody has labelled the data yet, for example when a taste panel has scored many products and the groups in the scores are not yet understood. A third kind of model learns by trying actions and keeping score: it tries a small change in a process, sees whether the result improves, and keeps the changes that help. That is useful for tuning a process step by step.
The same warning applies to all three kinds. A model that has memorised its training examples, word for word, will look perfect in training and fail on new cases. The test that matters is always the same: fresh examples the model has never seen, judged against the truth, not against the model's own memory. A food professional should always ask for that test result before trusting a system, and should ask how the test cases were chosen.
The diagram shows the three ways of learning. The steps point to the diagram: most food quality work uses the first way, labelled examples, because food businesses already label batches as good or spoiled.
Quick self-check
Question: A model scores 100 percent on its training data and 60 percent on new data. What has happened?
It has memorised the training examples instead of learning the real pattern. The training score is meaningless here; the new-data score is the true measure, and 60 percent means the model is not ready for use.
What AI cannot do, and why that matters from the start
AI cannot taste food, smell a spoilage gas, or feel whether dough is ready. It can only work with the measurements it is given, and a measurement is never the whole food. A photograph shows colour and shape, not flavour. A temperature log shows heat, not the microbes that heat allows to grow. A sales record shows what people bought, not why they bought it. Every AI system in food has this blind spot, and the food professional's job is to know where it lies.
AI also cannot take responsibility. When a batch is released, a person signs for it, not a model. When a consumer falls ill, the question is what the people in charge did, not what the computer suggested. This is why AI in food is built as a helper with a human check, not as an automatic decider. The system suggests, warns, and sorts; the person decides, checks, and signs.
Finally, AI cannot fix bad practice. If a cold store is broken, if records are faked, if samples are taken badly, no model will save the food. It will learn the broken pattern and repeat it. The units that follow keep returning to this point: AI works best in a business that already measures carefully, records honestly, and checks its own work. Where those habits are weak, the first investment is in the habits, not in the software.
Quick self-check
Question: A camera grades apples by colour. What can it miss that a person would catch?
Flavour, texture, internal damage, smell, and any fault that does not change the outside colour. The camera only sees what the photograph shows, so its grading is limited to visible signs.
Question: Why must a person still sign off a batch that an AI system has passed?
Because responsibility stays with people. The system gives a suggestion based on its data; the person weighs that suggestion against lab results, experience, and the rules that govern the food, and takes the decision.
A first map of the subject
The rest of this subject follows the food chain. Unit 2 explains machine learning in plain terms: how models learn from food data, how they are tested, and how to spot a model that has only memorised its examples. Unit 3 covers computer vision: how a camera and a model judge the look of food, from fruit grading to pack seals. Unit 4 turns to safety and quality control: finding contamination, predicting spoilage, and catching a process that is drifting. Unit 5 covers processing and production planning: tuning ovens, mixers, and dryers, and planning the day's production. Unit 6 covers the supply chain: forecasting demand, moving stock, and cutting waste. Unit 7 steps back and asks about limits, ethics, jobs, and the future, so that you can judge new AI claims with a clear head.
Read the units in order the first time. Each one builds on the words and ideas of the one before it, and the glossary at the end of each unit collects the terms you will need next. If a term is unfamiliar, look it up in the glossary of the unit where it first appears, not in a general dictionary: the food example there is the meaning that matters here.
Quick self-check
Question: Which unit would you read to learn how a camera grades fruit?
Unit 3, on computer vision. It covers how photographs are turned into judgements about colour, size, shape, and damage.
Question: Which unit covers forecasting how much food to make tomorrow?
Unit 6, on supply chain, demand forecasting, and reducing waste.
Try it yourself
Pick one food you know well: bread, milk, rice, apples, or biscuits. On one page, list every record that food already produces in a normal week: temperatures, weights, times, lab results, photographs, sales, complaints. Next to each record, write one question an AI system could try to answer with it, and one thing it could never learn from that record alone. Then circle the record you trust most and the record you trust least, and write one sentence for each explaining why. Bring the page to your next class discussion and compare it with a classmate who chose a different food: which records appear in both lists, and which are special to one food only?
Key ideas to carry forward
- AI is a computer system that learns a pattern from data and uses it to sort, predict, warn, or recommend.
- A fixed alarm that follows one rule is automation, not AI: AI learns its rule from data and can change it as more data arrives.
- Data is the record of what happened, a model is the pattern learned from data, and a prediction is what the model says about a new case.
- Good data is accurate, complete, labelled, and representative of all the conditions the system will meet.
- Models are tested on new cases they have never seen: a high score on training data alone proves nothing.
- AI fits wherever food work produces records and repeats a judgement: farming, processing, quality, safety, supply, and product development.
- AI cannot taste, smell, or take responsibility: a person still decides, checks, and signs.
- AI cannot fix bad practice: it learns the pattern it is given, including a broken one.
Glossary
Algorithm
A set of steps a computer follows to carry out a task or find a pattern. Food tech example: the steps a sorting machine follows to decide whether a tomato is ripe are an algorithm.
Artificial intelligence (AI)
Computer systems that carry out tasks needing judgement, such as recognising patterns, making predictions, and sorting things into groups. Food tech example: a system that predicts which milk batches will sour early is an AI system.
Data
Records of what happened: measurements, photographs, words, and times. Food tech example: daily temperature logs from a cold store are data.
Label
The correct answer attached to an example, so a model can learn from it. Food tech example: marking each loaf photograph as good or burnt gives the model its labels.
Machine learning
The part of AI in which a computer learns a pattern from examples instead of following only fixed rules written by a person. Food tech example: a model that learns from past batches which dough conditions give a good loaf uses machine learning.
Model
The pattern a computer has learned from data, kept in a form it can use again on new cases. Food tech example: a trained model that grades apples from photographs is used on every new apple that passes the camera.
Prediction
What a model says about a new case it has not seen before. Food tech example: a prediction that a batch of yoghurt will keep for six days.
Representative data
Data that covers the full range of real conditions, not only the easy or common ones. Food tech example: training data that includes hot days, old flour, and different operators is representative.
Supervised learning
Learning from examples that already carry their correct labels. Food tech example: learning to spot spoiled milk from samples already labelled fresh or spoiled.
Unsupervised learning
Learning from examples without labels, by finding groups and patterns in the data itself. Food tech example: grouping taste panel scores to find clusters of similar biscuits without any pre-set groups.
Training data
The examples a model learns from. Food tech example: a thousand photographs of tomatoes, each labelled by grade, are the training data for a grading model.
Test data
Fresh examples a model has never seen, used to check how well it really works. Food tech example: a new set of tomato photographs, kept aside during training, is the test data.
Overfitting
When a model memorises its training examples instead of learning the real pattern, so it fails on new cases. Food tech example: a model that remembers each training loaf photograph exactly but cannot judge a new loaf has overfitted.
Automation
Machines or software carrying out a fixed task by fixed rules, without learning. Food tech example: a filler that puts the same weight of jam in every jar is automation.
Sensor
A device that measures a physical property, such as temperature, weight, or colour, and records it as data. Food tech example: a temperature sensor in a cold store records the temperature every few minutes.
References
- Irudayaraj, J., Food Processing Operations Modeling, Design, and Analysis, 2nd edition, 2002.
- Singh, R. P., Computer Applications in Food Technology, 1996.
Unit 2: Machine Learning Basics: Learning from Food Data
Note
Unit 2: Machine Learning Basics: Learning from Food Data
A question to start with
A dairy plant tests every tanker of milk that arrives. For years, the lab has recorded the same things: temperature on arrival, acidity, fat, protein, and the count of bacteria after a standard test. One tanker in twenty is rejected, but nobody can say in advance which one it will be. A new team takes three years of those records, all already sitting in filing cabinets and spreadsheets, and builds a model from them. The model does not test the milk. It reads the temperature, acidity, fat, and protein of a new tanker and gives a score: how likely is this tanker to fail the bacteria test? The plant starts holding the high-score tankers for a fast check while the low-score tankers go straight to processing. Rejections fall, waiting time falls, and the lab does fewer wasted tests. The milk did not change. The records did not change. What changed was that the pattern hidden in the records was finally used. This unit explains how that pattern is found, how it is tested, and how to tell a sound model from a lucky one.
Machine learning is the part of artificial intelligence in which a computer learns a pattern from examples instead of following only fixed rules written by a person. The person still matters: the person chooses the question, gathers the examples, checks the labels, and judges the result. The computer does the part a person cannot do by hand: weighing many measurements at once, across thousands of examples, and finding the combination that separates good from bad, or predicts a number from the measurements that lead to it.
Questions to think about
- A model predicts the protein content of wheat from its colour and weight. What examples would it need to learn from, and what would count as a fair test of it?
- Two models both claim to spot spoiled milk. One was tested on milk from the same week it was trained on, the other on milk from a later month. Which test tells you more, and why?
- A factory has ten years of records, but the recipe changed three years ago. Should all ten years be used to train the model?
Think about the recipe-change question before you read on
Probably not, or not without care. The old recipe produced a different relationship between the measurements and the result, so old examples can teach the model a pattern that no longer holds. The safe move is to train mainly on data from the current recipe, and to test whether adding old data helps or harms the result on new cases. Data is not better simply because there is more of it: data must match the conditions the model will work in.
Features, labels, and the shape of a food problem
Every machine learning problem in food starts by turning a real question into a table. Each row of the table is one example: one tanker, one loaf, one batch, one apple. Each column is a feature, a measurement that might help answer the question: temperature, acidity, weight, colour, time, flour age. One column is the label, the answer the model must learn to give: rejected or accepted, good or spoiled, the protein percentage, the number of days the food will keep.
This step, turning a food question into rows, features, and a label, is the most important step in the whole unit, and it is done by a food professional, not by the computer. A bad choice of label ruins everything that follows. If the label is "the operator thought the batch looked fine", the model learns the operator's habits, including the operator's mistakes. If the label is a lab result, the model learns the lab result. If the label is missing for half the rows, those rows cannot teach the model anything about the answer, however rich their measurements are.
Features need the same care. A feature that is recorded after the answer is known is useless for prediction: the final loaf colour cannot predict the loaf colour. A feature that is a copy of the label in disguise, such as a "spoilage flag" set by the same test the model is meant to predict, will make the model look perfect in training and useless in real use. This trap has a name, leakage, and it is one of the most common mistakes in food machine learning. The check is simple to state and hard to keep: every feature must be known at the moment the prediction will be made, and none of it may carry the answer inside it.
The diagram shows how a question becomes a table. The steps point to the diagram: the label must be a real measured outcome, and every feature must be known before the prediction is needed.
Quick self-check
Question: A model predicts loaf quality from the final loaf weight. Is final weight a good feature?
It can be, if the weight is known at the time the prediction is needed. If the prediction must be made before baking, the final weight is not yet known, so it cannot be a feature. A feature must be available when the prediction is made.
Question: What is leakage, in plain words?
Leakage is when a feature carries the answer inside it, so the model looks perfect in training but cannot work in real use, where that feature is not yet known. An example is using the lab result itself, or a flag set from it, to predict that same lab result.
Supervised learning: learning from labelled examples
Supervised learning is learning from examples that already carry their correct labels. It is the workhorse of food machine learning, because food businesses label things all the time: pass or fail, grade A or grade B, fresh or spoiled. Supervised learning splits into two kinds. Classification sorts examples into groups: accept or reject, ripe or unripe, grade 1, 2, or 3. Regression predicts a number: protein percentage, moisture percentage, days of shelf life, the weight of a batch after drying.
In classification, the model learns a boundary. Picture the tankers from the opening story plotted on a chart, with acidity on one side and temperature on the other. The failed tankers cluster in one corner, the passed tankers in another, and the model draws a line between them. A new tanker falls on one side of the line or the other, and that side is the prediction. Real models use many features at once, so the line becomes a surface in many dimensions, but the idea is the same: learn where the boundary lies from labelled examples.
In regression, the model learns a relationship. Picture flour moisture plotted against the amount of water needed in the dough. The points rise in a rough line, and the model learns that line. A new flour sample, with its moisture measured, gives a point on the line, and the reading off the line is the predicted water amount. When the relationship is curved, or when many features act together, the model learns a more complex shape, but it is still a shape fitted to labelled points.
Both kinds are judged the same way: on new examples. A classification model is judged by how many new examples it sorts correctly, and by which mistakes it makes. A regression model is judged by how close its predicted numbers are to the true numbers on new examples. A model that is right on its training examples but wrong on new ones has not learned the pattern: it has memorised the examples.
Quick self-check
Question: Is predicting the moisture percentage of a biscuit classification or regression?
Regression, because the answer is a number. Classification would sort the biscuit into groups, such as dry, normal, or damp.
Question: Is sorting apples into grade 1, 2, and 3 classification or regression?
Classification, because the answer is a group, not a number. The model chooses one of three labels for each apple.
Unsupervised learning: finding groups without labels
Unsupervised learning works without labels. The computer is given many examples and asked to find the groups, patterns, or odd cases inside them. This is useful when nobody has labelled the data yet, or when the question itself is "what groups are there?" A taste panel scores twenty new biscuit recipes on sweetness, crunch, and flavour. Nobody has said which recipes are good. An unsupervised method groups the recipes by their scores, and the food team sees three clusters: sweet and soft, plain and crunchy, and rich and crumbly. The groups then guide which recipes to develop further.
Another unsupervised use is finding the odd one out. Most batches from a line look alike in their measurements. One batch sits far from all the others: its temperature trace is different, its weight is off, its colour is unusual. The method flags it as an anomaly, a case that does not fit the usual pattern. The flag does not say what went wrong. It says "look here", and a person investigates. In a food plant, that early flag can catch a failing sensor, a wrong ingredient, or a process drift before it becomes a full batch failure.
Unsupervised methods need the same caution as supervised ones. A group found in the data is not proof of a real difference in the food: it may reflect the day the samples were tested, the person who scored them, or the instrument that measured them. The check is always to go back to the food: do the groups match something real, such as a recipe change, a supplier change, or a storage difference? If they match only the date on the record, the grouping is an artefact of the records, not a discovery about the food.
Quick self-check
Question: A taste panel scores new biscuits and a method finds three clusters. What should the team do next?
Check whether the clusters match something real in the recipes or the tasting, such as sugar level or baking time, and taste one biscuit from each cluster to confirm the difference is real. A cluster alone is a suggestion, not a verdict.
Question: What is an anomaly in a production line?
A batch whose measurements sit far from the usual pattern of all other batches. It is a flag to investigate, not a diagnosis: it says something is different, and a person must find out what.
Training, testing, and the honest split
A model must be tested on examples it has never seen, and the only way to guarantee that is to keep some examples aside from the start. The usual practice is to split the data into two parts before any training begins: a training set, used to teach the model, and a test set, kept locked away until the end. The model is trained on the first part, then judged once on the second part. That single honest test is the number that matters.
The split must respect time and grouping. If the test set is picked at random from the same weeks as the training set, the test is too easy: the model has seen the same season, the same suppliers, and the same operators, and its score will look better than its real performance. A fairer test for food is a time split: train on earlier months, test on later months. That mirrors real use, where the model always meets the future, never the past. Another fair test is a group split: train on some suppliers or some lines, test on others the model has never seen.
A second trap is tuning the model many times against the same test set. Each time the test score guides a change, a little of the test data leaks into the training, and the score creeps up without the model truly improving. The remedy is a third set, a validation set, used for tuning, with the test set touched only once at the very end. In small food data sets, where examples are few, a method called cross-validation is used instead: the data is split into several parts in turn, each part takes its turn as the test set, and the scores are averaged. The principle never changes: the judgement must come from examples the model did not learn from.
The diagram shows the split in order. The steps point to the diagram: the test set stays locked away until the model is finished, so its score is an honest measure of new cases.
Quick self-check
Question: Why is a time split fairer than a random split for food data?
Because the model in real use always meets the future, not a random sample of the past. Training on earlier months and testing on later months checks whether the pattern still holds when seasons, suppliers, and conditions change.
Question: What goes wrong when a model is tuned many times against the same test set?
The test set stops being new: each tuning step uses its score to guide a change, so the score rises without the model truly improving. The test score then overstates how well the model will do on genuinely new data.
Measuring mistakes: which errors cost most
A classification score such as "90 percent correct" hides the kind of mistakes a model makes, and in food the kind matters more than the count. A model that sorts good apples from bad ones can make two mistakes: it can reject a good apple, or it can accept a bad apple. The first wastes a good apple. The second sends a bad apple to a customer. Those two mistakes do not cost the same, and a food business must decide which one it fears more.
This is why models are judged with a table of the four outcomes: true positives, where the model correctly flags a bad case; true negatives, where it correctly passes a good case; false positives, where it flags a good case as bad; and false negatives, where it misses a bad case. From that table come two plain measures. Precision asks: of all the cases the model flagged as bad, how many were truly bad? Recall asks: of all the truly bad cases, how many did the model catch? A safety check needs high recall: missing a contaminated batch is the worst error. A sorting line that wastes food needs a balance: high recall with poor precision throws away too much good food.
Regression is judged by the size of its errors. The usual measures are the average size of the error and the largest errors, because a model that is usually close but sometimes far off can be dangerous in food: a moisture prediction that is off by a large amount on one batch can spoil that whole batch. The food professional should always ask for the error on new data, the worst errors, and the conditions where the errors are largest, not only a single average number.
Quick self-check
Question: A safety screen must catch every contaminated batch. Which measure matters most?
Recall: the share of truly bad batches the model catches. Missing a bad batch is the error that matters most here, even if it means flagging some good batches for a second check.
Question: A model is 95 percent correct but misses half of the spoiled batches. Is it good?
No, not for a safety use. The headline number hides the fact that the model fails at the very job it exists to do. The table of outcomes, not the single percentage, is the right judgement.
Overfitting, underfitting, and the size of the data
A model can fail in two opposite ways. Overfitting means it has memorised the training examples, including their noise and their accidents, so it looks perfect in training and fails on new cases. Underfitting means it has learned too little: its pattern is too simple to capture the real relationship, so it fails in training and in testing alike. The picture is a curve: as a model grows more complex, its training score keeps rising, but its test score rises only to a point, then falls as overfitting sets in. The best model sits at the top of that test curve, not at the far end of complexity.
Food data makes overfitting likely, because food data sets are often small and noisy. A plant may have only a few hundred labelled batches, each with dozens of measurements. A complex model can memorise those few hundred rows with ease. The defences are plain: keep the model simple enough for the amount of data, test it honestly on new cases, and prefer features that have a food reason behind them. A feature that makes sense in food science, such as storage temperature for spoilage, is more likely to hold up on new data than a feature that only happens to line up in one small set.
The amount of data also sets a limit on what can be learned. A model that needs to separate ten grades of fruit cannot learn from twenty photographs. A model that predicts shelf life from ten measurements needs enough batches to cover the range of each measurement. When data is scarce, the honest answer is to collect more labelled examples, or to ask a simpler question that the data can support, rather than to build a complex model on too little evidence.
Quick self-check
Question: What is the visible sign of overfitting?
A large gap between the training score and the test score: the model is right on the examples it learned from and wrong on new ones. A small gap, with both scores reasonable, is the sign of a model that has learned a real pattern.
Question: Why is a food-science reason for a feature a defence against overfitting?
Because a feature with a real mechanism behind it, such as temperature driving microbial growth, is likely to hold in new conditions. A feature with no mechanism may only line up by chance in one small data set, and that chance will not repeat.
Cleaning food data: the work before the model
Real food records are messy, and cleaning them is a large part of any machine learning project. Temperatures are recorded in different units, dates are written in different formats, a sensor fails for a day and leaves a gap, a weight is typed with an extra zero, a lab result is entered against the wrong batch. None of this is the computer's fault, and none of it is fixed by a cleverer model. It is fixed by a person who knows the food and the process checking the records line by line.
The cleaning steps are plain. First, find the errors: values that cannot be true, such as a moisture content above 100 percent, or a temperature far outside the range the store can reach. Second, decide what to do with missing values: leave the row out, fill the gap from nearby records, or mark the value as missing so the model knows it is absent. Each choice changes the result, so it must be recorded. Third, put measurements on a common scale where needed, so that a temperature in hundreds does not drown out a pH in single figures in the model's calculations. Fourth, check the labels again, because a wrong label teaches a wrong lesson, and the label check is worth more than any other cleaning step.
Keep a record of every cleaning decision. A model trained on cleaned data can only be understood, repeated, or challenged if the cleaning is written down: which rows were removed, which values were corrected, and why. In food, that record is part of the evidence that the model is trustworthy, in the same way a lab notebook is part of the evidence for a lab result.
Quick self-check
Question: A temperature reading of 850 degrees is found in a cold store log. What should happen to it?
It should be treated as an error, checked against the sensor and the surrounding readings, and either corrected from a reliable source or removed, with the decision recorded. Leaving it in would distort everything the model learns about temperature.
Question: Why write down every cleaning decision?
So the work can be repeated, checked, and challenged. Without that record, nobody can tell whether a good result came from a real pattern or from a particular choice made during cleaning.
Try it yourself
Take a small set of real records you can collect in a week: the weight, colour, and taste notes for ten pieces of fruit, or the temperature and time for ten batches of a cooked food. Make a table with one row per item, one column per measurement, and one column for the label: good or not good, judged by eating or by a simple test you can repeat. Then split your table in two: seven rows for training, three rows for testing. Write a simple rule by hand from the seven rows, such as "if the fruit is soft and dark, it is not good", and test your rule on the three rows you kept aside. How many did you get right? What would you change if you had fifty rows instead of ten? Write your answer in three sentences and keep the table: it is a complete machine learning project in miniature.
Key ideas to carry forward
- A learning problem is a table: one row per example, one column per feature, one column for the label.
- Classification sorts examples into groups; regression predicts a number.
- Supervised learning uses labelled examples; unsupervised learning finds groups and odd cases without labels.
- The test set must be kept aside before training and touched once at the end; a time split is usually the fairest test for food.
- Precision and recall describe which mistakes a model makes; in safety work, recall matters most, because missing a bad batch is the worst error.
- Overfitting is memorising training examples; underfitting is learning too little; the best model sits where the test score is highest.
- Leakage, when a feature carries the answer, makes a model look perfect and useless at the same time.
- Cleaning data and checking labels is the first and most valuable work; a wrong label teaches a wrong lesson.
Glossary
Feature
A measurement used by a model to make its prediction. Food tech example: the acidity of milk is a feature used to predict whether the tanker will fail its bacteria test.
Label
The correct answer attached to an example, so a model can learn from it. Food tech example: marking each batch as pass or fail gives the model its labels.
Classification
Sorting examples into groups. Food tech example: sorting apples into grade 1, grade 2, and grade 3 is classification.
Regression
Predicting a number from measurements. Food tech example: predicting the moisture percentage of a biscuit from its baking time and temperature is regression.
Training set
The examples a model learns from. Food tech example: three years of tanker records used to teach a milk model are its training set.
Validation set
Examples used to tune a model and choose between models, kept separate from the final test set. Food tech example: one month of batches used to choose the best model settings is a validation set.
Test set
Fresh examples kept aside until the end, used for the honest final score. Food tech example: the latest month of milk tankers, never used in training, is the test set.
Cross-validation
A method that splits data into several parts in turn, so each part takes a turn as the test set and the scores are averaged. Food tech example: splitting a year's batches into five parts and testing each in turn gives a steadier score than a single split.
Overfitting
When a model memorises its training examples instead of learning the real pattern, so it fails on new cases. Food tech example: a model that remembers each training loaf exactly but cannot judge a new loaf has overfitted.
Underfitting
When a model is too simple to capture the real pattern, so it fails on training and test data alike. Food tech example: predicting shelf life from temperature alone, when humidity and packaging also matter, underfits the problem.
Leakage
When a feature carries the answer inside it, making the model look perfect in training and useless in real use. Food tech example: using the lab result itself to predict that lab result is leakage.
Precision
Of all the cases a model flagged as bad, the share that were truly bad. Food tech example: if a sorter flags ten apples as damaged and eight truly are, its precision is eight out of ten.
Recall
Of all the truly bad cases, the share a model catches. Food tech example: if twenty apples are truly damaged and the sorter catches fifteen, its recall is fifteen out of twenty.
False positive
When a model flags a good case as bad. Food tech example: rejecting a sound apple as damaged is a false positive, and it wastes good food.
False negative
When a model misses a bad case and passes it as good. Food tech example: passing a spoiled batch as fresh is a false negative, and it is the most serious error in safety work.
Anomaly
A case whose measurements sit far from the usual pattern. Food tech example: a batch with a temperature trace unlike any other batch is an anomaly worth investigating.
Clustering
Grouping examples by their similarity, without pre-set labels. Food tech example: grouping biscuit recipes by their taste scores to find clusters of similar products is clustering.
References
- Irudayaraj, J., Food Processing Operations Modeling, Design, and Analysis, 2nd edition, 2002.
- Singh, R. P., Computer Applications in Food Technology, 1996.
Unit 3: Computer Vision: Seeing Food Quality
Note
Unit 3: Computer Vision: Seeing Food Quality
A question to start with
A packing house grades oranges on a moving belt. For years, six workers stood along the belt, picked up each orange, turned it in their hands, and dropped it into a bin: large, medium, small, damaged, or perfect. The work was fast, tiring, and different from person to person: one worker was strict about spots, another was strict about size, and by the end of a long shift everyone's judgement drifted. Then cameras were fitted above the belt, with lights that never change and a model trained on thousands of photographs, each labelled by grade. The belt now grades every orange the same way, hour after hour, and the workers check the machine's mistakes instead of grading every fruit by hand. The oranges did not change. What changed was that seeing became a measurement: light, colour, and shape turned into numbers, and numbers into a grade. This unit explains how a camera sees food, how a model learns from photographs, and where seeing by camera is strong and where it is blind.
Computer vision is the part of AI that works with pictures. A camera records light as numbers, a model reads those numbers, and the result is a judgement about what is in the picture: its size, its colour, its shape, whether it is damaged, whether a seal is closed, whether a label is in the right place. The human eye does this without thinking. A computer must be taught it, photograph by photograph, and the teaching is only as good as the photographs and their labels.
Questions to think about
- A camera grades tomatoes by colour. What would happen if the light above the belt changed from white to yellow?
- A model spots bruises on apples from photographs. Why might it work well on one variety and fail on another?
- A pack seal looks closed in a photograph but leaks in the store. What has the camera missed, and what other check is needed?
Think about the light question before you read on
The grades would shift, because the camera measures the light that reaches it, not the true colour of the tomato. Yellow light makes every tomato look more yellow, so ripe tomatoes could be graded as unripe, or unripe ones as ripe. This is why vision systems use fixed, controlled lighting and check their calibration with standard colour cards: the light is part of the measurement, and if the light changes, the measurement changes with it.
How a camera turns food into numbers
A digital photograph is a grid of tiny squares called pixels. Each pixel records how much light reached it, split into colour channels, usually red, green, and blue. A photograph of a tomato is therefore a large table of numbers: thousands of rows, thousands of columns, three numbers per pixel. A computer vision model reads that table and learns which patterns of numbers go with which label: the pattern of a ripe tomato, the pattern of a bruise, the pattern of a torn seal.
Colour in a photograph is not the same as colour in the eye. The eye adjusts to the light, so a white plate looks white in sunlight and in a kitchen. A camera does not adjust by itself: the same plate photographs differently under different lights, and the same tomato looks different on a cloudy day and under a factory lamp. Food vision systems control this by fixing the light: a tunnel or a hood over the belt, lamps of a known type, and a white reference card photographed at regular intervals to check that the colours have not drifted. Without that control, the model is judging the light as much as the food.
Shape and size are measured from the same grid. The model finds the edge of the object, counts the pixels inside it, and turns that count into a size once it knows how many pixels make a centimetre at that distance. That calibration, pixels to centimetres, must be checked whenever the camera moves, the belt speed changes, or a new lens is fitted. A camera that has moved by a few millimetres will measure every fruit wrong by the same amount, and the error will be systematic: every apple too large, or every biscuit too small, until someone notices.
Quick self-check
Question: Why does a vision system need fixed lighting?
Because the camera measures the light that reaches it, and a change in the light changes every colour reading. Fixed lighting keeps the measurement steady, so a change in the reading means a change in the food, not a change in the light.
Question: What is a pixel?
One tiny square in the grid that makes up a digital photograph. Each pixel records the light at that spot, usually as red, green, and blue numbers, and together the pixels form the picture the model reads.
Teaching a model to see: labelling photographs
A vision model learns from labelled photographs. Someone, usually a food professional, looks at each photograph and records the true answer: the grade, the presence of damage, the ripeness, the seal condition. That label is the truth the model is judged against, and its quality decides everything. If two labellers disagree about what counts as a bruise, the model learns a confused lesson and its judgements will be confused too. Good labelling starts with a written rule, with example photographs for each grade, and with a check that different labellers agree on the same set of photographs before the real labelling begins.
The photographs must also cover the real range of the food. A model trained only on perfect fruit will not know what a bruised fruit looks like, and a model trained only on one variety will not know another variety's normal colour. A bruise on a green apple looks different from a bruise on a red apple. A tomato in summer light looks different from a tomato in winter light. The training photographs must include the varieties, the sizes, the damage types, and the lighting conditions the system will meet in real use, or the first unfamiliar case will be graded wrong.
Two extra habits protect a vision project. First, the test photographs must come from different days, different batches, and different lots from the training photographs, so the test measures real performance and not memory. Second, the photographs must be checked for tricks: a scratch on the belt that always appears under damaged fruit, a shadow that always falls on one grade, a date stamp in the corner that lines up with one supplier. A model will happily learn the scratch, the shadow, or the stamp instead of the food, and it will look perfect until the scratch is cleaned or the shadow moves.
The diagram shows the five steps in order. The steps point to the diagram: step 5 is the loop that keeps the system honest, because new mistakes become new training examples.
Quick self-check
Question: Why must labellers agree with each other before labelling begins?
Because the model learns whatever the labels say. If two labellers call the same bruise by different grades, the model is taught two different answers for the same picture, and its judgements will be confused.
Question: A model learns that a shadow on the belt means damaged fruit. What has gone wrong?
It has learned a trick in the photographs instead of the food. The shadow is not part of the fruit, so when the light changes or the shadow moves, the model will grade wrongly. The photographs must be checked for such clues before training.
What computer vision does well in food
The strongest use of vision in food is sorting by appearance: size, shape, colour, and visible damage. Fruit and vegetables are graded by diameter, by colour, and by the size and number of surface marks. Biscuits and bread are checked for colour, shape, and cracks. Nuts and grains are sorted by size and by visible foreign material, such as stones or stems. These are jobs where the judgement is about what can be seen, where the same judgement must be repeated thousands of times an hour, and where a person's judgement drifts with tiredness. A camera does not tire, and it applies the same rule to the first fruit of the day and the last.
A second strong use is checking packs and labels. A camera above a line can check that every pack has a label, that the label is in the right place, that the seal is straight, and that the date code is printed and readable. These checks are fast, cheap, and exact: a missing label is visible, a crooked seal is visible, a blurred date code is visible. The camera does not need to understand the food inside the pack to catch these faults, and catching them at the line is far cheaper than catching them after the packs have left the factory.
A third use is counting and measuring. A camera can count pieces on a belt, measure the diameter of every fruit, or check that every tray has the same number of items. Counting by eye is slow and error prone, and a camera counts without losing its place. The measurement is only as good as the calibration, so the pixels-to-centimetres check must be part of the routine, but once it is set, the counting is steady and repeatable.
Quick self-check
Question: Why is fruit grading a good job for a camera?
Because the judgement is about visible size, colour, and damage, it must be repeated thousands of times, and a person's judgement drifts with tiredness while a camera applies the same rule every time.
Question: Name two pack checks a camera can do well.
Any two of these count: checking that a label is present and in the right place, that a seal is straight and closed, that a date code is printed and readable, or that a tray holds the right number of items.
Where vision is blind: the inside of food
The limit of computer vision is plain: a camera sees only the outside. It cannot taste, smell, or feel, and it cannot see inside a food unless the food is cut open or a different kind of sensor is used. An apple can look perfect and be rotten at the core. A tomato can be the right colour and still be tasteless. A loaf can be the right shape and still be underbaked inside. A camera grading by appearance will pass all three, and only a cut test, a taste test, or a lab test will catch them.
This is why vision is always paired with other checks in a sound quality system. The camera sorts by appearance at high speed, and a sample from each lot is cut, tasted, and tested in the lab. The camera's job is to make the sorting steady and to catch the visible faults; the lab's job is to catch what the camera cannot see. A business that trusts the camera alone is trusting the outside of the food to speak for the inside, and that trust will fail on the first batch where the fault is hidden.
Some faults are visible only in a narrow sense. A bruise under the skin of a fruit may show as a slight darkening, but only in certain light, or only from certain angles. A hairline crack in a biscuit may be invisible from above and plain from the side. A seal that looks closed may have a tiny channel that lets air in. Vision systems deal with this by using several cameras, by lighting the food from different angles, and by turning the food so more of its surface is seen. Each extra view costs money and time, so the choice of how many views to use is a balance between the faults that must be caught and the cost of catching them.
Quick self-check
Question: An apple looks perfect but is rotten inside. Why does the camera miss it?
Because the camera only records the light from the outside surface. Internal rot does not change the outside appearance until it is far advanced, so the photograph carries no sign of it.
Question: How does a quality system cover what the camera cannot see?
By pairing the camera with sampling: a sample from each lot is cut, tasted, and lab tested. The camera handles the fast visible sorting, and the lab handles the hidden qualities.
Beyond ordinary photographs: other ways of seeing
An ordinary camera records visible light, but food can also be seen in other ways, and each way shows a different property. A near-infrared sensor records light the eye cannot see, and that light carries information about water content, sugar, and internal structure. It can help judge the ripeness of fruit or the moisture of grain without cutting the food open. A thermal camera records heat, and it can show whether a cooked food is evenly heated, whether a cold store has a warm spot, or whether a seal has been heated evenly. A three-dimensional scan records shape in depth, and it can measure the volume of a loaf or the shape of a piece of fruit more exactly than a flat photograph.
These methods are powerful, and they are also narrower and more costly than an ordinary camera. Each one needs its own calibration, its own labelled examples, and its own check against the truth. A near-infrared reading that predicts sugar in one variety may fail in another, because the relationship between the reading and the sugar depends on the variety, the season, and the growing conditions. The same rule from Unit 2 applies: test on new cases, from new batches and new lots, before trusting the system, and keep checking it as conditions change.
The choice between these methods is a food question, not a technology question. Ask first what property must be measured: colour, size, water, sugar, heat, shape. Then ask which kind of light or sensor measures that property, and whether the measurement is worth its cost on this line. A simple colour camera may be enough for grading by colour; a thermal camera may be needed to check that a cooked food is heated through. The right sensor is the one that measures the property that matters, at a cost the business can carry.
The diagram shows the four ways of seeing. The steps point to the diagram: each way measures a different property, so the choice starts from the property that must be measured, not from the sensor.
Quick self-check
Question: When would a thermal camera be more useful than an ordinary camera?
When the property that matters is heat: checking that a cooked food is heated evenly through, finding a warm spot in a cold store, or checking that a seal was heated evenly. An ordinary camera cannot see heat.
Question: Why might a near-infrared sugar reading work on one fruit variety and fail on another?
Because the relationship between the reading and the sugar depends on the variety, the season, and the growing conditions. A model trained on one variety has not learned the relationship for another, so it must be tested on the new variety before it is trusted.
Running a vision system on a line: speed, light, and drift
A vision system on a production line has three practical enemies: speed, dirt, and drift. Speed matters because the belt moves: the camera must take a sharp photograph of each item in the short time it passes, and the model must give its answer before the item reaches the sorting gate. A slow model, or a blurred photograph, means the item passes the gate before the grade is known, and the sorting fails. The system must be tested at full line speed, not at bench speed, because a model that works on still photographs may fail on a moving belt.
Dirt matters because a food line is not a clean room. Dust settles on the lens, steam fogs the cover, a splash of juice coats the light. Each of these changes the photographs a little at a time, and the model, trained on clean photographs, slowly starts to grade wrongly. The defence is a cleaning routine, written down and followed, and a regular check with a standard object of known colour and size, so that a drift in the measurement is caught before it becomes a drift in the grading.
Drift is the slow change in the food itself: a new season brings a different shade of fruit, a new supplier brings a different shape, a recipe change brings a different biscuit colour. The model was trained on the old food, and its grades slowly stop matching the true grades. The defence is the loop from the diagram above: a person keeps checking the machine's mistakes, labels the new photographs, and retrains the model on the new season's food. A vision system is not a machine that is set once and forgotten: it is a system that must be watched, cleaned, checked, and retaught as the food changes.
Quick self-check
Question: Why must a vision system be tested at full line speed?
Because the belt moves: the camera must take a sharp photograph and the model must answer before the item reaches the sorting gate. A system that works on still photographs may be too slow or too blurred on a moving belt.
Question: What is drift in a vision system?
The slow change in the food, the light, or the camera that makes the model's grades stop matching the true grades. New seasons, new suppliers, dust on the lens, and recipe changes all cause drift, and the remedy is regular checking and retraining on new labelled photographs.
Try it yourself
Take ten photographs of one food, such as apples, tomatoes, or biscuits, in the same place with the same light. Sort them by eye into two or three groups, and write down your rule for each group in one sentence: "dark spots larger than a coin", or "pale and small". Now take the same ten photographs again, but change the light: move to a different room, or photograph them in the evening instead of the morning. Sort them again by the same rule. Which photographs changed group, and why? Write down what your rule missed, and what you would need to fix in the light, the rule, or the photographs before a camera could use your rule. That gap between your first sorting and your second is the gap a vision system must close with fixed lighting and clear labels.
Key ideas to carry forward
- A photograph is a grid of pixels, each recording light as numbers: a model reads those numbers to judge colour, size, shape, and damage.
- Fixed, controlled lighting is part of the measurement: a change in the light changes every colour reading.
- Labels decide everything: clear written rules, example photographs, and agreement between labellers come before training.
- Test photographs must come from different days, batches, and lots from the training photographs.
- Vision is strong at sorting by appearance, checking packs and labels, and counting and measuring at speed.
- Vision is blind to the inside of food: taste, flavour, internal damage, and hidden faults need cutting, tasting, and lab testing.
- Other sensors see other properties: near-infrared for water and sugar, thermal for heat, three-dimensional scans for volume and shape.
- A line system must work at full speed, stay clean, and be checked and retaught as the food, the season, and the supplier change.
Glossary
Computer vision
The part of AI that works with pictures, turning photographs into judgements about size, colour, shape, and damage. Food tech example: a camera that grades oranges on a belt uses computer vision.
Pixel
One tiny square in the grid that makes up a digital photograph, recording light as numbers. Food tech example: a bruise on an apple appears as a group of darker pixels in the photograph.
Colour channel
One part of the light recorded in a photograph, usually red, green, or blue. Food tech example: a ripe tomato has high values in the red channel and lower values in the green channel.
Calibration
Checking and setting a measurement so it is true, such as setting how many pixels make a centimetre. Food tech example: photographing a ruler under the belt camera calibrates its size readings.
Labelling
Attaching the correct answer to each photograph so a model can learn from it. Food tech example: marking each apple photograph as grade 1, 2, or 3 is labelling.
Segmentation
Finding the edges of the food in a photograph, so the model measures the food and not the belt behind it. Food tech example: separating each biscuit from the tray in the photograph is segmentation.
Grading
Sorting food into quality groups by set rules. Food tech example: grading oranges by size and surface marks into large, medium, and small is grading.
Bruise
Damage under the skin of a fruit, often visible as a darkened or softened area. Food tech example: a bruised apple shows a dark patch that a camera can learn to spot.
Near-infrared
Light just beyond the visible range, which carries information about water, sugar, and internal structure. Food tech example: a near-infrared sensor can help judge the ripeness of fruit without cutting it.
Thermal camera
A camera that records heat instead of visible light. Food tech example: a thermal camera shows whether a cooked pie is heated evenly through.
Three-dimensional scan
A measurement of shape in depth, not only in a flat photograph. Food tech example: a three-dimensional scan measures the volume of a loaf more exactly than a flat picture.
Drift
The slow change in food, light, or camera that makes a model's judgements stop matching the truth. Food tech example: a new season's fruit colour causes drift in a grading model trained on last season's fruit.
Foreign material
Anything in a food that should not be there, such as stones, stems, or pieces of packaging. Food tech example: a vision system that spots stones among grains is checking for foreign material.
Seal
The closed edge of a pack that keeps air and microbes out. Food tech example: a camera checks that each pack seal is straight and fully closed.
Date code
The printed date on a pack, such as a production or best-before date. Food tech example: a camera checks that every pack carries a readable date code.
References
- Irudayaraj, J., Food Processing Operations Modeling, Design, and Analysis, 2nd edition, 2002.
- Singh, R. P., Computer Applications in Food Technology, 1996.
Unit 4: AI in Food Safety and Quality Control
Note
Unit 4: AI in Food Safety and Quality Control
A question to start with
A ready-meal factory makes thousands of packs a day. Each pack passes a metal detector, a weight check, and a seal check, and a sample from each batch goes to the lab for microbe testing. One morning, the lab finds a high count in a sample from the previous day, but that day's packs have already left the factory. The recall that follows is costly, and the question everyone asks is the same: could the problem have been seen earlier? The factory's records hold the answer. The cooling time that day was longer than usual, the filling temperature was a little high, and one supplier's ingredient had a higher count than normal. No single reading was outside its limit, but the combination was unusual, and a model trained on past batches would have flagged that combination on the day itself. This unit is about that kind of early warning: how AI helps food safety and quality control, what it can catch, and what it must never be allowed to decide alone.
Food safety is the work of keeping food free from harm: microbes that cause illness, toxins, chemical contaminants, and foreign objects. Quality control is the work of keeping food true to its standard: the right composition, the right taste, the right texture, the right weight, the right shelf life. The two are linked, because a process that drifts out of control can harm both safety and quality at once, but they are not the same job, and AI serves them in different ways. Safety work needs a model that misses nothing, even if it raises false alarms. Quality work needs a model that balances the two kinds of mistakes, because throwing away good food is also a cost.
Questions to think about
- A model flags a batch as risky, but every single reading is inside its normal limit. Should the batch be held? What would you check first?
- A lab test takes two days to give a result. What can a model do in those two days that the lab cannot?
- A supplier's ingredient passes every test, yet finished products made with it keep failing. Where would you look in the records for the cause?
Think about the flagged-batch question before you read on
Hold the batch for a closer check, and look first at the combination the model saw: which readings together were unusual, and whether that combination has pointed to a real problem before. A model flags a pattern, not a proof. The flag is a reason to test more, not a reason to condemn the batch, and not a reason to release it without that extra check.
How AI helps safety: finding the unusual combination
Most food safety failures do not come from one reading going wildly wrong. They come from several small changes lining up at once: a slightly warm delivery, a slightly slow cooling step, a slightly long holding time, a slightly high initial count in one ingredient. Each change alone is inside its limit, so no single alarm rings. Together they create conditions in which microbes can grow faster than usual, and the finished food carries a higher risk than any one reading suggests.
A model trained on past batches can learn these combinations. It reads the records of many batches, each labelled with its lab result, and learns which combinations of readings went with high counts and which went with low counts. When a new batch shows a combination like the risky ones, it raises a flag. The flag does not say the food is unsafe. It says this batch looks like past batches that turned out to be a problem, so check it more closely, test it sooner, or hold it until the lab result arrives.
This is the same idea as Unit 2, applied to safety, but the stakes change the judgement. In safety work, a missed bad batch is far worse than a false alarm, so the model is tuned for high recall: it is set to catch as many risky batches as it can, even if that means flagging some safe batches for an extra check. The extra checks cost time and money, and that cost is the price of the safety margin. A model tuned the other way, to avoid false alarms, would look tidy on paper and miss the very batches it exists to catch.
The diagram shows the five steps in order. The steps point to the diagram: step 5 is a human decision, because a flag is a pattern, not a proof, and only a person can weigh the flag against the lab result and the rules.
Quick self-check
Question: Why can a batch be risky when every single reading is inside its limit?
Because risk can come from a combination of small changes lining up at once: a warm delivery, slow cooling, and a long hold time together create conditions for growth, even when each reading alone is normal.
Question: In safety work, why is a missed bad batch worse than a false alarm?
Because a missed bad batch can reach people and cause illness, while a false alarm costs only an extra check. Safety models are therefore tuned to catch as many risky batches as possible, even at the price of extra checks.
Predicting spoilage and shelf life
Shelf life is the time a food stays safe and acceptable under stated storage conditions. It is usually set by testing: batches are stored, sampled over days, and the day the food fails a microbe, taste, or texture test fixes the limit. That testing is slow and costly, and it must be repeated whenever a recipe, a pack, or a storage condition changes. AI helps by learning the relationship between the conditions a batch met and the shelf life it achieved, so that a new batch can be given a predicted shelf life from its own records, before the long test is finished.
The model reads the features that drive spoilage: the starting microbe count, the acidity, the water activity, the storage temperature, the packaging, and the time the food spent at each temperature. From past batches, it learns how those features together set the keeping time. A batch that started with a low count, was cooled fast, and is packed to keep air out will be predicted to keep longer than a batch that started warm and cooled slowly. The prediction is then checked against the real test as the days pass, and the model is corrected when it is wrong.
Two cautions belong here. First, a shelf life prediction is never a substitute for the lab test that sets the shelf life: it is a guide for planning, for deciding which batches to test first, and for spotting a batch whose predicted life is far shorter than normal. Second, the model only knows the conditions in its training data. A new packaging material, a new recipe, or a storage temperature outside the trained range makes the prediction unreliable, and the honest answer then is to test the food in the ordinary way, not to trust the model.
Water activity deserves a plain note, because it appears in every spoilage model. It is a measure of the water in a food that microbes can actually use, not the total water in the food. Sugar and salt bind water, so a jam with a high sugar content can have a low water activity even though it contains water. Microbes need free water to grow, so foods with low water activity keep longer. A model that uses water activity, acidity, and temperature together is using the same science a food microbiologist uses, only faster and across many batches at once.
Quick self-check
Question: What is water activity, in plain words?
It is the measure of the water in a food that microbes can actually use. Sugar and salt bind water, so a sweet jam can hold water yet have a low water activity, and microbes grow slowly in it.
Question: Why is a predicted shelf life not a substitute for a lab test?
Because the prediction is learned from past batches, and a new recipe, pack, or storage condition can break the pattern it learned. The lab test measures the real food; the prediction only estimates it, and the estimate must be checked.
Watching a process: when the line drifts
A food process is a set of conditions held steady: a temperature, a time, a pressure, a flow rate, a mixing speed. When those conditions hold, the food comes out the same. When they drift, the food changes, often before anyone notices. A pasteuriser that runs a little cool, a mixer that runs a little short, a dryer that runs a little damp: each drift is small, and each one changes the food in a way that shows up later as a quality failure or a safety risk.
AI watches a process by reading many measurements at once and learning what "normal" looks like. Normal is not one fixed value: it is a pattern across all the measurements, including how they move together through the day. A model trained on normal running learns that pattern, and when a new batch moves away from it, the model flags the drift. The flag can arrive long before any single measurement crosses its limit, because the model sees the whole pattern shifting, not one gauge at a time.
This kind of watching has a name in food plants: statistical process control, and AI extends it. The older method watches one measurement at a time against a fixed limit. The AI method watches all the measurements together and asks whether their combination still looks like normal running. The person on the line still decides what to do: adjust the process, stop the line, or call the engineer. The model's job is to bring the drift to attention early, while the fix is still small and cheap.
Quick self-check
Question: What is process drift?
The slow movement of a process away from its normal conditions, such as a pasteuriser running a little cool or a dryer running a little damp. The drift is small at first, and it changes the food before any single alarm rings.
Question: How does AI spot drift earlier than a single gauge?
By reading many measurements together and learning the pattern of normal running. When the whole pattern shifts, the model flags it, even when each single measurement is still inside its own limit.
Tracing a problem back to its source
When a finished product fails, the question is where the problem started: the raw material, the process, or the storage. The records of a food business hold the links, if they are kept well: each batch of finished food can be traced to the batches of ingredients that went into it, the line it ran on, the people who ran it, and the conditions it met. AI helps by searching those links for the pattern behind the failures: do the failed batches share a supplier, a line, a shift, a storage room, or a week?
This is a grouping question, of the kind Unit 2 described, and it works best when the tracing records are complete and honest. If the records are patchy, the model will find the pattern in the records that happen to exist, not the pattern in the real food. If one supplier's deliveries are recorded in detail and another's are not, the model may blame the well-recorded supplier simply because its records are there to be blamed. The food professional's job is to check the records before trusting the search, and to confirm any suspect link with a direct test: test the ingredient, check the line, inspect the store.
Traceability also matters forward, not only backward. When a risky ingredient is found, the business must find every finished batch that used it, and do so fast. A model can help by reading the production records and listing the affected batches, but the listing is only as complete as the records. A batch that was made and never recorded cannot be found by any search, and that is a failure of record keeping, not of the model.
The diagram shows the tracing steps in order. The steps point to the diagram: the model suggests the shared link, but the direct test confirms it, and the records decide how far the problem reaches.
Quick self-check
Question: Why can patchy records mislead a trace-back search?
Because the model can only search the records that exist. A supplier whose deliveries are recorded in detail may look guilty simply because its records are there, while a poorly recorded supplier escapes the search.
Question: What is the difference between tracing back and tracing forward?
Tracing back follows a failed finished batch to its ingredients and process. Tracing forward follows a risky ingredient to every finished batch that used it. Both need complete records to work.
Quality control: keeping every batch true to standard
Quality control in food is a daily routine: samples are taken, tests are run, and the results are compared with a standard. AI helps that routine in three ways. First, it reads the routine results and spots a trend before it becomes a failure: the moisture of a biscuit creeping up over a week, the acidity of a sauce drifting down, the weight of a pack slowly falling. A trend is a warning that the process is moving, and the fix can be made while the product is still inside its standard.
Second, it helps decide how much to test. Testing every pack is costly, and testing too few is risky. A model that reads the process records can say which batches are most like past batches that failed, and those batches get more testing, while steady batches get the routine check. This is called risk-based testing, and it puts the lab's effort where the risk is, instead of spreading it evenly and thinly.
Third, it helps with sensory quality: taste, smell, texture, and appearance. Taste panels give scores, and a model can learn how those scores relate to the measurements: which acidity, which sugar, which baking time goes with the highest taste score. The model does not taste the food. It learns the link between the measurements and the panel's scores, and it suggests the next recipe change to try. The panel still tastes the new version and gives the verdict, because only people can taste.
Quick self-check
Question: What is risk-based testing?
Testing more where the risk is higher. A model reads the process records, finds the batches most like past batches that failed, and those batches get extra testing, while steady batches get the routine check.
Question: Can a model taste food?
No. It can learn the link between measurements and taste panel scores, and suggest a recipe change to try, but the panel must still taste the new version and give the verdict.
The limits that must never be forgotten in safety work
AI in safety has three hard limits, and this unit ends with them because they decide how the systems are used. First, a model only knows the past. A new hazard, a new ingredient, a new process, or a new way of cheating the system will not be in its training data, and the model will not flag it. The safety system must therefore keep its other defences: good hygiene, trained people, honest records, and lab testing, all of which work even when the model has never seen the hazard.
Second, a model can be wrong in both directions, and both directions have a cost. A false alarm holds good food and wastes time. A missed bad batch sends risky food onward. No tuning removes both errors at once: making the model stricter cuts the misses and raises the false alarms, and making it looser does the reverse. The choice of where to set the line is a food safety decision, made by people who carry the responsibility, not a technical choice made by the model.
Third, a model must never be the only check on a safety decision. A batch is released because a person has weighed the lab result, the process records, the model flag, and the rules, and has signed for it. If the model is the only check, its failure is the system's failure, with nothing behind it. The rule for safety AI is the same as the rule for any safety system: it is one layer among several, and the layers behind it must still work if it fails.
Quick self-check
Question: Why must safety AI keep the older defences behind it?
Because a model only knows the past, and a new hazard will not be in its training data. Hygiene, trained people, honest records, and lab testing work even when the model has never seen the hazard.
Question: Why must a person still release a batch that a model has passed?
Because the model gives one piece of evidence, not the whole decision. The person weighs the lab result, the process records, the model flag, and the rules, and takes responsibility for the release.
Try it yourself
Choose a food with a clear keeping problem: milk, bread, cooked rice, or cut fruit. Write down five things that make it spoil faster: warmth, time, air, moisture, and a high starting count are good places to start. Now imagine you have the records for twenty batches of that food, each with those five things measured and a lab result saying fresh or spoiled. Write, in plain words, the combination you would expect to see in the spoiled batches: which of the five would be high, and which would be low? Then write the combination you would expect in the fresh batches. If you can state both combinations clearly, you have written the pattern a model would try to learn. Keep the page: it is the same thinking you will need when you read a real model's flag and must decide whether to believe it.
Key ideas to carry forward
- Safety work needs a model that misses nothing: high recall matters more than a tidy headline score, even at the price of extra checks.
- Risk often comes from a combination of small changes, each inside its limit, not from one reading going wildly wrong.
- A shelf life prediction is a guide for planning and for choosing what to test first, not a substitute for the lab test that sets the shelf life.
- Water activity measures the water microbes can use, and it works with acidity and temperature to set how fast food spoils.
- AI watches a process by learning the pattern of normal running and flagging drift before any single gauge crosses its limit.
- Tracing a failure needs complete records: the model suggests the shared link, and a direct test confirms it.
- Risk-based testing puts the lab's effort where the risk is highest, instead of spreading it evenly.
- A model is one layer of safety among several: it must never be the only check, and a person still releases the batch.
Glossary
Food safety
Keeping food free from harm, including microbes that cause illness, toxins, chemical contaminants, and foreign objects. Food tech example: chilling milk fast after milking is a food safety step.
Quality control
Keeping food true to its standard in composition, taste, texture, weight, and shelf life. Food tech example: testing each batch of biscuits for moisture and weight is quality control.
Shelf life
The time a food stays safe and acceptable under stated storage conditions. Food tech example: a yoghurt with a shelf life of ten days under chilled storage.
Water activity
A measure of the water in a food that microbes can actually use, not the total water. Food tech example: jam has a low water activity because sugar binds the water, so microbes grow slowly in it.
Spoilage
The change in a food that makes it unacceptable, through microbial growth, chemical change, or loss of texture and flavour. Food tech example: bread going stale and mouldy is spoilage.
Process drift
The slow movement of a process away from its normal conditions. Food tech example: a dryer running a little damp over a week is process drift.
Statistical process control
Watching a process with measurements and limits, so a drift is caught before the food fails. Food tech example: plotting biscuit weights through the day and acting when the line moves is statistical process control.
Traceability
The ability to follow a food back to its ingredients and process, and forward to every batch that used a given ingredient. Food tech example: tracing a failed batch of sauce back to one delivery of tomatoes is traceability.
Risk-based testing
Testing more where the risk is higher, and less where the process is steady. Food tech example: giving extra lab tests to batches whose records look like past failed batches is risk-based testing.
Recall
In machine learning, the share of truly bad cases a model catches. Food tech example: a safety screen with high recall catches almost every contaminated batch.
False alarm
When a system flags a safe batch as risky. Food tech example: holding a good batch of milk for an extra test because its records looked unusual is a false alarm.
Hazard
Anything in food that can cause harm, such as a harmful microbe, a toxin, or a chemical contaminant. Food tech example: a harmful microbe in raw milk is a hazard.
Contaminant
A harmful substance that gets into food, such as a chemical residue or a toxin. Food tech example: a pesticide residue above its allowed level is a contaminant.
Foreign object
An object in food that should not be there, such as a piece of metal, glass, or plastic. Food tech example: a metal detector on a line checks for foreign objects in packs.
Sensory quality
How food is judged by the senses: taste, smell, texture, and appearance. Food tech example: a taste panel scoring the sweetness and crunch of biscuits measures sensory quality.
References
- Irudayaraj, J., Food Processing Operations Modeling, Design, and Analysis, 2nd edition, 2002.
- Singh, R. P., Computer Applications in Food Technology, 1996.
Unit 5: AI in Food Processing and Production Planning
Note
Unit 5: AI in Food Processing and Production Planning
A question to start with
A biscuit factory runs the same oven every day, but the biscuits do not come out the same. On damp mornings they are pale, on dry afternoons they are dark, and when the flour delivery changes, the texture shifts. The operators adjust the oven by feel: a little more time, a little less heat, a little more steam. Sometimes the fix works, sometimes it makes things worse, and the knowledge of what works lives in the heads of the two most experienced operators. Then the factory starts recording everything the oven does and everything the biscuits become: temperature at three points in the oven, belt speed, flour moisture, dough temperature, and the colour and weight of the finished biscuits. A model learns the link between the oven settings and the biscuit, and it starts suggesting the settings for each morning's flour and weather. The biscuits become steadier, the experienced operators spend their time on new problems instead of repeating the same fix, and the factory uses less energy because the oven no longer runs hotter than it needs to. This unit explains how AI tunes food processes and plans production, and how the people who run the line stay in charge of both.
Food processing is the set of steps that turns raw material into a finished food: mixing, heating, cooling, drying, freezing, fermenting, and packing. Production planning is the work of deciding what to make, how much, in what order, and with which people and machines, so that orders are met without waste. AI helps both, because both produce records, both repeat decisions, and both are affected by conditions that change day by day: the flour, the weather, the orders, the machines.
Questions to think about
- An oven operator changes the temperature by feel and the biscuits improve. How would you turn that feel into a rule a model could learn?
- A factory has three lines and ten orders. What makes the order of the orders a hard problem, and what could a model do about it?
- A model suggests a lower oven temperature to save energy. What would you check before accepting the suggestion?
Think about the energy question before you read on
Check the food, not the energy saving. Run a trial batch at the lower temperature, test its colour, texture, moisture, and safety, and compare those results with the standard. An energy saving that changes the food is not a saving: it is a quality failure bought cheaply. Accept the suggestion only when the trial proves the food is unchanged.
Tuning a process: from feel to a learned rule
Every food process has settings: the temperature of an oven, the time in a dryer, the speed of a mixer, the pressure in a pasteuriser, the time a dough is left to prove. Those settings decide the food, and the right settings change with the raw material and the conditions. A skilled operator learns the feel of the process: how the dough looks, how the oven sounds, how the product smells. That feel is real knowledge, but it lives in one person, it is hard to pass on, and it is hard to check.
A model learns the same link in a different form. It is given the records of many batches: the settings used, the conditions that day, and the result in the food. It learns which settings, under which conditions, give the food that meets the standard. The result is not a feeling but a suggestion with numbers: for this flour moisture and this room humidity, set the oven to this temperature and this belt speed. The operator reads the suggestion, weighs it against experience, and sets the oven. The suggestion is checked by the food that comes out, and the new batch becomes another example for the model to learn from.
This is the loop that makes process AI work: suggest, run, measure, learn. The loop only works if the measurement is honest. If the colour is judged by a quick glance instead of a measured colour, or the moisture is guessed instead of tested, the model learns from guesses and its suggestions will be guesses too. The investment that makes process AI pay is therefore not in the model alone, but in the measurement: good sensors, regular calibration, and a routine of testing the finished food.
The diagram shows the loop in order. The steps point to the diagram: step 4, measuring the food honestly, is the step the whole loop depends on, because the model learns from those measurements.
Quick self-check
Question: Why does process AI need good measurement more than a clever model?
Because the model learns from the measurements. If the colour is guessed and the moisture is not tested, the model learns from guesses, and its suggestions will be guesses too. Good sensors and regular testing are what make the loop work.
Question: What happens to the operator's feel when a model starts suggesting settings?
It is not removed: it is moved to a higher job. The operator checks the suggestion against experience, handles the cases the model has never seen, and spends time on new problems instead of repeating the same fix every morning.
Optimisation: the balance between many goals
A food process never has one goal alone. A biscuit must be the right colour and the right texture, it must be safe, it must be made fast enough, it must use as little energy as possible, and it must waste as little raw material as possible. Those goals pull against each other: a hotter oven bakes faster but uses more energy and risks burning; a longer drying time gives a drier product but slows the line; a faster belt makes more biscuits but may make them uneven.
Optimisation is the work of finding the settings that balance those goals best. A model helps by predicting the result of a setting before it is tried: this temperature and this time will give this colour, this moisture, and this energy use. The food team can then try many combinations in the model, see the trade-offs, and choose the combination that meets the standard with the least waste of time and energy. The chosen combination is then tested on the real line, because the model is a guide to the trial, not a replacement for it.
The trade-off must be stated plainly before the model is used. Is the priority the quality of the food, the speed of the line, or the energy used? A model that is asked to save energy without a quality limit will happily suggest settings that save energy and spoil the food. The limits, the standards the food must meet, must be written into the task before the model starts, and they must be checked on the real food after every change.
Quick self-check
Question: A model suggests a hotter oven to bake faster. What trade-off is it making?
Speed against quality and energy: a hotter oven bakes faster, but it uses more energy and risks burning or uneven baking. The choice is only sound if the food still meets its standard at the hotter setting.
Question: Why must quality limits be written into an optimisation task before the model starts?
Because a model asked only to save time or energy will suggest settings that save time or energy and spoil the food. The limits state what the food must still be, and the model must work inside them.
Learning by trying: tuning step by step
Some processes are tuned not by a single prediction but by trying small changes and keeping the ones that help. The model suggests a small change, the line runs with it, the food is measured, and the result decides whether the change is kept. Then the next small change is tried. This way of learning, by trial and by keeping score, is suited to processes where the link between settings and result is complex, or where the raw material changes so often that a fixed rule goes stale fast.
The trial must be run with care. Only one setting should change at a time, or the result cannot be blamed on any one change. The trial batch must be measured in the same way as normal batches, and the result must be compared with the standard, not with a feeling. The size of the trial matters too: a change tested on one batch may look good by chance, while a change tested on several batches shows whether the improvement is real. A food professional runs the trial like an experiment: one change, a clear measurement, a fair comparison, and a written record.
This way of learning is slow, and it carries a risk: a trial that makes the food worse wastes a batch. The remedy is to run trials on a small scale where possible, or to run them on the model first, using past data to predict which trials are worth running on the real line. The model then guides the trials, and the trials correct the model, in the same loop as the tuning section above.
Quick self-check
Question: Why change only one setting at a time in a trial?
So the result can be blamed on that one change. If two settings change together and the food improves, nobody knows which change did it, and the lesson cannot be repeated with confidence.
Question: Why test a change on several batches, not one?
Because one batch can look good or bad by chance. Several batches show whether the improvement is real and steady, or a single lucky result.
Production planning: what to make, and in what order
Production planning answers three questions every day: what to make, how much, and in what order. The answers depend on the orders that have come in, the raw material in store, the machines that are free, the people who are on shift, and the time each product needs on each line. The number of possible orders is large: with ten products and three lines, the combinations run into the thousands, and a person planning by hand can only check a few of them.
A model helps by doing the arithmetic that a person cannot do by hand. It reads the orders, the stock, the line capacities, and the times each product needs, and it searches through many possible plans, scoring each one: does it meet the orders on time, does it waste the least raw material, does it keep changeovers, the cleaning and resetting between products, to a minimum? Changeovers matter in food, because switching a line from one product to another takes time and often wastes material, and a good plan groups similar products together so the line changes over as rarely as possible.
The plan the model gives is a suggestion, not an order. A machine may break, a delivery may be late, a worker may be absent, and the plan must be remade on the spot. The person who plans the day must be able to read the model's plan, see why it chose that order, and change it when the real world changes. A plan that cannot be understood cannot be trusted, and a plan that cannot be changed fast is worse than no plan at all.
The diagram shows the plan in order. The steps point to the diagram: the model searches many plans and scores them, but the planner still checks the plan and changes it when the day changes.
Quick self-check
Question: Why does a good plan group similar products together?
To keep changeovers to a minimum. Switching a line from one product to another takes time and wastes material, so grouping similar products means fewer switches and less waste.
Question: Why must a planner be able to understand the model's plan?
Because the day changes: machines break, deliveries are late, people are absent. A plan that cannot be understood cannot be changed sensibly when those things happen.
Energy, water, and waste inside the process
Food processing uses energy to heat, cool, dry, and freeze, and water to wash, cool, and make steam. Both cost money, and both leave a mark on the world, so using less of them, without changing the food, is a proper goal for a food business. AI helps here by finding the waste that is hard to see: an oven that runs hotter than it needs to, a dryer that runs longer than it needs to, a cooling system that cools an empty room, a line that waits with its machines running.
The model reads the energy and water records alongside the production records and learns the pattern of normal use: how much energy a batch should take, how much water a wash should take, and when the use is higher than the pattern says it should be. A batch that uses far more energy than similar batches is flagged, and a person looks for the cause: a door left open, a sensor out of place, a setting left high after a trial. The saving comes not from the model alone, but from the person who acts on the flag.
Waste inside the process is the same story. Dough trimmings, broken biscuits, spilled milk, overfilled packs: each one is a small loss, and together they add up. A model that reads the waste records can show where the losses are largest and when they happen: at the start of a shift, after a changeover, on one line more than the others. The fix is usually a change in the process or in the routine, not a new machine, and the model earns its keep by pointing at the right place to look.
Quick self-check
Question: How does a model find wasted energy?
By learning the pattern of normal energy use for each kind of batch, then flagging batches that use far more than similar batches. A person then looks for the cause, such as a door left open or a setting left high.
Question: Why does a model point at waste instead of fixing it?
Because the fix is usually a change in the process or the routine, made by a person. The model shows where the loss is largest; the person changes the routine that causes it.
When the model is wrong on the line
A process model will be wrong sometimes, and the line must be built to survive that. The most common failure is a change in the raw material: a new flour, a new milk supply, a new season's fruit. The model was trained on the old material, and its suggestions, learned from that material, no longer fit the new one. The signs are plain: the food starts to drift from its standard even though the settings follow the model's suggestion. The remedy is to notice the drift early, go back to the operator's judgement and the standard settings, and retrain the model on the new material.
A second failure is a broken sensor. A temperature sensor that reads low will make the model think the oven is cool, and it will suggest more heat, while the real oven is already hot. The model cannot know the sensor is lying: it only reads the numbers it is given. The defence is the same as in any process: check the sensors, calibrate them on a routine, and watch for a reading that disagrees with the food itself. When the sensor says cool and the biscuits are dark, the sensor is wrong, not the biscuits.
A third failure is a model that is followed without question. An operator who sets the oven exactly as the model says, even when the dough looks wrong, has given away the judgement that the model depends on. The rule on the line is simple: the model suggests, the operator decides, and the food is the judge. If the food is wrong, the setting is wrong, whatever the model said.
Quick self-check
Question: A new flour arrives and the biscuits drift from standard, though the settings follow the model. What has happened?
The model was trained on the old flour, and its suggestions no longer fit the new one. The remedy is to return to the operator's judgement and the standard settings, and to retrain the model on the new flour.
Question: A sensor reads low and the biscuits are dark. Which is wrong?
The sensor. The food is the judge: when the sensor disagrees with the food, the sensor must be checked and calibrated, not the food.
Try it yourself
Pick a cooking process you know: baking bread, boiling rice, or making tea. Write down its settings: the heat, the time, the amount of water, the size of the pot. Now write down three things that change the result: the age of the ingredient, the weather, the size of the batch. For each one, write what you would change in the settings to keep the result the same. Then ask yourself: could a model learn that link from records of your cooking? What records would it need, and what would you have to measure every time instead of judging by eye? Write your answers in half a page. You have just written the first draft of a process model, in plain words, for a process you already understand.
Key ideas to carry forward
- A process model learns the link between settings, conditions, and the food, and suggests settings for each day's raw material and weather.
- The tuning loop is suggest, run, measure, learn: honest measurement of the food is the step the loop depends on.
- Optimisation balances many goals at once: quality, speed, energy, and waste, and the quality limits must be written in before the model starts.
- Learning by trying changes one setting at a time, measures the result, and keeps the changes that help.
- Production planning searches many possible plans and scores them on time, waste, and changeovers, and the planner still checks and changes the plan.
- Grouping similar products together keeps changeovers, and their waste of time and material, to a minimum.
- Energy and water waste is found by learning the pattern of normal use and flagging batches that use far more than similar batches.
- When the food disagrees with the model, the food is right: the model is retrained, the sensor is checked, and the operator decides.
Glossary
Process
A set of steps that turns raw material into a finished food, such as mixing, heating, cooling, and packing. Food tech example: baking is a process with mixing, proving, and baking steps.
Production planning
Deciding what to make, how much, and in what order, so orders are met without waste. Food tech example: planning which biscuits run on which line each day is production planning.
Optimisation
Finding the settings that balance several goals best, such as quality, speed, energy use, and waste. Food tech example: choosing the oven temperature and time that give good biscuits with the least energy is optimisation.
Changeover
The cleaning and resetting of a line when it switches from one product to another. Food tech example: changing a biscuit line from plain to chocolate biscuits needs a changeover.
Setting
A value chosen for a process, such as oven temperature, belt speed, or mixing time. Food tech example: the oven temperature is a setting the operator chooses for each batch.
Trial
A small test run with one change, measured and compared with the standard. Food tech example: baking one batch at a lower temperature to test an energy saving is a trial.
Trade-off
A choice where improving one goal makes another goal worse. Food tech example: baking faster by raising the heat trades speed against energy use and the risk of burning.
Capacity
How much a line, a machine, or a team can make in a given time. Food tech example: a line with a capacity of one tonne of biscuits per hour.
Throughput
The amount of food that passes through a process in a given time. Food tech example: the throughput of a dryer is the weight of product dried per hour.
Sensor
A device that measures a physical property, such as temperature, weight, or colour, and records it as data. Food tech example: a temperature sensor in an oven records the heat at three points.
Calibration
Checking and setting a measurement so it is true. Food tech example: checking an oven sensor against a known thermometer is calibration.
Energy use
The energy a process takes to run, usually as heat or electricity. Food tech example: the energy use of a dryer is the fuel or electricity it takes to dry one batch.
Waste
Material, time, or energy lost in a process without becoming finished food. Food tech example: dough trimmings and broken biscuits are waste from a biscuit line.
Batch
One run of a process, making one amount of food under one set of conditions. Food tech example: one oven load of biscuits is a batch.
Standard
The set of qualities a food must meet, such as colour, moisture, weight, and taste. Food tech example: the standard for a biscuit fixes its colour, weight, and moisture range.
References
- Irudayaraj, J., Food Processing Operations Modeling, Design, and Analysis, 2nd edition, 2002.
- Singh, R. P., Computer Applications in Food Technology, 1996.
Unit 6: AI in Supply Chain, Demand Forecasting and Reducing Waste
Note
Unit 6: AI in Supply Chain, Demand Forecasting and Reducing Waste
A question to start with
A small dairy makes fresh yoghurt every morning. Some days it sells out by noon and customers leave empty handed. Other days half the pots are left at closing time and must be thrown away, because fresh yoghurt cannot be sold the next day. The dairy owner keeps a notebook: the weather, the day of the week, whether a school holiday is on, how many pots were made, and how many were sold. After a year, the notebook holds a pattern the owner can feel but cannot quite state: rainy Mondays are slow, sunny Fridays before a holiday are fast, and the week after a festival is always quiet. A model reads the same notebook, now kept as a spreadsheet, and turns that feeling into a number for tomorrow: make this many pots. The waste falls, the sell-outs fall, and the owner still checks the number against the day ahead, because a model cannot know that a road is closed or a local event is on. This unit explains how AI forecasts demand, moves food through the supply chain, and cuts waste, and where the numbers stop and the person's local knowledge begins.
The supply chain is the path food takes from where it is made to where it is eaten: farms, stores, factories, warehouses, shops, and kitchens. At each step, someone must decide how much to make, how much to store, how much to move, and when. Those decisions are hard because demand changes: people buy more on some days than others, seasons change what people want, and a delay at one step leaves the next step short. AI helps by reading the records of what was bought, made, and moved, and by turning those records into a forecast: a reasoned guess about tomorrow, next week, and next month.
Questions to think about
- A shop sells more bread on Saturday than on Tuesday. What records would prove that, and what would a forecast for next Saturday need to know?
- A warehouse throws away food that expired before it was sold. Was the problem the forecast, the storage, or the ordering?
- A model forecasts demand from last year's sales. What could make last year a bad guide to this year?
Think about the warehouse question before you read on
It could be any of the three, and the records must be read to tell them apart. If the forecast was too high, too much was ordered. If the storage was warm or slow, food spoiled before its date. If the ordering ignored what was already in store, new stock arrived while old stock was still waiting. Waste is usually a chain problem, not a single mistake, and the fix depends on which link failed.
Demand forecasting: learning the pattern of buying
Demand is how much people want to buy, and forecasting is guessing that amount before it happens. A forecast is never exact, and a good forecaster says so plainly: the forecast is a number with a range around it, and the range matters as much as the number. A forecast that says "about a hundred pots, and the range is ninety to one hundred and ten" is more useful than a forecast that says "one hundred" with no sense of how wrong it could be.
A model forecasts demand by learning the pattern in past sales. It reads the sales record, day by day, and finds the rhythms in it: the weekly rhythm, with weekends different from weekdays; the yearly rhythm, with seasons changing what people buy; the holiday rhythm, with festivals and school breaks lifting or cutting demand; and the weather rhythm, with hot days lifting sales of cold foods and cold days lifting sales of warm ones. It also reads the things that changed demand in the past: a price change, a new product, a promotion, a shop opening nearby. Each of these is a feature, and the model learns how much each one moves the sales.
The forecast is then used to decide how much to make and how much to order. That decision must carry a safety margin: a little extra stock to cover the days when demand is higher than the forecast, balanced against the cost of the stock that is left over. Fresh food makes that balance sharp, because leftover fresh food cannot be kept: the margin that protects against a sell-out is the same margin that creates waste when demand is low. The model's job is to make the forecast as accurate as it can be, so the margin can be as small as it can be, and the person's job is to set the margin with the food's keeping time in mind.
The diagram shows the five steps in order. The steps point to the diagram: step 5 closes the loop, because a forecast that is never checked against real sales never improves.
Quick self-check
Question: Why is a forecast with a range more useful than a single number?
Because a forecast is never exact, and the range says how wrong it could be. A range of ninety to one hundred and ten tells the planner how much extra stock is a sensible margin, while a single number hides the risk.
Question: Why does fresh food make the safety margin a sharp balance?
Because leftover fresh food cannot be kept and sold later. The extra stock that protects against a sell-out becomes waste on a slow day, so the margin must be set with the food's keeping time in mind.
What makes a forecast go wrong
Forecasts go wrong for reasons that are easy to name and hard to prevent. The first is a change in the world that is not in the past data: a new shop opens nearby, a road closes, a festival moves its date, a product changes its recipe or its pack. The model learned from a world that no longer exists, and its forecast belongs to that old world. The remedy is local knowledge: the person who knows the road is closed, or the festival has moved, adjusts the forecast before it is used, and the model is retrained once the new pattern has enough history behind it.
The second reason is a change in the data itself. Sales records can mislead: a day when the shop ran out of stock looks like a day of low demand, when in fact the demand was high and the shelves were empty. A day when a promotion cut the price looks like a day of high demand, when in fact the price, not the appetite, did the work. A model trained on those records without knowing about the stock-out or the promotion will learn the wrong lesson. The cleaning rule from Unit 2 applies here with force: a sales record is only a record of what was sold, not of what people wanted to buy, and the two differ whenever the shelf was empty.
The third reason is noise: the random ups and downs of daily sales that no model can predict. A forecast that chases every daily wiggle will overfit, swinging wildly from day to day. A sound forecast learns the steady rhythms and accepts that the daily noise will remain. The judgement of a forecast is therefore not whether it is exact, but whether its errors are smaller, and its bad days fewer, than the method it replaces.
Quick self-check
Question: A shop sold few loaves on a day it ran out of stock by noon. What does that sales record really mean?
It means the shop sold all it had, not that demand was low. The true demand was higher than the sales, and a model that reads the sales as demand will learn the wrong lesson and forecast too little next time.
Question: Why should a forecast not chase every daily wiggle in sales?
Because much of the daily change is random noise that cannot be predicted. Chasing it makes the forecast swing wildly and overfit, while a sound forecast learns the steady rhythms and accepts the noise.
Moving food: stock, storage, and the cold chain
Once the forecast is made, the food must be made, stored, and moved. Each of those steps holds stock, and stock is food waiting: waiting in a warehouse, waiting in a truck, waiting on a shelf. Waiting costs money, takes space, and, for fresh food, eats into the shelf life. The supply chain problem is to keep enough stock to meet demand without holding so much that it spoils or so little that the shelf is empty.
AI helps by reading the stock records together with the forecast and the shelf life. It can suggest how much to order, when to order it, and where to send it: the shop that sells fast gets more, the shop that sells slowly gets less, and the stock with the shortest life left is sent where it will sell first. That last rule, sending the oldest stock first, has a plain name: first in, first out. A model that knows the age of every batch can apply that rule far more exactly than a person working from memory, and it can spot the batch that is quietly ageing in a corner while newer stock is sold ahead of it.
The cold chain is the part of the supply chain where temperature matters most: the unbroken chain of chilled or frozen storage and transport from the maker to the eater. Sensors in trucks and stores record the temperature through the journey, and a model reads those records to find the weak links: the truck that warms up at midday, the store room that runs warm on busy days, the loading bay where pallets wait in the sun. Finding the weak link is the first step to fixing it, and the fix is usually a change in routine, such as loading faster or shading the bay, not a new truck.
Quick self-check
Question: What does first in, first out mean?
It means the oldest stock is used or sold first, so no batch ages quietly while newer stock is sold ahead of it. A model that knows the age of every batch can apply the rule exactly.
Question: What is the cold chain?
The unbroken chain of chilled or frozen storage and transport from the maker to the eater. If the chain breaks, if food warms up on the way, its safety and shelf life suffer.
Reducing waste: where food is lost, and why
Food waste is food made or grown for people that is never eaten. It happens at every step: in the field, in storage, in the factory, in the shop, and in the home. The reasons differ at each step. In storage, food spoils because it waits too long or is kept too warm. In the factory, food is lost as trimmings, breakage, and overproduction. In the shop, food is lost because too much was ordered, or because the oldest stock was not sold first. In the home, food is lost because too much was bought, or because it was forgotten at the back of the fridge.
AI cuts waste by making each of those decisions more exact. A better forecast means less overproduction. A better stock rule means the oldest food is sold first. A better shelf life prediction means the food that will spoil soonest is used soonest. A model that reads waste records can show where the losses are largest, and that showing is often the most valuable thing it does: a business that learns that most of its waste happens on one line, or on one day of the week, or with one product, can fix that one place and cut its waste far more than by trying to fix everything at once.
The measure of waste matters. Waste should be counted by weight and by cause, not only by value, because the fix depends on the cause. Waste from spoilage needs a different fix from waste from breakage, and waste from overproduction needs a different fix from waste from a wrong order. A model that only counts the total will hide those differences. A model that counts by cause, and by place and by day, shows the business where to act.
The diagram shows the places where food is lost. The steps point to the diagram: the fix is different at each place, so waste must be counted by cause and by place, not only as one total.
Quick self-check
Question: Why count waste by cause, not only as a total?
Because the fix depends on the cause. Spoilage needs better storage or faster use, breakage needs a process fix, and overproduction needs a better forecast. A single total hides those differences.
Question: What is the most valuable thing a waste model often does?
It shows where the losses are largest: one line, one day, one product. That focus lets the business fix the worst place first, instead of trying to fix everything at once.
Suppliers, orders, and working together
A supply chain is not one business: it is many businesses linked together, and each one keeps its own records. A factory orders from suppliers, a warehouse supplies shops, and a shop serves customers. When each link plans alone, the chain wastes food: the shop orders extra to be safe, the warehouse orders extra to cover the shop's extra, and the factory makes extra to cover the warehouse's extra. Each small safety margin adds up to a large overproduction at the start of the chain. This piling up of margins has a name: the bullwhip effect, because a small flick at the customer end becomes a large swing at the factory end.
AI helps by sharing the forecast, not only the order. When the shop shares its sales and its forecast with the warehouse and the factory, each link can plan from the same demand instead of from the order of the link below it, and the margins stop piling up. The sharing needs trust and clear rules about whose data is whose, and it needs the data to be in a form each business can use. The technology is the easy part: the agreement to share, and the habit of sharing honestly, is the hard part, and it is a business decision, not a software decision.
Supplier choice is another place where AI helps, and where it must be handled with care. A model can read supplier records: delivery times, quality results, and prices, and it can score suppliers on those records. That score is a useful guide, but it is not a verdict: a supplier with a poor score because of one bad season, or because its records are patchy, may be a good supplier judged unfairly. The score must be read with the story behind it, and the decision to change a supplier must weigh the score against the relationship, the reliability, and the food itself.
Quick self-check
Question: What is the bullwhip effect?
When each link in a supply chain adds its own safety margin to its order, so a small change in customer demand becomes a large swing in production at the start of the chain. Sharing the forecast, not only the order, calms the swing.
Question: Why is sharing a forecast better than sharing only an order?
Because each link can then plan from the same demand, instead of guessing from the order of the link below it. The safety margins stop piling up, and less food is made than will be sold.
The last step: food that is left, and what happens to it
Even with the best forecast, some food will be left over. The question then is what happens to it. The first choice is to sell it sooner or to use it sooner: a shop can cut the price near the end of the day, a factory can use short-life stock in a product that is made the same day, a kitchen can plan a dish around the ingredient that must be used first. A model can help here too, by listing the stock that will spoil soonest and suggesting where it can be used or sold first, so that the food is eaten instead of wasted.
The second choice is to keep it safe while it waits: the cold chain, the storage routine, and the first-in-first-out rule are the defences that buy time. The third choice, when food cannot be sold or used in time, is to find another use for it: animal feed, compost, or energy, where the rules allow. Those uses are better than throwing food away, but they are still a loss of the food itself, and they should not be used as an excuse for a bad forecast. The order of choices is plain: prevent the waste first, use the food second, and find another use only when the food cannot be eaten.
Quick self-check
Question: What should happen first to food that will soon spoil?
It should be sold or used sooner, where it can still be eaten: the shop sells it first, or the kitchen plans a dish around it. Prevention and early use come before any other use.
Question: Why is finding another use for wasted food not a fix for a bad forecast?
Because the food is still lost as food, even if it becomes feed or compost. Another use softens the loss, but only a better forecast prevents it.
Try it yourself
Keep a food diary for one week for a single food in your home: bread, milk, or fruit. Each day, write down how much you had at the start of the day, how much you used, how much was left, and whether any was thrown away. At the end of the week, look at the pattern: which days did you use most, which days least, and did the weather or the day of the week explain the difference? Now write a forecast for next week, in plain words: how much will you buy, and on which day? Keep the diary for a second week and check your forecast against what really happened. How far off were you, and what did you miss? That error, and the reason for it, is the same lesson a demand model learns from every week of real sales.
Key ideas to carry forward
- A forecast is a number with a range around it: the range matters as much as the number, because it sets the safety margin.
- Demand has rhythms: weekly, seasonal, holiday, and weather rhythms that a model can learn from past sales.
- Sales are not demand: a day the shelf was empty looks like low demand, when the true demand was higher than the sales.
- A model trained on an old world fails when the world changes: local knowledge must adjust the forecast before it is used.
- First in, first out means the oldest stock is sold or used first, so no batch ages quietly in a corner.
- The cold chain is the unbroken chain of chilled or frozen storage and transport, and a model can find its weak links from sensor records.
- Waste must be counted by cause, place, and day, because the fix depends on the cause.
- Sharing the forecast, not only the order, calms the bullwhip effect, where small margins pile up into large overproduction.
- Prevent waste first, use the food sooner second, and find another use only when the food cannot be eaten.
Glossary
Supply chain
The path food takes from where it is made to where it is eaten: farms, stores, factories, warehouses, shops, and kitchens. Food tech example: milk moves from farm to dairy to shop to home along a supply chain.
Demand
How much people want to buy. Food tech example: the demand for cold drinks rises on hot days.
Demand forecasting
Guessing how much people will want to buy, before it happens, from past sales and other records. Food tech example: forecasting how many pots of yoghurt will sell tomorrow.
Safety margin
Extra stock held to cover the days when demand is higher than the forecast. Food tech example: making a few extra loaves in case Saturday demand is higher than expected is a safety margin.
Stock
Food held waiting, in a warehouse, a truck, or a shop, before it is sold or used. Food tech example: flour held in a bakery store is stock.
First in, first out
The rule that the oldest stock is used or sold first. Food tech example: a shop sells the oldest milk first, so no carton ages past its date at the back of the shelf.
Cold chain
The unbroken chain of chilled or frozen storage and transport from maker to eater. Food tech example: frozen peas kept frozen from factory to shop freezer are in the cold chain.
Shelf life
The time a food stays safe and acceptable under stated storage conditions. Food tech example: fresh yoghurt has a short shelf life under chilled storage.
Food waste
Food made or grown for people that is never eaten. Food tech example: bread thrown away at closing time is food waste.
Bullwhip effect
When each link in a supply chain adds its own safety margin, so a small change in customer demand becomes a large swing in production. Food tech example: shops, warehouses, and factories each ordering extra leads to far too much food made at the start.
Changeover
The cleaning and resetting of a line when it switches from one product to another. Food tech example: changing a line from plain to chocolate biscuits needs a changeover.
Order
A request from a customer or a shop for a stated amount of food by a stated time. Food tech example: a shop orders two hundred loaves for Saturday morning.
Promotion
A temporary cut in price, or another offer, that lifts sales for a short time. Food tech example: a lower price on yoghurt for one week is a promotion.
Seasonal demand
Demand that rises and falls with the seasons. Food tech example: demand for ice cream rises in hot weather and falls in cold weather.
Warehouse
A large store where food is held before it is sent to shops. Food tech example: a chilled warehouse holds yoghurt before it is delivered to shops.
References
- Irudayaraj, J., Food Processing Operations Modeling, Design, and Analysis, 2nd edition, 2002.
- Singh, R. P., Computer Applications in Food Technology, 1996.
Unit 7: Limits, Ethics, Jobs and the Future of AI in Food
Note
Unit 7: Limits, Ethics, Jobs and the Future of AI in Food
A question to start with
A food company buys a new AI system. The seller says it will cut waste, catch every fault, and pay for itself in a year. The system is switched on, and for a month it works well. Then a new season starts, the fruit changes colour, the supplier changes, and the system's grades start to drift. The company calls the seller, who says the model needs retraining, at a price, and the retraining needs new labelled photographs, which the company must supply. The system is still in the factory, the staff have stopped trusting it, and the money is already spent. The failure was not in the model. It was in the promise: a system was bought as if it were a machine that works on its own, when it is really a system that needs people, data, and care for as long as it runs. This unit is about that whole picture: the limits of AI, the ethics of using it with food and people, the jobs it changes, and how to judge the next promise that arrives.
The first six units showed what AI can do in food: learn from records, see quality, flag safety risks, tune processes, plan production, and forecast demand. This unit steps back and asks the questions that decide whether any of that is worth doing, and worth doing well. What can AI not do? Who is responsible when it is wrong? Whose data is it learning from? Whose job changes, and who gains from the change? And when a new AI product is offered, how does a food professional judge it with a clear head instead of being carried along by the promise?
Questions to think about
- A seller promises an AI system that will catch every fault. What questions would you ask before believing that promise?
- A model learns from the records of one factory. Who owns those records, and who should be allowed to use what the model learned from them?
- A sorting line is automated and three jobs change. Who gains from the change, and who should be helped through it?
Think about the seller's promise before you read on
Ask for the test: on what new cases was it tested, from which batches and seasons, and what were its mistakes, not only its headline score? Ask what it needs to keep working: whose labels, whose cleaning, whose checking, and what it costs when the food changes. Ask what happens when it is wrong, and who carries the responsibility. A promise without a test, a cost, and a person responsible for the result is a sales claim, not a plan.
The limits, stated plainly
AI has four limits that run through every unit of this subject, and they are worth collecting here in one place. First, a model only knows the past. It learns from the examples it was given, and a new hazard, a new ingredient, a new process, or a new way of breaking the rules will not be in those examples. The model will not flag what it has never seen, and the safety system must keep its other defences working for exactly that case.
Second, a model only knows what it was given to measure. It cannot taste, smell, or feel, and it cannot see inside a food unless a sensor shows it the inside. A photograph shows the outside, a temperature log shows heat, a sales record shows what was bought. Each of those is a part of the food, never the whole food, and a judgement made from one part alone will miss the faults that live in the other parts.
Third, a model can be wrong with confidence. It gives an answer, not a doubt, and the answer can be wrong in a way that looks certain. A model that has memorised its training examples will give a high score on those examples and fail on new ones, and nothing in its own output will warn you. The warning comes from outside the model: from the honest test on new cases, from the lab result that disagrees, from the food that looks wrong.
Fourth, a model learns the pattern it is given, including a broken one. If the records are biased, if one group of suppliers is recorded in detail and another is not, if the labels carry a person's prejudice or a past mistake, the model will learn that bias and repeat it at scale, faster and more steadily than any person could. The bias is not in the computer: it is in the data, and it must be found and fixed in the data.
The diagram shows the four limits in order. The steps point to the diagram: each limit is met by a human check outside the model, a test, a lab result, a look at the food, and a check of the data.
Quick self-check
Question: Why will a model not flag a new hazard?
Because it only knows the past, and the new hazard is not in its training data. The model learns from examples it was given, and an example it has never seen cannot be part of the pattern it learned.
Question: What is bias in a model's data?
When the records or the labels carry a slant, such as one supplier recorded in detail and another barely recorded, or labels that carry a person's prejudice or a past mistake. The model learns that slant and repeats it.
Ethics: food, people, and data
Ethics in AI is the question of what is right to do with the system, not only what is possible. In food, the first ethical duty is safety: no system may be used in a way that puts people at risk, and no efficiency saving is worth a safety cut. A model that saves money by testing less, or by releasing batches sooner, must be judged against the safety it removes, and the judgement must be made by people who carry the responsibility, not by the model's own score.
The second duty is honesty about food. A model that grades food, labels it, or writes about it must not mislead the eater. A photograph that makes a product look better than it is, a grade that flatters a poor batch, a claim that a model cannot support: each of these breaks the trust between the maker and the eater, and that trust, once broken, is hard to rebuild. AI that touches labels, grades, and claims must be checked against the real food, in the same way a label claim is checked by a lab test.
The third duty is about data and privacy. Food businesses hold records about suppliers, workers, and customers: who delivered what, who worked which shift, who bought what, and what they complained about. A model trained on those records can reveal things about people that were never meant to be shared, and the records can be used in ways the people who gave them never agreed to. The rules are plain: collect only the data that is needed, use it only for the purpose it was collected for, keep it safe, and be able to say, when asked, what data was used and for what. Workers whose work is measured by a model should know what is measured, how it is used, and how they can challenge a judgement made about them.
The fourth duty is fairness. A model that decides which suppliers are trusted, which workers are flagged, or which products are graded well must not treat people unfairly because of where they come from, or because their records are thinner than someone else's. The check is to look at the model's results for different groups, and to ask whether the differences come from the food or from the records. If they come from the records, the records must be fixed before the model is used to judge people.
Quick self-check
Question: Why must workers know what a model measures about them?
Because the measurement affects their work and their standing, and they should be able to understand it, question it, and challenge a judgement made about them. A measurement kept secret cannot be checked, and a judgement that cannot be checked cannot be trusted.
Question: What is the first ethical duty of AI in food?
Safety. No system may be used in a way that puts people at risk, and no saving in money or time is worth a cut in safety.
Jobs: what changes, what stays, and what is new
AI changes food jobs, and the change is easiest to understand in three parts: what is taken away, what stays, and what is new. What is taken away is the repetitive judgement: grading every fruit by hand, watching every gauge, copying numbers from one record to another. Those tasks are tiring, and a person doing them all day will drift, tire, and make mistakes. A machine that takes them over does not only save time: it makes the judgement steadier.
What stays is the judgement that a machine cannot make: tasting the food, smelling a fault, deciding whether a batch is safe to release, knowing that a road is closed or a festival has moved, and taking responsibility for the decision. Those tasks need experience, senses, local knowledge, and accountability, and they stay with people. The person who used to grade every fruit now checks the grader's mistakes, teaches it with new photographs, and handles the cases it has never seen. The job has moved up a level, from doing the judgement to checking and teaching the judgement.
What is new is the work of caring for the system: collecting and cleaning data, labelling photographs, testing the model on new cases, watching for drift, and retraining it when the food changes. Those are real skills, and they are food skills as much as computer skills: the person who labels a photograph must know what a bruise looks like, and the person who checks a model must know what a good loaf looks like. A food business that buys AI without training its people in those skills will have a system nobody can check, and a system nobody can check will be trusted until the day it fails, and then blamed for a failure that was really a failure to care for it.
The change is not painless. Some jobs will shrink, some people will need new skills, and some will need time and support to learn them. A fair change is one where the people whose jobs change are told early, are trained for the new work, and share in the gain: steadier food, less waste, and work that is less tiring and more skilled. A business that plans the change with its people, instead of imposing it on them, will keep the knowledge that the model depends on: the operators who know the feel of the process are the very people who must teach and check the model.
Quick self-check
Question: What part of a food job does AI take away?
The repetitive judgement: grading every fruit, watching every gauge, copying numbers. Those tasks tire a person and drift with tiredness, while a machine applies the same rule every time.
Question: What new work does AI create in a food business?
Caring for the system: collecting and cleaning data, labelling photographs, testing the model on new cases, watching for drift, and retraining it when the food changes. That work needs food knowledge as much as computer knowledge.
Judging a new AI promise: a checklist that fits in a pocket
New AI products for food arrive often, and each one comes with a promise. A food professional needs a way to judge the promise without becoming a computer expert, and the checklist below is that way. It fits in a pocket, and it can be used in a single meeting with a seller. The questions are the same ones this subject has asked in every unit, and a seller who cannot answer them has not done the work the promise assumes.
First, what question does the system answer, and what data does it use? The answer should be a food question in plain words, and the data should be records the business already has or can collect honestly. Second, how was it tested, and on what new cases? The test should be on cases from different days, batches, and lots from the training data, and the mistakes should be shown, not only the headline score. Third, what happens when the food changes? A new season, a new supplier, a new recipe: how is the model retrained, who does it, and what does it cost? Fourth, who is responsible when it is wrong? The answer should name a person, not a system, and the safety checks behind the model should still work if the model fails. Fifth, what does it cost to keep running, not only to buy? The cost includes labelling, cleaning, checking, and retraining, for as long as the system runs.
If the answers are clear, the system is worth a trial: a small, honest trial on the real line, measured against the standard, with the result written down before the decision is made. If the answers are vague, or if the seller will not show the mistakes, the promise is not ready to be bought, whatever the headline score says.
The diagram shows the five questions in order. The steps point to the diagram: a clear answer to all five is the start of a trial, and a vague answer to any one of them is a reason to wait.
Quick self-check
Question: A seller shows a 98 percent score but will not show the mistakes. Should you buy?
No. The headline score hides which mistakes the model makes, and in food the kind of mistake matters more than the count. A seller who will not show the mistakes has not done the honest test.
Question: Why ask about the cost of keeping a system running, not only the price to buy it?
Because the system needs labelling, cleaning, checking, and retraining for as long as it runs. A cheap system that costs a lot to keep honest is not cheap at all.
The future: what is likely, what is not, and what to watch
The future of AI in food is easier to judge if the promise is split into three parts: what is likely, what is possible, and what is only a story. What is likely is more of what this subject has described, done better: cameras that grade more steadily, models that forecast more exactly, sensors that are cheaper and more common, and records that are kept better because they are used more. The gain will come not from a single new invention but from the steady work of better data, better testing, and better care for the systems already in place.
What is possible, but not certain, is a wider use of AI in places where data is now thin: small businesses that have never kept records in a form a model can use, foods that are made in small batches with much variation, and tastes and textures that are hard to measure. Those uses will grow as sensors get cheaper and as the habit of recording spreads, but they will grow slowly, because the food, the variation, and the small amount of data make the learning hard.
What is only a story is the idea of a food system that runs itself: a factory with no people, a kitchen with no cook, a safety system with no one responsible. Food is eaten by people, and the decisions about it carry a weight that a model cannot carry: the taste, the safety, the trust, and the responsibility. The future that fits the food industry is not a factory without people. It is a factory where people do the work that needs people, and machines do the work that needs a machine, and the two are checked against each other every day.
Three things are worth watching as that future arrives. First, the cost of sensors and the habit of recording: as both spread, more food businesses will have the data that AI needs. Second, the rules that govern food, safety, and data: as AI touches more decisions, the rules will say more clearly who is responsible and what records must be kept. Third, the skills of food professionals: the people who can read a model, check it against the food, and teach it with better examples will be the people the industry needs most, and this subject is a first step toward those skills.
Quick self-check
Question: What is the most likely future for AI in food?
More of what this subject describes, done better: steadier grading, more exact forecasts, cheaper sensors, and better records, with the gain coming from better data, better testing, and better care, not from a single new invention.
Question: Why will a food factory never run itself?
Because food is eaten by people, and the decisions about it carry taste, safety, trust, and responsibility that a model cannot carry. People will always be needed to taste, to decide, and to answer for the food.
Try it yourself
Find a real AI promise for food: an advertisement, a product page, or a sales claim you have seen. Write down the promise in one sentence, then run it through the five questions in the checklist above. For each question, write what the seller actually says, and what they do not say. If the seller says nothing about the test, the mistakes, the retraining, or the person responsible, write that down too: silence on those questions is an answer. Finish by writing your own verdict in two sentences: would you trial this system, and what trial would you run first? Keep the page: it is the habit this whole subject has been teaching, applied to a real promise.
Key ideas to carry forward
- A model only knows the past, only knows what was measured, can be wrong with confidence, and learns the bias in its data.
- Safety comes first: no efficiency saving is worth a safety cut, and no model may be the only check on a safety decision.
- AI that touches labels, grades, and claims must be honest about the food, and checked against the real food.
- Data about people must be collected only as needed, used only for its stated purpose, kept safe, and open to challenge.
- A model must not judge people unfairly because their records are thinner or their group is different: check the results for different groups.
- AI takes away repetitive judgement, leaves the judgement that needs senses, experience, and responsibility, and creates new work in caring for the system.
- A fair change tells people early, trains them for the new work, and shares the gain.
- Judge any new promise with five questions: the question and the data, the test and the mistakes, the retraining, the responsibility, and the running cost.
- The likely future is steadier, better-tested AI in the hands of food professionals, not a factory without people.
Glossary
Bias
A slant in data or labels that makes a model treat some cases unfairly. Food tech example: a model trained mainly on one supplier's records may judge other suppliers unfairly.
Ethics
Questions of what is right to do with a system, not only what is possible. Food tech example: deciding whether a model may be used to cut testing is an ethics question.
Privacy
The right of people to control what is known about them and how their records are used. Food tech example: worker records used to train a model must be kept safe and used only for their stated purpose.
Responsibility
Being answerable for a decision and its result. Food tech example: the person who signs to release a batch carries the responsibility for that batch.
Drift
The slow change in food, light, or camera that makes a model's judgements stop matching the truth. Food tech example: a new season's fruit colour causes drift in a grading model.
Overfitting
When a model memorises its training examples instead of learning the real pattern, so it fails on new cases. Food tech example: a model that remembers each training photograph exactly but cannot judge a new fruit has overfitted.
Transparency
Being open about how a system works, what data it used, and what its mistakes are. Food tech example: a seller who shows the model's test mistakes is being transparent.
Accountability
The clear naming of who answers for a decision made with a model's help. Food tech example: naming the person who releases a batch is accountability.
Fairness
Treating different people and groups justly, without a slant from the data. Food tech example: checking that a supplier score does not punish suppliers whose records are thinner is fairness.
Trial
A small test run of a system on the real line, measured against the standard, before a decision to buy. Food tech example: running a new sorter for one week and counting its mistakes is a trial.
Retraining
Teaching a model again on new labelled examples, so it learns the new season, supplier, or recipe. Food tech example: retraining a fruit grader on this season's photographs is retraining.
Automation
Machines or software carrying out a fixed task by fixed rules, without learning. Food tech example: a filler that puts the same weight of jam in every jar is automation.
Sensor
A device that measures a physical property, such as temperature, weight, or colour, and records it as data. Food tech example: a temperature sensor in a cold store records the temperature every few minutes.
Model
The pattern a computer has learned from data, kept in a form it can use again on new cases. Food tech example: a trained model that grades apples from photographs is used on every new apple that passes the camera.
Test data
Fresh examples a model has never seen, used to check how well it really works. Food tech example: a new set of tomato photographs, kept aside during training, is the test data.
References
- Irudayaraj, J., Food Processing Operations Modeling, Design, and Analysis, 2nd edition, 2002.
- Singh, R. P., Computer Applications in Food Technology, 1996.