CSS Prepare

Artificial Intelligence and Machine Learning

10 min read

Artificial Intelligence (AI) is the branch of computer science dedicated to building systems that perform tasks ordinarily requiring human intelligence — perception, reasoning, learning, planning, language understanding. Machine Learning (ML) is the subfield in which systems learn patterns from data without being explicitly programmed.

Artificial Intelligence

The capability of a machine to imitate intelligent human behaviour. AI systems acquire knowledge, reason with it, and act in their environment — encompassing perception, learning, problem-solving and language.

Brief history

YearMilestone
1950Alan Turing's paper "Computing Machinery and Intelligence" proposes the Turing Test
1956Dartmouth Conference — birth of the field; McCarthy coins "Artificial Intelligence"
1965-70ELIZA chatbot; early expert systems
1980sExpert systems boom (MYCIN, DENDRAL)
Late 1980s"AI winter" — funding collapses
1997Deep Blue defeats Garry Kasparov at chess
2011IBM Watson wins Jeopardy!
2012AlexNet — deep learning revolution in image classification
2016AlphaGo defeats Lee Sedol
2017Transformer architecture introduced ("Attention Is All You Need")
2020-25LLMs (GPT, Claude, Gemini) revolutionise NLP

Branches of AI

  • Search and problem-solving — uninformed (BFS, DFS) and informed (A*, greedy) search.
  • Knowledge representation and reasoning — logic, semantic networks, frames, ontologies.
  • Machine learning — supervised, unsupervised, reinforcement.
  • Natural Language Processing (NLP).
  • Computer Vision.
  • Robotics.
  • Expert systems — rule-based domain reasoning.

Search algorithms

Uninformed

  • BFS — complete, optimal for uniform cost; O(b^d) time and space.
  • DFS — low memory; not optimal.
  • Iterative Deepening DFS — combines BFS's optimality with DFS's memory profile.

Informed (heuristic)

  • Greedy best-first — uses h(n); not optimal.
  • A* — uses f(n) = g(n) + h(n); optimal if h(n) is admissible (never overestimates).

Adversarial

  • Minimax — assumes optimal opponent; backs up values from leaves.
  • Alpha-beta pruning — speeds up minimax without changing outcome.
  • Monte Carlo Tree Search (MCTS) — basis of AlphaGo.
Key Points
  • A heuristic is admissible if it never overestimates the true cost to the goal.
  • A heuristic is consistent if h(n) ≤ c(n, n') + h(n') for every edge.
  • Local search (hill climbing, simulated annealing) trades completeness for memory.
  • Genetic algorithms apply evolutionary principles to optimisation problems.

Machine learning paradigms

Supervised learning

Learn from labelled (input, output) pairs. Goal: predict outputs for new inputs.

  • Classification — discrete labels (spam vs. not spam).
  • Regression — continuous outputs (predicting house prices).

Common algorithms: linear/logistic regression, k-Nearest Neighbours, decision trees, random forests, gradient boosting (XGBoost, LightGBM), Support Vector Machines, neural networks.

Unsupervised learning

No labels; find structure.

  • Clustering — k-means, hierarchical, DBSCAN.
  • Dimensionality reduction — PCA, t-SNE, UMAP.
  • Association rules — Apriori (market-basket analysis).

Reinforcement learning

Agent interacts with environment, learns policy maximising cumulative reward.

  • Markov Decision Process formalism: states, actions, rewards, transition probabilities.
  • Q-learning, SARSA, Policy gradients, Actor-critic methods.
  • Deep RL combines neural nets with RL (DQN, PPO, A3C).
  • Applications: game AI, robotics, recommendation systems.

Semi-supervised, self-supervised, transfer learning

These approaches exploit large unlabelled corpora (text from the web) to pre-train powerful models, then fine-tune on small labelled datasets — the basis of modern LLMs.

Model evaluation

