Skip to main content

Featured

Space Explorers Book 7: Answers and Explanations

Memunic Space Explorers › Book 7: Memoon and the Search for Another Home › Answers and Explanations Answers and Explanations Habitable means life could live there; inhabited means life does live there. A world can be habitable and empty, as an unoccupied flat has a roof and water but nobody in it. The Moon has almost no air, so water would boil or freeze, and its gravity is only about one-sixth of Earth’s, too weak to keep air. Accept also: no greenhouse blanket, so it swings between very hot and very cold. Venus. It matches Earth in size and roughly in mass, but its thick carbon dioxide air traps heat, making it hot and crushing. “Twin” is only true for size and weight. A dip of 1 per cent means (planet width divided by star width) squared is 0.01, so the ratio is 0.1: the planet is about a tenth as wide as the star. Repeats at the same gap show the planet is going round the star in 12 days, and rule out a one-time event such as a passing object. A planet shines only by reflected l...

Byte by Byte Book 7: Chapter 14 – The AI Project Cycle

Byte by Byte › Book 7: Networks, Programming and Machine Learning › Chapter 14: The AI Project Cycle

Chapter 14: The AI Project Cycle

You will learn: the difference between AI and automation, the six stages of the AI project lifecycle, how to define a problem with the 4Ws canvas, sources of data and how to collect it ethically, data cleaning, formatting and labelling, rule-based and learning-based models, training and testing, accuracy and the confusion matrix, precision and recall, deployment, monitoring and data drift, and how AI is used in India's environment, healthcare, agriculture, transport and education.

🔎 The Case

Nimo had been waiting for this chapter of the adventure for a long time, and it showed. He had arranged the whole desk like a classroom: a whiteboard, coloured pens, and a small stack of index cards with neatly written headings.

"Last year," he said, "you learned what AI is: how it sees, hears, predicts and chats. This year you're going to build one, to solve a real problem. And the first thing every AI engineer learns is that building the model is the smallest part."

He held up six cards. Define the problem. Collect data. Prepare data. Build and train. Evaluate. Deploy and monitor.

"Most AI projects that fail," he said, "fail at card one or card two. Not card four."

Vega looked at the cards. "Card one is easy. The problem is: find the fake clips."

"Is it?" said Nimo. "Find them for whom? How fast? What happens when the AI is wrong? Should it decide, or should it help a person decide?" He smiled. "Card one is never easy."

💡 The Concepts

What is an AI project? In Book 6 you learned that artificial intelligence gives machines the ability to do tasks that normally need human intelligence, such as recognising images, understanding language or making predictions, mostly by learning patterns from data. An AI project is the step-by-step process of building an AI system to solve a real-world problem. The process is called the AI project lifecycle (or AI project cycle). It is iterative: you go round it again and again, improving each time.

   ┌──────── 1. Define the problem ────────┐
   │                                          ▼
6. Monitor and maintain             2. Collect data
   ▲                                          │
   │                                          ▼
5. Deploy                           3. Prepare data
   ▲                                          │
   └── 4b. Evaluate and refine ◀── 4a. Build and train

Stage 1: Define the problem. Before anything else, decide exactly what problem you are solving, for whom, and whether AI is really needed.

AI or automation? Many problems do not need AI at all. Automation follows fixed rules written in advance: it does the same thing every time and does not learn. AI learns from data and adapts its decisions to each situation.

TaskAutomation (fixed rules)AI (learns from data)
Traffic lightsChange every 30 seconds, whatever the trafficAdjust green time to the number of vehicles a camera sees
Watering a gardenWater every day at 7 a.m.Water when soil moisture and the weather forecast say it is needed
Car washSame water, soap and brush time for every carCameras judge the car's size and how dirty it is, and adjust
Spam filterBlock emails containing a fixed list of wordsLearn from millions of emails which features usually mean spam

If a few simple rules solve the problem reliably, use automation: it is cheaper, easier to explain and easier to test. Use AI when the rules are too many, too fuzzy or too changeable to write by hand, such as recognising faces, understanding speech, or spotting edited video frames.

The 4Ws problem canvas. A good way to define the problem is to answer four questions, often written as a problem statement template:

