Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Industrial applications of AI

Industrial applications of AI cover using machine learning, computer vision, planning and optimization to improve manufacturing quality, predictive maintenance, supply-chain and robotics, with decision rules and cost-based thresholds derived from Bayesian reasoning.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

AI is widely used in industry to reduce costs, improve product quality, and increase uptime. Engineers apply AI for predictive maintenance, automated visual inspection, demand forecasting, and process optimization to make data-driven decisions in manufacturing, energy, logistics and more.

Key ideas

Define terms first, then give exact statements and derivations.

  • Artificial intelligence (AI): a field of computer science and engineering that builds systems that perform tasks that normally require human intelligence (perception, prediction, decision). I will use this phrase without re-teaching other topics in the syllabus.

  • Predictive maintenance: a maintenance strategy that uses sensor data and models to estimate the probability a machine will fail in a future time window and schedule maintenance before a costly failure. Predictive maintenance aims to minimize total cost = inspection/maintenance cost + failure cost.

  • Anomaly detection: the task of identifying data points or events that deviate from normal behaviour. Anomalies often represent faults, defects, or unusual system states.

  • Quality control (automated visual inspection): using sensors (usually cameras) and ML models to detect defects in manufactured items. A common pipeline: image capture → preprocessing → model inference (e.g., CNN) → decision threshold → accept/reject.

  • Demand forecasting: predicting future product demand from historical sales and external features (price, season, promotions). Typical models: ARIMA, exponential smoothing, or ML models (random forest, neural nets).

  • Optimization in supply chains: using models (linear programming, integer programming, reinforcement learning) to minimize cost function subject to constraints (capacity, lead times). Exact statement: an optimization model is min f(x) subject to g_i(x) ≤ 0 and h_j(x) = 0, where x are decision variables.

Bayesian decision and threshold derivation (commonly asked in exams):

Problem: decide whether to replace a component now (action R) or not replace (action N) based on sensor vector x. Let y=1 mean failure would occur in the next interval if we do nothing; y=0 means no failure. Let P = P(y=1 | x).

Costs:

  • C_r = cost of replacing now (including scheduled downtime), paid if we take action R regardless of y.
  • C_f = cost of an unexpected failure (repairs, lost production), paid only if we take action N and y=1.

Expected costs:

  • Cost(R) = C_r.
  • Cost(N) = P · C_f.

Decision rule: choose action with smaller expected cost. So choose R if C_r ≤ P·C_f => P ≥ C_r / C_f.

This is an exact, exam-style derivation that follows from the definition of expected cost and Bayes posterior P(y=1|x). The assumption is that replacement always eliminates the failure cost (i.e., replacement prevents the pending failure) and costs are known.

Bayes rule (definition used above):

  • Bayes' theorem: For events A and B with P(B) > 0, P(A|B) = P(B|A)P(A) / P(B). When A is a class label and B is observed data x, this gives posterior probability used in many diagnostic decisions.

Confusion-matrix definitions (for classification/inspection):

  • True positive (TP): model predicts defect and item is defective.
  • False positive (FP): model predicts defect but item is good (false alarm).
  • False negative (FN): model predicts good but item is defective (miss).
  • True negative (TN): model predicts good and item is good.

Exact metrics:

  • Precision = TP / (TP + FP). It is the probability an item flagged defective is truly defective.
  • Recall (True Positive Rate, TPR) = TP / (TP + FN). It is the probability we detect a real defect.
  • False Positive Rate (FPR) = FP / (FP + TN).
  • Specificity (True Negative Rate, TNR) = TN / (TN + FP).
  • False Negative Rate (FNR) = FN / (FN + TP).
  • Accuracy = (TP + TN) / (TP + FP + FN + TN).
  • F1 score = 2 · (precision · recall) / (precision + recall).

Receiver Operating Characteristic (ROC) curve (diagram instructions):

  • Draw a 2D plot with x-axis labelled "False Positive Rate (FPR)" from 0 to 1 and y-axis labelled "True Positive Rate (TPR)" from 0 to 1. Plot a curve obtained by sweeping the decision threshold; label the diagonal line y = x as the random classifier baseline. Mark the chosen operating point and annotate its (FPR, TPR). Also report Area Under the ROC Curve (AUC) as a threshold-independent summary; when the positive class is rare or costs emphasize positives, also plot the Precision–Recall (PR) curve and consider Average Precision (AP).

Assumptions to state in exam answers:

  • Sensor data are representative of operational conditions (no severe concept drift).
  • Costs and probabilities are stationary within the decision window when applying the threshold formula.
  • Models are evaluated on held-out data reflecting the production distribution.

Formulas

P(A|B) = P(B|A) * P(A) / P(B) — Bayes' theorem. P(A|B) is posterior probability of A given B, dimensionless. Applies when P(B) > 0.

ExpectedCost(R) = C_r — replacing cost. C_r in currency units (e.g., INR). Applies when replacement cost is fixed.