Classification metrics

  • Accuracy = correct / total.
  • Precision = TP / (TP + FP).
  • Recall (sensitivity) = TP / (TP + FN).
  • F1 score = harmonic mean of precision and recall.
  • ROC curve and AUC.
  • Confusion matrix.

Regression metrics

  • Mean Absolute Error (MAE).
  • Mean Squared Error (MSE).
  • Root Mean Squared Error (RMSE).
  • (coefficient of determination).

Train-test split, cross-validation, regularisation (L1 LASSO, L2 ridge), early stopping — all techniques to combat overfitting.

Deep learning

Deep neural networks have many hidden layers; trained via backpropagation and gradient descent variants (SGD, Adam, RMSProp).

Architectures

  • Multilayer Perceptron (MLP) — fully connected.
  • Convolutional Neural Networks (CNN) — image and grid data; LeNet, AlexNet, VGG, ResNet.
  • Recurrent Neural Networks (RNN) — sequences; LSTM, GRU handle long dependencies.
  • Transformers — self-attention; basis of BERT, GPT, T5, LLaMA.
  • Autoencoders — unsupervised representation learning.
  • Generative Adversarial Networks (GANs) — generator vs. discriminator.
  • Diffusion models — image and video generation (Stable Diffusion, DALL-E, Sora).

Natural Language Processing

Tasks:

  • Tokenisation, POS tagging, parsing.
  • Named Entity Recognition (NER).
  • Sentiment analysis.
  • Machine translation — neural sequence-to-sequence with attention.
  • Question answering.
  • Summarisation.
  • Speech recognition / synthesis.

Pakistani relevance: NLP for Urdu, Punjabi, Pashto, Sindhi, Balochi remains under-resourced — a research frontier.

Computer vision

  • Image classification, object detection (YOLO, Faster R-CNN), segmentation (U-Net, Mask R-CNN), image generation, face recognition.
  • Pakistan's Safe City projects in Lahore, Islamabad and other cities deploy CCTV with face/plate recognition.

Generative AI and LLMs

Large Language Models (LLMs) trained on internet-scale text exhibit few-shot reasoning, code generation and dialogue. Examples: GPT-4/5 (OpenAI), Claude (Anthropic), Gemini (Google DeepMind), LLaMA (Meta), Mistral.

Concepts:

  • Pre-training on massive unlabelled corpora.
  • Fine-tuning for specific tasks.
  • RLHF (Reinforcement Learning from Human Feedback) for alignment.
  • Prompt engineering, Retrieval-Augmented Generation (RAG).

AI ethics and risks

Concerns include:

  • Bias and fairness — models reflect biases in training data.
  • Privacy — training data may leak personal info.
  • Hallucinations in LLMs.
  • Job displacement.
  • Autonomous weapons.
  • Misinformation and deepfakes.
  • Concentration of compute in a few firms.
  • AGI safety — long-term existential debates.

Regulatory frameworks: EU AI Act (2024) is the world's first comprehensive AI law, classifying systems by risk. Pakistan's National AI Policy (draft, 2023-24) envisions sectoral guidelines and capacity building.

A common CSS conceptual trap is confusing AI, ML and deep learning. Remember the nested relationship: AI ⊃ ML ⊃ Deep Learning ⊃ Generative AI / LLMs. Not all AI uses ML (rule-based expert systems don't); not all ML is deep learning.

Pakistan and AI

  • Government's Centre for Artificial Intelligence and Computing (CENTAIC) at PAF.
  • National Centre of AI with university partners (UET, NUST, ITU, Bahria, FAST).
  • Universities offering BS/MS AI programmes are growing.
  • Applications under development: precision agriculture, e-health diagnostics, fraud detection in banking, traffic management, electoral roll analytics at NADRA.

A CSS officer who can distinguish hype from substance and understand the data, computational and ethical demands of AI is well-placed to engage with the rapidly evolving policy frontier.

Artificial Intelligence and Machine Learning — Computer Science CSS Notes · CSS Prepare