2.1 Revisiting AI, ML & DL
To build an AI project, we work with AI models / algorithms. Before jumping into modelling let us clarify the three related terms:
Any technique that enables computers to mimic human intelligence. An AI machine works on algorithms and data fed to it, producing the desired output.
Enables machines to improve at tasks with experience. The machine learns from new data, takes mistakes into account, and considers exceptions in the next iteration.
Enables software to train itself using vast amounts of data. Multiple ML algorithms work together inside DL. The most advanced form of AI.
🔹 Relationship between AI, ML and DL — Funnel / Venn Model
🧠 Machine Learning (ML) — Examples
ML model is given past / historical data as input; the model learns from it and generates output.
- Object Classification — identifies and labels objects in an image (e.g., apple vs strawberry).
- Anomaly Detection — finds unexpected things in data. Example: tracking heart rate and flagging a sudden spike as a potential issue.
🕳️ Deep Learning (DL) — Examples
Input is given to an ANN; after processing, the output is generated by the DL block. The machine can develop algorithms for itself.
- Object Identification — identifies and labels objects within an image using powerful DL algorithms.
- Digit Recognition — training computers to identify handwritten digits (0-9) within images.
2.2 Common Terminologies Used with Data
2.3 Modelling — Types of AI Models
Generally, AI models are classified into two main approaches:
📘 1. Rule-Based Approach
Rule 1: If user message contains "track order", "shipment status" or "delivery" → show order-tracking options.
Rule 2: If user asks for their order number → prompt to enter it. If entered correctly → show tracking info. If invalid → show error and ask again.
Rule 3: If no defined rule matches → "Sorry, I can't help. Please try our FAQs or contact support."
📗 2. Learning-Based Approach
2.4 Categories of Machine Learning Models
Machine Learning can be further divided into three main categories:
Machine learns from labelled data — like a teacher teaching a class.
Machine finds its own patterns in unlabelled data — like a child learning to swim alone.
Machine learns by trial and error using rewards and penalties.
📗 1. Supervised Learning
Analogy: "Supervised" = having a supervisor. A maths teacher teaches using many solved examples (training), then tests the class with new problems (testing).
Problem: Predict the coin based on its weight.
Dataset: 1 Euro = 5g · 1 Dirham = 7g · 1 Dollar = 3g · 1 Rupee = 4g …
Feature = Weight · Label = Currency
The trained model can then identify a new coin just from its weight.
📘 2. Unsupervised Learning
Analogy: A child learning to swim on his own without any supervision. The child is the model; the swimming pool is the unknown data.
🔹 Supervised vs Unsupervised — Quick Comparison
| Aspect | Supervised Learning | Unsupervised Learning |
|---|---|---|
| Input Data | Labelled (tagged) | Unlabelled (raw) |
| Goal | Predict / classify using known labels | Find hidden patterns & groupings |
| Analogy | Student learning with teacher | Child discovering on its own |
| Problem Types | Classification, Regression | Clustering, Association |
| Example | Currency prediction, spam detection | Customer segmentation, Netflix recommendations |
🔹 Identify the Model — Quick Test
| Case | Answer |
|---|---|
| Social media identifies your friend in a picture from tagged photos. | Supervised — uses tagged photos as labels. |
| OTT platform recommends movies based on watch history. | Unsupervised — groups by similar features without labels. |
| Bank analyses transactions for suspicious fraud (no "fraud" labels given). | Unsupervised — identifies outliers / anomalies. |
🎮 3. Reinforcement Learning
• Show the machine an apple — it predicts "cherry". You give negative feedback: "incorrect".
• Show apple again — it knows it's not a cherry. Predicts "apple" — you give positive feedback: "correct".
• Machine has now learned: this is an apple.
🔹 When to Use Reinforcement Learning
- You face large, complex problem spaces.
- You must respond to unforeseen environments.
- You don't have sufficient labelled data for specific scenarios.
- The environment may change — the system needs to be adaptive.
🔹 Real-World RL Examples
- Parking a car automatically.
- Humanoid robot learning to walk.
- AlphaGo, chess-playing AI, self-driving cars.
- Game-playing bots that learn from wins/losses.
🔹 Summary of 3 ML Categories
| Category | Used When… |
|---|---|
| Supervised | We want to determine relationships through training. |
| Unsupervised | We want to discover new patterns from data. |
| Reinforcement | We want to implement ML through a reward mechanism. |
2.5 Sub-Categories of Supervised Learning
Supervised Learning has two sub-types based on the type of output:
Data is classified according to labels. Output is discrete / categorical (yes/no, spam/not spam, cat/dog). Example: grading students, email spam filter.
Works on continuous data. Output is a continuous value like temperature, price, income, age. Example: predicting salary, house price.
🔹 Classification — Examples
- Weather Classifier: trained on labelled "hot" or "cold" weather data — considers location, season, humidity, high/low temperature. Predicts tomorrow as hot or cold.
- Email Spam Filter: analyses clues in an email → classifies as "spam" or "not spam". Modern email also categorises into social, promotions, notifications.
🔹 Regression — Examples
- Predicting Temperature — temperature is continuous, so regression is well-suited.
- House Price Prediction: Features (independent): number of bedrooms, carpet size, garage area. Label (dependent): Price.
- Used-Car Price Prediction: predicts continuous price using fuel type, years of service, number of previous owners, kilometres driven, transmission type.
🔹 Identify Model — Classification or Regression?
| Case | Answer |
|---|---|
| Predict whether a customer is eligible for a bank loan. | Classification (yes/no — discrete) |
| Predict the weather for the next 24 hours. | Regression (continuous range) |
2.6 Sub-Categories of Unsupervised Learning
Unsupervised Learning has two sub-types:
Groups data based on similarity of characteristics. Example: grouping birds and animals without labels — cluster 1 = all animals, cluster 2 = all birds.
Finds interesting relationships between variables in the database. Example: customer who buys bread will most probably also buy butter.
• Classification uses predefined classes to assign objects (labels known).
• Clustering finds similarities between objects and places them in the same cluster, differentiating from others (labels unknown).
🔹 Clustering Example — Jim's Music
🔹 Association Example — Shop Purchases
2.7 Sub-Categories of Deep Learning
Deep Learning has two main types:
Modelled on the human brain and nervous system. Every node is essentially an ML algorithm. ANNs extract features automatically — no programmer input. Useful for very large datasets.
DL algorithm that takes an input image, assigns importance (learnable weights & biases) to various aspects, and differentiates one image from another. Used in computer vision & image recognition.
2.8 What is a Neural Network?
🔹 Architecture — Layers of a Neural Network
Acquires data and feeds it into the network. No processing occurs here.
Where the whole processing happens. Each node runs its own ML algorithm on data from the previous layer. There can be multiple hidden layers; number depends on problem complexity.
Receives processed data from the last hidden layer and delivers the final output to the user. No processing here.
🔹 How Hidden Layers Work — Weights, Biases, Activation
- Each hidden-layer node computes using weights and biases.
- Information passes through an activation function from one layer to the next.
- The network learns by trial & error — with each try, weights are adjusted based on the error between desired output and network output.
- This process of finding the right output is called training.
🔹 Real-World Applications of Neural Networks
- Face recognition (phone unlock, airport security).
- Customer-support chatbots.
- Vegetable & stock price prediction.
- Medical image analysis (MRI, X-ray).
- Handwritten digit recognition.
- Self-driving car vision.
2.9 How Does AI Make a Decision?
🔹 Step 1 — Identify Inputs (Factors)
Four inputs influence your decision:
- Do I have a jacket?
- Do I have an umbrella?
- Is it sunny now?
- What is the weather forecast for later?
🔹 Step 2 — Assign Importance (Weights)
Not all factors are equal. Rank them:
- "Is it sunny now?" → most important.
- "Weather forecast later" → very important.
- "Having a jacket" → important.
- "Having an umbrella" → least important.
🔹 Step 3 — Perceptron Model
🔹 Where Do Weight Values Come From?
- From experience — sunny now usually means a bright day ahead, so weight is high.
- From personal preference — a person may judge one factor more heavily than another.
- Bias WB — cautious person sets WB higher (stay indoors unless sure); daring person sets WB lower (go out regardless).
🔹 Example Calculation 1 — Go to Park
Calculation with sample weights: output = 0.5 → higher than threshold (0) → I WILL go to the park.
🔹 Example Calculation 2 — Stay Home
Calculation: output = −0.5 → lower than threshold (0) → I will NOT go to the park.
2.10 Activity — Human Neural Network (The Game)
Setup — 20 students arranged in 4 layers:
- Input Layer: 7 students (each writes 6 chits)
- Hidden Layer 1: 6 students (each receives 7 chits, writes 4 chits)
- Hidden Layer 2: 6 students (receives chits, writes 2 chits)
- Output Layer: 1 student (receives 12 chits, makes a final guess)
- Facilitator shows an image only to the Input Layer.
- Each input student writes 6 words describing it on 6 chits.
- Chits pass to Hidden Layer 1 → re-written as 4 new chits each.
- Chits pass to Hidden Layer 2 → re-written as 2 chits each.
- All chits reach the Output node who guesses the image and writes a ≤5-line summary.
- If the summary matches the actual image → the whole network wins! Otherwise, it loses.
Quick Revision — Key Points to Remember
- AI = machines mimicking human intelligence. ML = AI that improves with experience. DL = ML that self-trains with vast data. Relation: AI ⊇ ML ⊇ DL.
- Data terms: Data · Features (columns) · Labels (tags) · Labeled vs Unlabeled · Training data · Testing data.
- 2 modelling approaches: Rule-Based (developer defines rules — e.g., FAQ chatbot) · Learning-Based (machine finds patterns — e.g., spam filter).
- 3 ML categories: Supervised (labelled data) · Unsupervised (unlabelled data) · Reinforcement (reward-based trial & error).
- Supervised analogy: teacher with solved examples. Example: coin-weight → currency.
- Unsupervised analogy: child swimming alone. Example: supermarket clustering, Netflix recommendations.
- Reinforcement analogy: learn from reward/penalty. Example: apple/cherry feedback, humanoid walking, self-parking car.
- Supervised sub-categories: Classification (discrete — spam/not spam, loan yes/no) · Regression (continuous — temperature, house price, car price).
- Unsupervised sub-categories: Clustering (similarity groups — Jim's music) · Association (relationships — bread→butter).
- DL sub-categories: ANN (general neural nets) · CNN (image recognition).
- Neural Network layers: Input (acquires data) · Hidden (processes with weights/biases) · Output (delivers result).
- Perceptron: inputs × weights + bias × WB → compare with threshold → output.
- Weights/biases come from experience, preference or caution — different people = different decisions.
- Human Neural Network Game: 20 students across 4 layers passing chits to guess a hidden image — direct experience of how NNs process information.