Introduction to Computer Science

Chapter 14
Artificial Intelligence, Machine Learning, and Intelligent Systems

Bachelors Program in Computer Science Engineering
Introduction to Computer Science   •   Post Graduate

Artificial Intelligence, Machine Learning, and Intelligent Systems

Introduction and Context

Artificial intelligence (AI) is the study and engineering of computational systems that perceive their environment, represent knowledge, reason, learn, communicate, and act to achieve specified goals. Machine learning (ML) is a major approach to AI in which a system improves its performance by inferring patterns from data or experience rather than relying exclusively on hand-written rules. An intelligent system combines algorithms, data, computational resources, interfaces, and governance mechanisms to produce useful and accountable decisions or actions.

The distinction is important. A calculator can perform sophisticated arithmetic without being an intelligent system in the broader sense. Conversely, a spam filter may use statistical learning to classify messages, but its practical intelligence depends also on data pipelines, feedback, security, evaluation, and human oversight. At postgraduate level, AI should therefore be understood not merely as a collection of algorithms, but as a systems discipline involving computation, uncertainty, cognition, engineering, and social responsibility.

Learning Objectives

After completing this chapter, a learner should be able to:

  1. distinguish AI, ML, deep learning, data mining, and intelligent systems;
  2. explain major AI paradigms and formulate problems as search, inference, or learning tasks;
  3. describe supervised, unsupervised, semi-supervised, self-supervised, and reinforcement learning;
  4. derive and interpret basic classification, regression, optimization, and evaluation equations;
  5. design an end-to-end intelligent-system pipeline and identify sources of failure;
  6. assess reliability, fairness, privacy, explainability, safety, and governance requirements; and
  7. evaluate an applied AI solution using technical and organizational criteria.

1. Foundations and Historical Perspectives

Early AI research emphasized symbolic representation, logic, search, and explicit knowledge. A symbolic agent represents facts and rules, then applies inference procedures. For example, the rule “if a component is overheated, inspect its cooling system” can be useful when the relevant facts are observable and the rules are stable. Expert systems demonstrated the value of this approach, but they also revealed the knowledge-acquisition bottleneck: encoding and maintaining comprehensive expert knowledge is difficult.

The statistical learning tradition instead treats intelligence as estimation from observations. A model is fitted to examples and evaluated on previously unseen cases. Modern systems often combine both traditions: a neural model may recognize an object, while a symbolic planner schedules actions subject to safety constraints.

Important historical shifts include:

  • 1950s–1960s: formal problem solving, game playing, theorem proving, and the study of machine intelligence;
  • 1970s–1980s: knowledge-based systems, logic programming, and planning;
  • 1990s–2000s: probabilistic reasoning, support-vector methods, data mining, and large-scale statistical learning;
  • 2010s onward: deep learning enabled by large datasets, specialized hardware, and improved optimization;
  • Current direction: foundation models, multimodal systems, AI agents, edge intelligence, and human–AI collaboration.

The history also includes periods of reduced funding known as AI winters. These demonstrate that impressive demonstrations do not guarantee robust general performance, economic value, or scientific progress.

2. Core Concepts and Terminology

Agent. An agent perceives observations, maintains an internal state or model, selects actions, and receives outcomes. A rational agent chooses actions expected to maximize a performance measure, given its information and constraints. Rationality is not omniscience: an agent may make a reasonable decision under uncertainty and still receive an unfavorable outcome.

Environment. The environment supplies observations and responds to actions. It may be fully or partially observable, deterministic or stochastic, static or dynamic, discrete or continuous, and single-agent or multi-agent.

State, action, and policy. A state describes relevant conditions; an action is an available intervention; and a policy maps states or histories to actions. In a deterministic setting, a transition model can be written as st+1 = T(st, at), where st is the current state, at is the action, and T is the transition function.

Knowledge representation. Knowledge may be represented using logical sentences, ontologies, semantic networks, graphs, probability distributions, vectors, or learned parameters. Representation determines what can be inferred efficiently and what kinds of uncertainty can be expressed.

Model. A model is a parameterized or rule-based approximation of a phenomenon, task, or decision process. Parameters are adjusted during training; hyperparameters, such as learning rate or tree depth, are selected by the practitioner and are not normally learned directly from the training objective.