WQuestionFor the Truth Desk
WhoWho has the problem? Who are the stakeholders?Truth Desk checkers; readers deciding whether to forward
WhatWhat exactly is the problem? What is the evidence?Too many new clips to check frame by frame; several are edited
WhereWhere and when does it happen?Clips published on the Mirror and forwarded across the Light Bridges, every day
WhyWhy would solving it help?Checkers could focus on the most suspicious clips first; fewer fakes spread

The resulting problem statement: Our Truth Desk checkers have the problem of too many clips to examine by hand, every day, on the Light Bridges. An ideal solution would flag the clips most likely to be edited, so humans can check those first. Notice the solution flags clips for humans. It does not decide what is true.

Stage 2: Collect data (data acquisition). AI learns from examples, so it can only be as good as its data. Computer scientists have a saying for this: garbage in, garbage out.

SourceExample
SensorsCameras, microphones, thermometers, soil-moisture and air-quality sensors
SurveysQuestionnaires and forms (Chapter 10)
Websites and APIsPublic data, news, open-data portals such as data.gov.in
Historical recordsPast files, reports, sales or exam results
ObservationPeople recording what they see, such as birdwatchers counting species

Collecting data raises ethical questions, which the CBSE AI curriculum stresses at every stage. Do you have permission (consent) to use it? Does it include personal data that must be protected under the DPDP Act 2023? Is it representative, including all the kinds of cases the AI will meet (Book 5)? Are you allowed to use it under its licence?

For the Truth Desk, the data is frames from video clips, each one labelled real or edited.

Stage 3: Prepare data. Raw data is almost always messy. Data scientists often spend most of a project's time on this stage.

Data exploration comes first: look at the data, count it, and draw charts (Chapter 13) to understand it. How many examples of each label are there? Are any values impossible?

Data cleaning fixes problems:

ProblemExampleFix
Missing valuesA frame with no labelFind the label, or remove the row
DuplicatesThe same frame saved twiceRemove the copies, or the model will over-learn them
Incorrect valuesA real frame labelled edited by mistakeCheck and correct
Irrelevant dataFrames of the Mirror's logoRemove: they do not help with the question
OutliersOne frame a thousand times brighter than the restCheck whether it is an error

Data formatting puts everything into the same form: the same image size, the same date format, text converted to numbers where needed. Data labelling (or annotation) attaches the correct answer to each example, such as spam or not spam, plastic or paper, real or edited. Labelling is often done by people, and its quality decides the AI's quality.

Finally the data is split into two sets:

  • Training data (often about 80%): used to teach the model.
  • Test data (about 20%): kept completely separate, and used only to check the finished model on examples it has never seen (Book 6).

Testing on the training data is like letting students see the exam paper in advance. A model that does well on training data but badly on new data has memorised instead of learning. This is called overfitting, and you will see it again in Chapter 15.

Stage 4a: Build and train the model. A model is the part of an AI system that turns inputs into outputs (predictions). It is often compared to the brain of the system. There are two broad approaches:

  • A rule-based model uses rules written by people: if a frame's edge pixels jump more than 20 pixels between frames, flag it. This is closer to automation; it is clear, but brittle.
  • A learning-based model (machine learning) works out its own rules from the labelled training data. You give it thousands of labelled frames, and it finds the patterns that separate real from edited.

Learning from labelled examples is supervised learning, which you met in Book 6, along with unsupervised and reinforcement learning. Most school projects, and the Truth Desk's detector, use supervised learning. The process of the model adjusting itself to fit the training data is called training. Chapter 15 opens up two kinds of model, decision trees and neural networks, to see how training works inside.

No-code AI tools. You do not have to write code to build a model. Teachable Machine (teachablemachine.withgoogle.com, used in Books 4 and 6) and Machine Learning for Kids (machinelearningforkids.co.uk) let you collect and label examples, train a model in your browser, and test it, with a few clicks.

Stage 4b: Evaluate and refine. Evaluation tests the model on the test data and measures how well it performs.

Accuracy is the percentage of predictions that are correct:

accuracy = (correct predictions ÷ total predictions) × 100%

