AI in drone work
UAT 306 Artificial Intelligence for UAS
Lesson
By the end of this module you will be able to
- Distinguish the main approaches of AI and choose between hand-written rules and machine learning
- Frame a drone AI problem so that it is measurable, and state the cost of each type of error
- Compute positive predictive value (precision) when the target is rare
- Choose a decision threshold from the costs of misses and false alarms
- Explain where AI can support decisions and where people must check
Why this matters
This is the main AI course of the four-year programme, building on statistics in UAT 106 and programming in UAT 104 towards AI systems that work in practice with drone data. The first step, often skipped, is framing the problem: what to detect, what decision the result supports, and which kind of error costs more. The whole course uses the case of detecting cracks on the concrete surface of a bridge from drone images. The numbers are hypothetical.
Types and approaches of AI
Artificial intelligence (AI) is the study of building agents, programs that perceive their surroundings and choose actions to reach a goal; this is the definition used throughout the textbook by Russell and Norvig. AI is not one technique but a family of approaches, and a drone already carries several of them:
- Rule-based (knowledge-based) systems: people write the rules, such as “if the battery falls below the reserve, return to launch” or a geofence check. They are easy to explain and verify, but they are only as good as the rules people can think of.
- Search and planning: the program tries possible options and chooses the best one, such as planning a path around obstacles with the A* algorithm.
- Probabilistic reasoning: combining uncertain evidence, such as the Kalman filter in the flight controller that blends GNSS with the inertial sensors.
- Machine learning (ML): the program learns a pattern from examples instead of being given the rule. Supervised learning learns from labelled examples and answers a class (classification) or a number (regression). Unsupervised learning finds structure in unlabelled data, such as grouping flights or spotting an unusual one. Reinforcement learning learns by trial and reward (Sutton and Barto, 2018); for drones it is trained mostly in simulation, because trial and error in the air is dangerous.
- Deep learning is machine learning with neural networks of many layers, the approach behind most modern image detectors (Module 4).
All AI in use today is narrow AI: good at one defined task and useless outside it. Aviation regulators also classify AI by how much authority it has. EASA’s concept paper on machine learning in aviation describes Level 1 AI as assistance to a human and Level 2 as human–AI teaming, in which the AI takes some decisions under human oversight. This is Issue 2 (March 2024), the latest final issue; a Proposed Issue 3 published on 3 June 2026, open for comment until 12 August 2026, adds Level 3 and further techniques such as reinforcement learning and symbolic AI, so check which issue is in force. The crack detector in this course is Level 1: it helps an engineer, and the engineer decides.
A practical rule: use hand-written rules when experts can state the rule precisely and it rarely changes; use machine learning when the pattern is easy to see but hard to write down, like the look of a crack, and labelled examples can be collected.
Example 1 A rule written by hand versus a threshold learned from data
Stains and cracks differ in their length-to-width ratio. An inspector proposes the rule “a mark longer than 5 times its width is a crack”. We compare this rule with a threshold learned from 200 labelled patches, and test both on 200 new patches (simulated data).
import numpy as np
rng = np.random.default_rng(7)
def patches(n): # n stains and n cracks
stain = rng.normal(2.0, 0.8, n) # length-to-width ratio of stains
crack = rng.normal(4.0, 1.0, n) # length-to-width ratio of cracks
return np.r_[stain, crack], np.r_[np.zeros(n), np.ones(n)]
def accuracy(t, x, y):
return ((x > t) == y).mean()
x_train, y_train = patches(100)
x_test, y_test = patches(100)
RULE_T = 5.0 # expert rule: longer than 5 times its width = crack
cands = np.round(np.arange(1.0, 6.01, 0.1), 1)
learned_t = cands[np.argmax([accuracy(t, x_train, y_train) for t in cands])]
print(f"rule written by hand (t = {RULE_T}): test accuracy {accuracy(RULE_T, x_test, y_test):.2f}")
print(f"threshold learned from data (t = {learned_t}): test accuracy {accuracy(learned_t, x_test, y_test):.2f}")
rule written by hand (t = 5.0): test accuracy 0.57
threshold learned from data (t = 3.1): test accuracy 0.87
The hand-written rule is easy to explain, but its number was set without data and is too high, so it misses many cracks (test accuracy 0.57). Learning the threshold from labelled examples raises test accuracy to 0.87. This is machine learning in its simplest form: the rule has the same shape, but the number comes from data. A learned model must always be checked on data that was not used for learning, as done here with the test patches.
Framing a measurable problem
The same problem can be framed several ways: classifying whole images as cracked or not, detecting crack locations as boxes, or segmenting crack pixels. Each needs different labels and different measures. Before choosing, ask what the user will do with the result. If the result filters images for an engineer to review, missing a crack (a false negative) costs far more than a false alarm (a false positive), because a missed crack may never be seen again, while a false alarm costs only a few seconds of the engineer’s time.
When the target is rare
A detector’s sensitivity and specificity do not say “when it reports a crack, how often is there really one?” That value is the positive predictive value (PPV, or precision), and it depends on the prevalence of the target, as explained by Altman and Bland (1994) for medical tests, which follow the same principle.
Example 2 A good detector with low precision
A detector with sensitivity 0.95 and specificity 0.98 is used on 1,000 images.
SE, SP, N = 0.95, 0.98, 1000
for prevalence in (0.20, 0.05, 0.01):
tp = SE * prevalence * N
fp = (1 - SP) * (1 - prevalence) * N
ppv = tp / (tp + fp)
print(f"crack in {prevalence:4.0%} of images: {tp:5.1f} true alarms, {fp:4.1f} false alarms, precision {ppv:.2f}")
crack in 20% of images: 190.0 true alarms, 16.0 false alarms, precision 0.92
crack in 5% of images: 47.5 true alarms, 19.0 false alarms, precision 0.71
crack in 1% of images: 9.5 true alarms, 19.8 false alarms, precision 0.32
The same detector has high precision when cracks are common, but when cracks appear in only 1% of images, most alerts are false. Accuracy figures advertised by vendors must be questioned for the prevalence of the dataset they were measured on, and evaluated at the prevalence of the real job.
Choosing a threshold from costs
Most detectors output a confidence score, and we choose the threshold. A low threshold catches every crack but raises many false alarms; a high one raises few false alarms but misses more. The best threshold depends on the cost of each error, not the program’s default of 0.5.
Example 3 The threshold with the lowest total cost
A validation set of 1,000 images contains 60 with cracks. The team judges that missing one crack costs as much as reviewing 50 false-alarm images (simulated scores).
import numpy as np
rng = np.random.default_rng(11)
pos = rng.normal(0.72, 0.12, 60).clip(0, 1) # scores of images with cracks
neg = rng.normal(0.35, 0.15, 940).clip(0, 1) # scores of normal images
C_FN, C_FP = 50, 1
for t in (0.3, 0.4, 0.5, 0.6, 0.7):
fn, fp = int((pos < t).sum()), int((neg >= t).sum())
tp = len(pos) - fn
cost = C_FN * fn + C_FP * fp
print(f"threshold {t}: missed {fn:>2}, false alarms {fp:>3}, recall {tp / len(pos):.2f}, "
f"precision {tp / max(tp + fp, 1):.2f}, cost {cost}")
threshold 0.3: missed 0, false alarms 607, recall 1.00, precision 0.09, cost 607
threshold 0.4: missed 0, false alarms 363, recall 1.00, precision 0.14, cost 363
threshold 0.5: missed 2, false alarms 155, recall 0.97, precision 0.27, cost 255
threshold 0.6: missed 9, false alarms 45, recall 0.85, precision 0.53, cost 495
threshold 0.7: missed 26, false alarms 11, recall 0.57, precision 0.76, cost 1311
A threshold of 0.5 gives the lowest total cost of the values tried, even though precision is low, because missing a crack is so much more expensive. If the cost ratio changes, so does the best threshold. The team must agree the costs with the user first and then choose the threshold on the validation set, not the test set.
AI supports decisions; it does not make them
In structural inspection, AI fits best as a screening tool that reduces the number of images people must review. Deciding whether a structure is safe remains the job of a qualified engineer. A good system shows its confidence, marks locations in the image for checking, and records the model version used, so that questions can be traced back.
Module lab
Lab: framing an AI problem for a real job
- Choose one inspection job and write what the user will do with the AI’s results
- Choose a problem type (classification, detection or segmentation) with reasons
- Estimate the prevalence of the target in the real job and compute the expected precision with Example 2
- Agree the cost ratio of misses to false alarms with the user and choose a threshold with Example 3
- Write the scope of what the AI may decide and what people must check
Common mistakes
Watch out
- Using machine learning where a clear rule would do, or a hand-written rule for a pattern nobody can write down
- Collecting data before deciding what the results are for
- Using accuracy on imbalanced data, which looks better than it is
- Trusting precision from a dataset whose prevalence differs from the real job
- Using the default threshold of 0.5 without considering costs
- Letting AI decide safety in place of experts
Summary
- AI is a family of approaches (rules, search, probabilistic reasoning, machine learning); machine learning learns the rule from labelled examples
- Frame the problem from what the user will do with the result, and state the cost of each type of error
- Precision depends on prevalence; a good detector can raise mostly false alarms when the target is rare
- Choose the threshold that minimises total cost, on the validation set
- AI is a screening tool and assistant; the final decision belongs to experts
Check your understanding
- With sensitivity 0.9, specificity 0.95 and prevalence 10%, what is the precision?
- Why can accuracy mislead on imbalanced data?
- Give one drone example of a rule-based system and one of a machine-learning system
- If misses are far more expensive than false alarms, which way should the threshold move?
- Why choose the threshold on the validation set rather than the test set?
Answers
- If cracks appear in 1% of images, a model that always answers “no crack” scores 99% accuracy
- Rule-based: return to launch when the battery reaches the reserve, or a geofence. Machine learning: a crack detector trained on labelled images
- Lower, to catch more
- The test set must be kept for the final evaluation; using it to choose values makes the result look better than it is
Key formulas
| Positive predictive value (precision) from prevalence | |
| Total cost at threshold t |
Key references
- Géron, A. (2022). Hands-on machine learning with Scikit-Learn, Keras, and TensorFlow (3rd ed.). O'Reilly.
- Prince, S. J. D. (2023). Understanding deep learning. MIT Press. link
- Altman, D. G., & Bland, J. M. (1994). Diagnostic tests 2: Predictive values. BMJ, 309(6947), 102. link
- Russell, S., & Norvig, P. (2021). Artificial intelligence: A modern approach (4th ed.). Pearson. link
- Sutton, R. S., & Barto, A. G. (2018). Reinforcement learning: An introduction (2nd ed.). MIT Press. link
- European Union Aviation Safety Agency. (2024). EASA artificial intelligence concept paper issue 2: Guidance for Level 1 & 2 machine learning applications. link
- European Union Aviation Safety Agency. (2026). EASA artificial intelligence concept paper proposed issue 3 [Consultation draft]. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
In class / field
Lecture, case discussion and in-class problem solving
Learning evidence: Quiz results and submitted exercises