Generalization. Generalization is performance on new data drawn from a relevant target distribution. Memorizing training examples is not equivalent to learning a useful general pattern.

3. Problem Formulations in AI

3.1 Search and Planning

Many tasks can be represented by an initial state, actions, a transition model, a goal test, and a path-cost function. Breadth-first search is complete for finite branching spaces and returns a shortest path when all step costs are equal. Depth-first search uses less memory but is not generally optimal and may fail to terminate in infinite spaces.

In informed search, a heuristic h(n) estimates the remaining cost from node n. A* evaluates

f(n) = g(n) + h(n)

where g(n) is the cost from the start to n. If h(n) is admissible—never overestimating the true remaining cost—and appropriate consistency conditions hold for graph search, A* is optimal. The quality of the heuristic affects efficiency, not the definition of the problem itself.

Planning extends search by reasoning about action preconditions, effects, resources, time, and uncertainty. In real systems, planning is often interleaved with perception and execution because the world may change while a plan is being carried out.

3.2 Logic and Probabilistic Inference

Classical logic provides exact entailment when facts and rules are adequately specified. Real environments, however, contain noise, missing information, and conflicting evidence. Probability provides a language for uncertainty. Bayes’ theorem is

P(H | E) = [P(E | H)P(H)] / P(E)

where H is a hypothesis, E is evidence, P(H) is the prior probability, P(E | H) is the likelihood, and P(H | E) is the posterior probability. The denominator is positive and can be expanded as the total probability of the evidence. Bayesian inference is applicable when probabilities meaningfully represent uncertainty and the conditional relationships have been specified or estimated.

A probabilistic model is not automatically causal. Correlation can support prediction without justifying an intervention. Causal reasoning requires assumptions about mechanisms, confounding, and the data-generating process.

4. Machine Learning Paradigms

4.1 Supervised Learning

In supervised learning, a dataset contains input–target pairs D = {(xi, yi)}i=1n. A model f_θ with parameters θ is trained by minimizing empirical risk:

J(θ) = (1/n)∑i=1n L(f_θ(xi), yi) + λΩ(θ)

Here L is a loss function, Ω(θ) is a regularization penalty, λ ≥ 0 controls its strength, and n is the number of training examples. The objective assumes that examples are suitably represented and that the training loss is a useful proxy for the desired operational performance.

For binary classification, logistic regression models

p(y=1 | x) = σ(wᵀx + b), σ(z) = 1/(1 + e^(−z))

where x is the feature vector, w is the weight vector, b is an intercept, and σ maps scores to values between 0 and 1. A threshold converts probability into a class, but the threshold should reflect the relative costs of false positives and false negatives.

For numerical prediction, mean squared error is

MSE = (1/n)∑i=1n(ŷi − yi)2

where ŷi is the prediction and yi is the observed value. MSE has squared units of the target variable; its square root, RMSE, has the same units as the target.

4.2 Unsupervised and Representation Learning

Unsupervised learning seeks structure without supplied target labels. In k-means clustering, observations are assigned to one of k clusters and centroids are updated to minimize within-cluster squared Euclidean distance:

J = ∑j=1k ∑xi∈Cj ||xi − μj||²

Here Cj is cluster j and μj is its centroid. The algorithm can converge to a local optimum, depends on initialization, and requires a meaningful distance measure and a selected value of k. Clusters are not automatically real natural categories.

Dimensionality-reduction methods learn compact representations. Principal component analysis (PCA), under centered data and an orthogonal linear representation, chooses directions of maximum variance. It can aid visualization and compression, but high variance is not necessarily high predictive or causal relevance.

Self-supervised learning creates learning signals from the data itself, such as predicting a masked token or a future observation. It is particularly important for large language and multimodal models.

4.3 Reinforcement Learning

In reinforcement learning, an agent interacts with an environment and receives rewards. A discounted return is

Gt = ∑k=0∞ γk Rt+k+1, 0 ≤ γ < 1

where Rt+k+1 is a future reward and γ is the discount factor. The infinite sum is well-defined for bounded rewards when 0 ≤ γ < 1. The agent seeks a policy maximizing expected return. Exploration is necessary to discover actions, while exploitation uses current knowledge. Poorly designed rewards can produce reward hacking: behavior that maximizes the measured objective while violating the intended goal.

5. Deep Learning and Foundation Models