If a model correctly labels 87 of 100 test clips, its accuracy is 87%.

But accuracy alone can hide serious problems. Suppose 80 of the 100 test clips are real and only 20 are edited. A lazy model that always says real gets 80% accuracy, and catches none of the fakes. To see what is really going on, use a confusion matrix, a table comparing what the model predicted with what was actually true. One class is chosen as the positive class: here, edited (the thing we are looking for).

Actually editedActually real
Predicted editedTrue positive (TP): a fake correctly flagged — 15False positive (FP): a real clip wrongly flagged — 8
Predicted realFalse negative (FN): a fake that was missed — 5True negative (TN): a real clip correctly passed — 72

From these four numbers:

  • Accuracy = (TP + TN) ÷ total = (15 + 72) ÷ 100 = 87%.
  • Precision = TP ÷ (TP + FP) = 15 ÷ 23 = 65%. Of the clips it flagged, how many really were fakes?
  • Recall = TP ÷ (TP + FN) = 15 ÷ 20 = 75%. Of all the fakes, how many did it catch?

Which mistakes matter more depends on the problem. A model that screens for a serious disease should have very high recall: missing a sick patient (a false negative) is far worse than a false alarm, which a doctor will check. A spam filter needs high precision: a real email lost in the spam folder (a false positive) can be a real problem. For the Truth Desk, a false positive means a checker wastes a few minutes; a false negative means a fake spreads. So the team wanted high recall, with humans checking everything flagged.

Refining the model when results are not good enough: collect more (and more varied) data, fix incorrect labels, balance the classes, change the model's settings, then train and test again. This loop is why the lifecycle is a cycle.

Stage 5: Deploy. Deployment means putting the model to work in the real world: inside an app, a website, a camera, a hospital system. The model receives new inputs and makes predictions for real users. It is graduation day for the AI. Examples you use daily: spam detection, face unlock, voice assistants, recommendations in shopping and video apps, and translation.

Good deployment also decides how the AI's output is used: who sees it, what happens when it is wrong, and how a person can challenge its decision. The Truth Desk shows a flag with a confidence score and the words Flagged for human checking, never FAKE.

Stage 6: Monitor and maintain. The world changes after a model is deployed. Monitoring keeps checking whether it still works. Maintenance updates it when it does not. A common reason for a model getting worse over time is data drift: the new data it meets no longer looks like the data it was trained on. Exam patterns change, new slang appears, and people trying to fool a detector change their methods. A model that was 87% accurate in testing can quietly become much worse. The fix is new data, retraining, and testing again: back round the cycle.

AI and its applications in India. The CBSE AI curriculum highlights AI that helps solve real problems. A few examples:

AreaHow AI helpsIndian examples
EnvironmentSatellite images and sensor data to spot plastic dumps, deforestation and pollution; air-quality forecastsSatellite mapping of plastic dumps in Himachal Pradesh; Forest Survey of India monitoring forest cover; AI-based air-quality forecasting in several cities
WildlifeCamera traps that recognise animals and send alertsAI camera traps in tiger reserves
HealthcareReading medical images; predicting health risks; health chatbotsAI tools validated by ICMR that read chest X-rays to screen for tuberculosis
AgricultureCrop disease detection from photos, weather and soil adviceGovernment crop-photo and advisory platforms for farmers in their own languages
TransportSignals that adapt to traffic; detecting traffic offences; navigationAdaptive traffic signals in cities such as Bengaluru and Delhi
EducationInstant feedback, personalised practice, translation of lessonsDIKSHA and SWAYAM learning platforms
WasteSorting machines that recognise plastic, metal and organic wasteAI-assisted waste sorting in cities such as Indore and Pune

Each of these went round the same cycle: a clearly defined problem, carefully collected and cleaned data, a model, honest evaluation, careful deployment, and continuous monitoring.

Think About It: A school wants to deploy an AI that predicts which students will score below 75% in the final exam, using attendance, study hours and test marks, so teachers can offer extra help. What could go well? What could go wrong if the predictions are shown to students, or used to decide who gets into an advanced class? Who should be able to see the predictions?

