Machine Learning (ML) Basics
NCO – Cyber Olympiad
Digital Ethics & Emerging Technologies
Machine Learning is a sub‑field of artificial intelligence that enables computers to learn patterns from data, make predictions, or take actions without being explicitly programmed for every scenario.
1. Simple Explanation
-
What it is
- ML algorithms learn from examples (training data).
- Once trained, they can generalise to new, unseen data.
-
Why it matters
- Powers recommendation engines, autonomous vehicles, fraud detection, etc.
- Can amplify bias or privacy risks if not handled responsibly.
-
Core Components
- Data – raw input (images, text, numbers).
- Model – mathematical function mapping input to output.
- Training – iteratively adjusting the model to minimise error.
- Evaluation – measuring performance on unseen data.
- Deployment – putting the model into real‑world use.
2. Key Points
| Concept | What It Means | Typical Terminology |
|---|---|---|
| Supervised Learning | Learning with labelled data (input → correct output). | Regression, Classification |
| Unsupervised Learning | No labels; discover hidden structure. | Clustering, Dimensionality Reduction |
| Overfitting vs. Underfitting | Over‑training on noise vs. too simple a model. | Bias‑Variance Tradeoff |
| Training / Validation / Test Sets | Separate data splits to train, tune, and evaluate. | Cross‑validation, Hold‑out |
| Loss Function | Numeric measure of error; guides optimisation. | Mean Squared Error, Cross‑Entropy |
| Gradient Descent | Optimisation method moving model parameters downhill. | Stochastic, Mini‑batch |
| Regularisation | Penalise complexity to avoid over‑fitting. | L1, L2, Dropout |
| Feature Engineering | Selecting/transforming inputs to improve learning. | Normalisation, One‑hot |
| Bias & Fairness | Systematic errors that can discriminate. | Protected attributes, disparate impact |
| Privacy | Risk of leaking individual data from model. | Differential privacy, Federated learning |
3. Worked Example – Linear Regression
Problem
Predict a student’s final exam score from hours studied.
| Hours Studied (x) | Final Score (y) |
|---|---|
| 2 | 55 |
| 4 | 65 |
| 6 | 70 |
| 8 | 78 |
| 10 | 85 |
Steps
-
Define model
( \hat{y} = w_0 + w_1 x ) -
Compute parameters (least‑squares)
[ w_1 = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^2} ] [ w_0 = \bar{y} - w_1 \bar{x} ]
Here, (\bar{x}=6), (\bar{y}=71).
[ w_1 = \frac{(2-6)(55-71)+(4-6)(65-71)+(6-6)(70-71)+(8-6)(78-71)+(10-6)(85-71)}{(2-6)^2+(4-6)^2+(6-6)^2+(8-6)^2+(10-6)^2} \approx 3.5 ] [ w_0 = 71 - 3.5 * 6 \approx 48 ]
Model: ( \hat{y} = 48 + 3.5x )
-
Predict
For 7 hours studied: ( \hat{y} = 48 + 3.5*7 = 75.5 ) -
Evaluate
- Compute Mean Squared Error (MSE) on training data.
- If MSE is low → good fit; else adjust (regularisation, more data).
-
Ethical Check
- Fairness: Does the model treat all student groups equally?
- Transparency: Is the linear model explainable to stakeholders?
- Data Bias: Are the training hours representative of all demographics?
Take‑away
Linear regression is the simplest ML algorithm. It showcases the core ML workflow: data → model → training → evaluation → ethical review.
4. Quick Revision Summary
| Topic | Quick Fact |
|---|---|
| ML Goal | Learn from data to make predictions or decisions. |
| Supervised vs Unsupervised | Labeled data vs. pattern discovery. |
| Key Metrics | Accuracy, Precision, Recall, F1, MSE, AUC‑ROC. |
| Overfitting | High training accuracy, low test accuracy. |
| Regularisation | Adds penalty to keep model simple. |
| Bias‑Variance Tradeoff | Balance between under‑ and over‑fitting. |
| Ethics | Bias, fairness, privacy, transparency. |
| Common Algorithms | Linear/Logistic Regression, Decision Trees, SVM, Neural Networks, K‑Means. |
| Pipeline | Data → Preprocess → Train → Validate → Deploy → Monitor. |
Quick Quiz
- What does “overfitting” mean in ML?
- Name one way to mitigate privacy concerns when training on personal data.
- Give an example of a supervised learning task.
Answer:
- The model learns noise, performing poorly on new data.
- Differential privacy or federated learning.
- Email spam classification (input: email, label: spam or not).
Next Steps
- Experiment with a simple dataset in Python (scikit‑learn).
- Try a Kaggle “Titanic” notebook to see data cleaning, modelling, and evaluation.
- Read about AI Ethics frameworks (IEEE, EU AI Act) to understand responsible ML deployment.