A neural network composes parameterized functions, commonly affine transformations followed by nonlinear activations. In a feed-forward layer, h = φ(Wx + b), where W is a weight matrix, b a bias vector, and φ an activation function applied componentwise. Training commonly uses gradient-based optimization. For learning rate η, a basic update is

θt+1 = θt − η∇_θ J(θt)

This update assumes a differentiable or suitably approximated objective and a gradient that provides useful local information. It does not guarantee a global optimum for non-convex neural-network objectives.

Deep learning uses many layers to learn hierarchical representations. Convolutional networks are effective for spatial data; recurrent and attention-based architectures process sequences. Transformer models use attention to relate elements of a sequence. A simplified scaled dot-product attention expression is

Attention(Q,K,V) = softmax(QKᵀ / √dk)V

where Q, K, and V are query, key, and value matrices, and dk is the key-vector dimension. This is a computational mechanism, not a guarantee of human-like understanding.

Foundation models are trained on broad data and adapted through prompting, fine-tuning, retrieval, or tool use. Their capabilities can be general, but their outputs remain sensitive to training data, context, evaluation design, and deployment controls. Generative models may produce fluent but false statements, often called hallucinations. Retrieval-augmented generation can improve access to current or domain-specific information, but retrieval quality, source authority, prompt injection, and citation verification remain necessary concerns.

6. Evaluation and the End-to-End Lifecycle

A reliable system is developed through problem definition, data acquisition, labeling, preprocessing, model development, validation, deployment, monitoring, and retirement. Data must be split by time, entity, or other dependence structure when random splitting would leak information. A test set should remain untouched until final evaluation.

For binary classification, with true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN):

Accuracy = (TP + TN)/(TP + TN + FP + FN)
Precision = TP/(TP + FP), Recall = TP/(TP + FN)

Precision measures the proportion of predicted positives that are correct; recall measures the proportion of actual positives detected. Accuracy can be misleading under class imbalance. The F1 score is

F1 = 2(Precision × Recall)/(Precision + Recall)

when both precision and recall are defined and nonzero. Receiver operating characteristic and precision–recall curves assess performance across thresholds. Metrics must be connected to operational costs, not selected only because they produce attractive numbers.

Regression requires residual analysis, calibration where probabilistic forecasts are used, and examination of performance across subgroups and relevant operating conditions. Post-deployment monitoring should detect data drift, concept drift, latency degradation, abnormal inputs, and changes in user behavior.

7. Intelligent-System Architecture

A production architecture commonly contains:

  1. Sensing and interfaces: sensors, documents, speech, APIs, or user inputs;
  2. Data and feature layer: collection, validation, lineage, storage, and transformation;
  3. Inference layer: rules, predictive models, retrieval, planning, or optimization;
  4. Action layer: recommendations, automated decisions, or physical control;
  5. Feedback and governance: logging, human review, monitoring, incident response, and model updates.

Security must be considered throughout. Threats include data poisoning, adversarial inputs, model extraction, privacy leakage, prompt injection, insecure tool use, and unauthorized automation. Defense in depth includes access control, encryption, input validation, rate limits, provenance records, red-teaming, rollback procedures, and least-privilege tool permissions.

8. Ethics, Governance, and Professional Responsibility

AI systems can amplify existing discrimination when labels, sampling, features, or decisions reflect historical inequity. Fairness has multiple, sometimes incompatible, definitions. For example, demographic parity compares positive decision rates across groups, whereas equal opportunity compares true-positive rates. Neither definition alone establishes justice; domain context and affected-community participation matter.

Privacy protection requires purpose limitation, data minimization, retention controls, access governance, and legally appropriate processing. De-identification reduces risk but does not guarantee anonymity. Sensitive applications require documentation of data provenance, intended use, limitations, known failure modes, and human escalation paths.

Explainability should match the decision and audience. A global feature-importance summary does not necessarily explain an individual prediction. Explanations should be faithful to the model, understandable to the recipient, and not used as a substitute for validation. High-impact systems require accountability: a named owner, auditability, contestability, and a process for correcting errors.

Professional practice should follow risk-based governance. A low-risk recommendation tool may need monitoring and disclosure; a medical, employment, credit, or safety-critical system requires stronger validation, qualified oversight, security controls, and compliance with applicable law and sector standards. Autonomous capability should never exceed the organization’s ability to supervise and recover.