ExpectedCost(N) = P(y=1|x) * C_f — expected cost of not replacing. C_f in currency units. Applies when failure cost applies only if failure occurs.

Decision: replace iff P(y=1|x) >= C_r / C_f — replacement threshold. Dimensionless ratio. Applies under assumptions above.

Precision = TP / (TP + FP) — unitless fraction. Use when TP+FP > 0.

Recall = TP / (TP + FN) — unitless fraction. Use when TP+FN > 0.

F1 = 2 * Precision * Recall / (Precision + Recall) — harmonic mean of precision and recall.

F = m * a — (example physical formula if used in robotics) F is force (N), m mass (kg), a acceleration (m/s^2). Include only if discussing actuators or dynamics.

Worked examples

Example 1 — Predictive maintenance decision (numerical): Given: predicted probability of failure for a machine based on sensor x is P = 0.12. Cost of scheduled replacement C_r = ₹20,000. Cost of unexpected failure C_f = ₹200,000. Decide whether to replace now.

Step 1: Compute threshold = C_r / C_f = 20,000 / 200,000 = 0.1. Step 2: Compare P to threshold: P = 0.12 ≥ 0.1. Step 3: Since P ≥ threshold, replace now.

Final answer: Replace now. (This decision minimizes expected cost: ExpectedCost(R)=20,000; ExpectedCost(N)=0.12×200,000=24,000.)

Example 2 — Python program: compute confusion-matrix metrics for an inspection model.

Program (save as metrics.py):

# metrics.py - compute precision, recall, F1 from counts
def metrics(tp, fp, fn, tn):
    precision = tp / (tp + fp) if (tp + fp) > 0 else 0.0
    recall = tp / (tp + fn) if (tp + fn) > 0 else 0.0
    f1 = (2 * precision * recall / (precision + recall)) if (precision + recall) > 0 else 0.0
    return precision, recall, f1

if __name__ == '__main__':
    # sample input: counts
    tp, fp, fn, tn = 80, 20, 10, 890
    p, r, f1 = metrics(tp, fp, fn, tn)
    print(f'Precision: {p:.3f}')
    print(f'Recall: {r:.3f}')
    print(f'F1: {f1:.3f}')

Sample input: (Counts are in the code.) Exact output when run:

Precision: 0.800 Recall: 0.889 F1: 0.842

(Explanation: Precision = 80/(80+20)=0.8; Recall = 80/(80+10)=0.888888... → 0.889; F1 computed accordingly.)

Example 3 — short model-answer (theory): Describe steps to deploy an automated visual inspection system in a factory. Model answer (exam style):

  1. Define defect classes and acceptance criteria (specs). 2. Select sensors and lighting to maximize defect visibility and reduce noise. 3. Collect labeled dataset representing production variability. 4. Preprocess images (resize, normalize, augment). 5. Train model (e.g., CNN) with cross-validation; use precision/recall depending on whether misses or false alarms cost more. 6. Choose decision threshold by minimizing expected cost or by ROC analysis. 7. Validate on production-like holdout; measure TP, FP, FN, TN and compute metrics. 8. Deploy at edge or server, add monitoring for concept drift and periodic retraining. 9. Implement fail-safe actions and human-in-loop for uncertain cases. 10. Monitor ROI and update model or process as needed.

A full-marks answer lists these steps and explains cost trade-offs and evaluation metrics.

Common mistakes

  • Mixing up precision and recall definitions.
  • Using the wrong threshold formula (confusing C_r/C_f with C_f/C_r).
  • Not carrying units/currency through in cost numericals.
  • Drawing ROC axes swapped or unlabeled in diagrams.
  • For Python code: integer division errors (use floats) or not handling division-by-zero when TP+FP = 0.

For your exam

  • Short notes: explain a pipeline for visual inspection or predictive maintenance; include sensors, model choice, metrics, and deployment issues. Full answer lists steps and trade-offs.
  • Derivations: derive the replacement decision threshold from expected cost using Bayes posterior. Full marks require showing expected cost expressions and the inequality leading to P ≥ C_r/C_f and stating assumptions.
  • Numericals: compute decision using given P, C_r, C_f or compute precision/recall from confusion counts; show formulas, substitute numbers with units/currency, and final decision or metrics. Full marks show all steps and units.
  • Programs: small Python programs computing metrics or expected costs. Full marks include correct code, sample input and exact output.
  • Diagrams: ROC curve or inspection pipeline block diagram. Full marks include axes labels, baseline, and annotated operating point.

Quick check

  1. Define predictive maintenance in one sentence.
  2. Give the formula for precision using confusion-matrix symbols.
  3. If C_r = 15,000 and C_f = 150,000, what is the replacement threshold value (number)?

Answers: 1) Predictive maintenance is a data-driven strategy that schedules maintenance when models estimate a high probability of future failure. 2) Precision = TP / (TP + FP). 3) Threshold = 15,000 / 150,000 = 0.1.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?