Career Spotlight: Machine learning engineer and data scientist. Data scientists explore and clean data and find what it can and cannot tell us. Machine learning engineers build, evaluate, deploy and monitor models. In India, both jobs are growing fast in healthcare, agriculture, finance and government services.

Illustration from Byte by Byte Book 7: Chapter 14 – The AI Project Cycle

🛠️ Build It

Activity 1: AI or automation? Sort these into automation (fixed rules are enough) and AI (learning from data is needed), and give a reason for each: a lift that stops at the floor you press; a phone that unlocks when it recognises your face; an alarm clock; an app that suggests the next word as you type; a washing machine with a fixed timer; a system that reads number plates at a toll booth; a streetlight that turns on at 6 p.m.; a system that predicts tomorrow's air quality.

Activity 2: Your problem canvas. Choose a real problem in your school or neighbourhood that AI might help with (for example: sorting school waste, predicting when the canteen will run out of food, recognising bird species in the school garden, identifying unhealthy plant leaves). Fill in the 4Ws table and write a one-sentence problem statement. Then answer: could simple automation solve it instead?

Activity 3: Build a waste classifier in Teachable Machine. This follows the CBSE Class 8 activity.

  1. Define: we want a model that recognises plastic, paper and organic waste from a camera image.
  2. Collect: with a grown-up's permission, take 20 to 30 photos of each type (bottles and wrappers; newspapers, notebooks and cardboard; fruit peels, vegetable scraps and dry leaves). Vary the background, lighting and angle.
  3. Prepare: delete blurry, duplicate or mislabelled photos. Keep 5 of each type aside in a separate folder as your test set; do not use them for training.
  4. Build: open teachablemachine.withgoogle.com, click Get Started → Image Project → Standard image model. Rename the classes Plastic , Paper and Organic , and click Upload on each class to add its training photos. Click Train Model and wait.
  5. Evaluate: in the Preview panel, switch the input to File and upload each of your 15 test photos one at a time. Record each prediction and its confidence in a table. Then build a 3 × 3 confusion matrix (actual class down the side, predicted class across the top) and calculate the accuracy.
  6. Refine: which class was confused most? Add more varied photos of that class, retrain and test again. Did the accuracy improve?
  7. Reflect: what happens when you show it something that is none of the three, such as your hand? Why? (The model must always choose one of the classes it knows.)

Activity 4: Calculate evaluation measures in Python. Save as evaluate.py :

def evaluate(actual, predicted, positive="fake"):
    """Compare two lists of labels and return a dictionary of results."""
    tp = fp = fn = tn = 0
    for a, p in zip(actual, predicted):
        if p == positive and a == positive:
            tp = tp + 1
        elif p == positive and a != positive:
            fp = fp + 1
        elif p != positive and a == positive:
            fn = fn + 1
        else:
            tn = tn + 1
    total = tp + fp + fn + tn
    return {
        "TP": tp, "FP": fp, "FN": fn, "TN": tn,
        "accuracy": (tp + tn) / total,
        "precision": tp / (tp + fp) if tp + fp > 0 else 0,
        "recall": tp / (tp + fn) if tp + fn > 0 else 0,
    }
actual    = ["fake", "real", "real", "fake", "real", "fake", "real", 
"real", "fake", "real"]
predicted = ["fake", "real", "fake", "real", "real", "fake", "real", 
"real", "fake", "real"]
results = evaluate(actual, predicted)
for key, value in results.items():
    if isinstance(value, float):
        print(f"{key}: {value:.0%}")
    else:
        print(f"{key}: {value}")

Output:

TP: 3
FP: 1
FN: 1
TN: 5
accuracy: 80%
precision: 75%
recall: 75%

( zip() walks through two lists side by side, pairing their items. tp = fp = fn = tn = 0 sets all four to 0 at once. {value:.0%} shows a decimal as a percentage with no decimal places. isinstance(value, float) checks whether a value is a decimal number.)

Now test the lazy model: print(evaluate(actual, ["real"] * len(actual))) . What are its accuracy and recall? What does this tell you about using accuracy alone?