9. Illustrative Case: Predictive Maintenance in a Manufacturing Plant

Background. A plant operates motors whose failure interrupts production. Engineers have vibration, temperature, current, and maintenance-history data.

Problem. The plant wants to predict failures seven days in advance. A false alarm costs an inspection; a missed failure costs downtime and possible safety risk.

Analysis. The team first defines the prediction time and failure window, then constructs labels without using measurements collected after the prediction time. Random row-level splitting would leak information because many records belong to the same motor and operating episode. A time- and asset-aware split is therefore used. Class imbalance is expected because failures are rare.

Approach. Engineers establish a rule-based baseline based on temperature limits. A gradient-boosted classifier is then trained with time-window features. The decision threshold is selected using estimated costs rather than defaulting to 0.5. Evaluation includes recall at a fixed inspection capacity, precision, lead time, calibration, and subgroup or asset-family performance. Alerts are shown to maintenance staff with sensor trends and an override mechanism.

Outcome. In an illustrative deployment, the model identifies most high-risk events but produces too many alerts during a seasonal operating change. Monitoring detects the shift; the team investigates sensor calibration and updates the model only after controlled validation. The system remains advisory rather than fully autonomous.

Learning points. The principal engineering work is not merely fitting a model. It includes label design, leakage prevention, cost-sensitive evaluation, human workflow integration, drift monitoring, and safe recovery. A technically accurate model can still fail if alerts are not actionable or if operational incentives encourage users to ignore them.

10. Contemporary Directions and Best Practices

Current research addresses multimodal foundation models, efficient and federated learning, synthetic data, causal and neuro-symbolic AI, continual learning, embodied agents, privacy-preserving computation, and evaluation of robustness and alignment. These directions introduce opportunities but also unresolved questions concerning compute concentration, copyright, environmental cost, emergent behavior, and dependable autonomy.

Best practices include:

  • define the decision, affected stakeholders, and success criteria before selecting a model;
  • establish a simple baseline and compare against it;
  • maintain data and model lineage, versioning, reproducible experiments, and audit logs;
  • separate development, validation, and final testing;
  • evaluate worst-case and subgroup behavior, not only average performance;
  • use human oversight proportional to risk and provide meaningful appeal mechanisms;
  • test security, privacy, robustness, and failure recovery before deployment;
  • monitor real-world performance and establish explicit retirement criteria; and
  • communicate uncertainty instead of presenting probabilistic outputs as facts.

Chapter Summary

AI concerns computational agents that perceive, reason, learn, and act. ML learns patterns from data, while intelligent systems integrate models with data, interfaces, actions, monitoring, and governance. Search and planning formalize goal-directed behavior; logic and probability support inference; supervised, unsupervised, self-supervised, and reinforcement learning address different sources of learning signals. Loss functions, regularization, gradient optimization, classification metrics, and discounted returns provide essential analytical tools. Deep learning and foundation models expand representational capacity but do not eliminate uncertainty, bias, security risk, or the need for evaluation. Effective professional practice is lifecycle-oriented: define the problem, prevent leakage, evaluate against operational costs, monitor drift, protect privacy, document limitations, and retain accountable human control.

Key Terms

Agent: A system that perceives conditions and selects actions.

Artificial intelligence: The discipline of building systems capable of tasks associated with intelligent behavior.

Machine learning: Algorithms that infer patterns or policies from data or experience.

Intelligent system: An integrated computational system that senses, reasons, learns, and acts within a context.

State: A representation of conditions relevant to future behavior.

Policy: A mapping from states or histories to actions.

Heuristic: An estimate or rule used to guide search efficiently.

Bayesian inference: Updating beliefs using prior knowledge and evidence.

Supervised learning: Learning from input–target examples.

Unsupervised learning: Discovering structure without supplied targets.

Reinforcement learning: Learning actions through rewards and interaction.

Regularization: A method that constrains model complexity to improve generalization.

Overfitting: Fitting training data so closely that performance on new data declines.

Data leakage: Unintended use of information unavailable at the intended prediction time.

Precision: The fraction of predicted positives that are true positives.

Recall: The fraction of actual positives that are detected.

Concept drift: Change in the relationship between inputs and the target over time.

Explainability: The extent to which system behavior can be meaningfully understood.

Foundation model: A broadly pretrained model adapted to multiple downstream tasks.

Reward hacking: Optimizing a measured reward in a way that defeats its intended purpose.

Review Questions

5 Short Answer Questions

  1. Distinguish artificial intelligence, machine learning, and deep learning.
  2. What are the roles of g(n) and h(n) in A* search?
  3. State Bayes’ theorem and define its terms.
  4. Why can accuracy be misleading for an imbalanced classification problem?
  5. What is data leakage, and how can a temporal split reduce it?

5 Long Answer Questions

  1. Explain the architecture and lifecycle of a production intelligent system, including monitoring and governance.
  2. Compare symbolic AI, probabilistic reasoning, and neural learning in terms of representation, strengths, and limitations.
  3. Explain supervised, unsupervised, self-supervised, and reinforcement learning with appropriate applications.
  4. Discuss how regularization, validation design, and drift monitoring contribute to generalization.
  5. Analyze ethical, privacy, fairness, security, and accountability requirements for a high-impact AI system.

3 Analytical / Application Questions

  1. A fraud detector has high accuracy but misses most fraudulent transactions. Which metrics, threshold strategy, and data checks should be investigated? Justify your answer.
  2. Design a predictive-maintenance experiment that avoids temporal and asset-level leakage. Specify the split, baseline, evaluation metrics, and deployment safeguards.
  3. A language-model assistant gives fluent but unsupported answers from confidential documents. Propose a system-level remediation plan covering retrieval, access control, evaluation, user disclosure, and incident response.

Multiple Choice Questions with Answers

Question 1

Which statement best distinguishes machine learning from traditional rule-based programming?

A. Machine learning always uses neural networks.

B. Machine learning infers patterns or policies from data or experience.

C. Machine learning cannot use probability.

D. Machine learning requires no evaluation data.

Correct Answer: B. Machine learning infers patterns or policies from data or experience.

Question 2

Under the stated admissibility condition, what does h(n) represent in A* search?

A. The cost already paid to reach n

B. The number of explored nodes

C. An estimate of the remaining cost from n to a goal

D. The branching factor of n

Correct Answer: C. An estimate of the remaining cost from n to a goal

Question 3

In Bayes’ theorem, P(H | E) denotes:

A. The probability of evidence given the hypothesis

B. The prior probability of the evidence

C. The probability of the hypothesis given the evidence

D. The joint probability of unrelated events

Correct Answer: C. The probability of the hypothesis given the evidence

Question 4

A classifier produces TP = 80 and FN = 20. What is its recall?

A. 0.20

B. 0.50

C. 0.80

D. 0. Oops

Correct Answer: C. 0.80

Question 5

Which practice most directly helps prevent temporal data leakage?

A. Using future observations to increase training size

B. Splitting data so training precedes validation and test periods

C. Removing all validation data

D. Increasing the classification threshold

Correct Answer: B. Splitting data so training precedes validation and test periods

Question 6

What is the principal purpose of regularization in the stated empirical-risk objective?

A. To increase model complexity without constraint

B. To penalize complexity and potentially improve generalization

C. To guarantee a global optimum

D. To replace the loss function

Correct Answer: B. To penalize complexity and potentially improve generalization

Question 7

Which learning paradigm uses rewards generated through interaction with an environment?

A. Supervised learning

B. Unsupervised learning

C. Reinforcement learning

D. PCA

Correct Answer: C. Reinforcement learning

Question 8

Why may accuracy be inappropriate when positive cases are rare?

A. It cannot be calculated for binary tasks.

B. A model can obtain high accuracy while missing most positives.

C. It always equals recall.

D. It has squared target units.

Correct Answer: B. A model can obtain high accuracy while missing most positives.

Question 9

What is concept drift?

A. A change in the relationship between inputs and the target over time

B. A technique for selecting a neural activation function

C. A guarantee of fairness across groups

D. A type of encryption

Correct Answer: A. A change in the relationship between inputs and the target over time

Question 10

Which is an example of reward hacking?

A. An agent achieving the intended objective under constraints

B. An agent maximizing a measured reward through behavior that violates the intended goal

C. A model being evaluated on held-out data

D. A human reviewing an alert

Correct Answer: B. An agent maximizing a measured reward through behavior that violates the intended goal

Introduction to Computer Science
Chapter 14 of 14