Activity 5: Deployment plan. For your Activity 2 problem, write a short deployment and monitoring plan: who will use the AI, where its prediction will appear, what a user should do if it is wrong, how you will check each month that it still works, and what would make you switch it off.

Unplugged: Human classifier. One person is the "model". Show them 10 "training" picture cards of two kinds of leaf, each labelled. Then show 10 unlabelled "test" cards and record their guesses. Fill in a confusion matrix and calculate the accuracy. Then repeat with a new person, but give them training cards of only one kind of leaf plus two of the other. What happens to their recall for the rare kind? This is the effect of unbalanced data.

✅ Case Closed

They went round the cycle together. Nimo made them write the problem canvas twice, until it said flag for humans instead of find fakes. Frost and Ribbit gathered 6,000 frames: from the Mirror's clips, and from real recordings of Simbha that the palace and the Times had filmed over the years, with permission. Beautine took charge of cleaning, with terrifying efficiency: she deleted 214 duplicates, sent 37 frames with missing labels back for checking, and discovered that 90 "real" frames had been mislabelled, because they came from a clip the Times had itself once edited for length.

The first model, trained on Teachable Machine, scored 91% accuracy on the test set. Pip wanted to celebrate. Memoon drew the confusion matrix first.

Its recall was only 40%. There were far more real frames than edited ones in the data, and the model had learned that guessing real was usually right. It was catching fewer than half of the fakes.

They balanced the data, gathering more edited examples, and retrained. Accuracy dropped slightly, to 88%. Recall rose to 83%. "A model that is less accurate," said Vega, "and much more useful. I'd never have believed it."

The detector, which Pip insisted on calling Mirror Catcher, went live on the Truth Desk the next morning. Every new clip from the Mirror was scored, and the most suspicious ones went to the front of the checkers' queue.

For two days it worked beautifully. On the third day, its flags dropped almost to nothing. Five new clips came out of the Mirror, and Mirror Catcher passed every one as real.

Memoon looked at them frame by frame. The flicker in the mane was gone. The edges were clean. The voices were smoother. Whoever was making the clips had improved their method.

"Data drift," said Nimo quietly. "Or rather, someone is drifting it on purpose. They know they're being watched."

Memoon stared at the screen. "Then we need to understand what our model is actually looking at, inside," she said. "And we need to understand how their model makes a lion talk."

❓ Test Yourself

  1. What is the difference between AI and automation? Give an example of each from your home.
  2. Name the six stages of the AI project lifecycle in order. Why is it called a cycle?
  3. What are the 4Ws of the problem canvas? Fill them in for an AI that predicts when a school's water tank will run dry.
  4. Name four sources of data. Give two ethical questions to ask before collecting data.
  5. What do data cleaning, data formatting and data labelling mean? Give an example of each.
  6. Why must test data be kept separate from training data?
  7. What is the difference between a rule-based model and a learning-based model?
  8. A model tested on 50 emails gets 44 right. What is its accuracy?
  9. In a confusion matrix for a disease-screening AI, what are a false positive and a false negative? Which is more dangerous, and why?
  10. A detector has TP = 12, FP = 3, FN = 8, TN = 77. Calculate its accuracy, precision and recall.
  11. Why can a model with 90% accuracy still be a bad model?
  12. What is data drift? Give an example.
  13. Give one example each of AI being used in India for the environment, healthcare and agriculture.
  1. Challenge: Plan a complete AI project for one problem in your community, following all six stages. For each stage, write what you would do, what could go wrong, and one ethical check.

📚 Key Terms

  • AI project lifecycle: the six iterative stages of building an AI system.
  • Automation: a system that follows fixed rules and does not learn.
  • Problem statement: a clear description of the problem an AI project will solve.
  • 4Ws canvas: Who, What, Where and Why questions for defining a problem.
  • Stakeholder: anyone affected by a project.
  • Data acquisition: collecting the data a project needs.
  • Consent: permission to collect or use someone's data.
  • Representative data: data that includes all the kinds of cases the AI will meet.
  • Data exploration: examining data to understand it before using it.
  • Data cleaning: fixing missing, duplicate, incorrect and irrelevant data.
  • Data labelling (annotation): attaching the correct answer to each example.
  • Training data / test data: data used to teach a model / data kept back to check it.
  • Model: the part of an AI system that turns inputs into predictions.
  • Rule-based / learning-based model: a model using human-written rules / rules learned from data.
  • Training: the process of a model adjusting itself to fit the training data.
  • Overfitting: memorising the training data instead of learning general patterns.
  • Accuracy: the percentage of predictions that are correct.
  • Confusion matrix: a table comparing predictions with actual results.
  • True / false positive, true / false negative: the four kinds of result in a confusion matrix.
  • Precision: of the items flagged, the fraction that were really positive.
  • Recall: of all the real positives, the fraction that were found.
  • Deployment: putting a model to use in the real world.
  • Monitoring and maintenance: checking and updating a deployed model.
  • Data drift: changes in real-world data that make a model less accurate over time.

Keep learning with Byte by Byte

Explore Book 7: Networks, Programming and Machine Learning. Find the ebook, purchase details and teaching slides on MemuniCity.

Watch this chapter on YouTube

Comments

Popular posts from this blog

CA-7 Job Status and Failure Reason Codes

Here are the various status codes that You may see for jobs in the Queue or Logs in CA-7. R-C0002 R-C0003 R-C0099 R-C0255 R-JCLER A-U0002 A-U0004 A-U0015 A-U0043 A-U4095 A-SOC7 A-U4000 Reason Code/Job Status Code explanation: The indication of the job's current disposition. Values and their meanings are: A-Snnnn-- The job has failed with a system abend. A-Unnnn --The job has failed with a user abend. C-Cnnnn --The job has completed successfully and is going through completion processing. E-ARFATT-- An error occurred during the attempt to attach ARF definitions. This can result if the ARFSET specified is not defined. A diagnostic message may have been written to the CA-7 log, the OS console, or to the trailer queue for the job (in which case it can be displayed using LQ,JOB=x,LIST=ALL). E-ARFERR ---The job encountered an error in the ARF processing. Do a LARFQ command for the job to get more specific information. E-SEGERR --The job has been requeued...

Whistling Winds and Waterfalls: 4 Days of Magic in Shillong

Nestled in the clouds, where the scent of pine trees mingles with the rhythm of waterfalls and the tunes of local guitar-strumming youth—Shillong is more than a place. It’s a vibe. If you’ve got 3 nights and 4 days, you’ve got just enough time to fall in love. Here’s how to make the most of it—food, fun, fog and fantastic views included. Day 1: Shillong, We’re Coming for You! You land in Guwahati, barely out of the airport when the hills start calling. You hop into your cab, Spotify on, windows down, and the three-hour ride to Shillong begins. Just when you think it can’t get better, you stop at Umiam Lake —a lake so calm, it looks like someone ironed the water. By evening, you’re sipping hot chai in Laitumkhrah, maybe nibbling on spicy momos or pork jadoh from a roadside stall. You’re checked into your charming hotel ( Tripura Castle if you fancy old-world royalty, Ri Kynjai if you’re into lakeside poetry). The breeze whispers secrets of waterfalls and pine forests. Sleep well, drea...

Installing and Configuring Hadoop on Ubuntu as a Pseudo Distributed Single Node Cluster

Briefly what is psuedo-distributed single node Hadoop cluster: It is a Hadoop distributed cluster having Single Node. All the five daemons (NN,DN,JT,TT,SNN) are running as individual JVM (java process) instances. We will get all distributed features of Hadoop. This mode is used to develop, test, and staging (before production) Map Reduce programs quickly. It writes all the system, daemon and user logs to different files on the cluster To install Hadoop in this mode, we have to modify the hadoop-env.sh, core-site.xml, hdfs-site.xml, mapred-site.xml. hadoop-env.sh contains all the Environment variables which are required for running Hadoop. All the default values are fine, Only we have to modify the JAVA_HOME=“The location of Java Home Directory” Core-site.xml contains all the cluster specific information like io, temp directory, sorting, file system uri etc. Hdfs-site.xml contains all the parameters which are specific to HDFS like name node directory, data node directory...