Unit 3: Machine Learning - Subjective Questions
INT428 — Artificial Intelligence Essentials • Practice Questions with Detailed Answers
20 questions
Define Machine Learning. Explain the three main paradigms of machine learning with real-world examples for each.
Machine Learning (ML) is a subfield of Artificial Intelligence that enables systems to automatically learn patterns from data and improve their performance on a task without being explicitly programmed for every scenario.
The three main paradigms are:
-
Supervised Learning: The model learns from labeled data (input-output pairs). The goal is to map inputs to known outputs.
- Example: Email spam detection (spam/not spam), house price prediction.
-
Unsupervised Learning: The model learns from unlabeled data to discover hidden patterns or groupings.
- Example: Customer segmentation for marketing, anomaly detection in network traffic.
-
Reinforcement Learning (RL): An agent learns by interacting with an environment, receiving rewards or penalties for its actions to maximize cumulative reward.
- Example: Game-playing AI (AlphaGo), robotics control, self-driving cars.
Each paradigm suits different problem types depending on data availability and the nature of feedback.
State and derive Bayes' Theorem. Explain the meaning of each term with a practical example.
Bayes' Theorem describes the probability of an event based on prior knowledge of related conditions.
Statement:
Derivation:
From the definition of conditional probability:
From the second equation:
Substituting into the first:
Meaning of terms:
- — Posterior: probability of given evidence .
- — Likelihood: probability of observing if is true.
- — Prior: initial probability of .
- — Evidence: total probability of .
Example (Medical Test): If a disease affects 1% of people (), a test is 99% accurate (), and has a 5% false positive rate, Bayes' theorem helps compute the true probability that a person with a positive test actually has the disease, which is often surprisingly low due to the low prior.
Explain Feature Engineering. Describe common feature engineering techniques and why they are important for model performance.
Feature Engineering is the process of using domain knowledge to create, transform, or select features (input variables) that make machine learning algorithms work more effectively.
Common Techniques:
- Handling Missing Values: Imputation with mean, median, or mode; or dropping incomplete records.
- Encoding Categorical Variables:
- One-Hot Encoding for nominal categories.
- Label Encoding for ordinal categories.
- Feature Scaling:
- Normalization (Min-Max):
- Standardization (Z-score):
- Feature Creation: Combining or transforming existing features (e.g., extracting day/month from a date).
- Binning/Discretization: Converting continuous values into categorical bins.
- Dimensionality Reduction: Using PCA to reduce feature count.
Importance:
- Improves model accuracy and generalization.
- Reduces overfitting by removing noise.
- Makes models train faster with fewer, more relevant features.
- Well-engineered features often matter more than the choice of algorithm.
Define Precision and Recall. Derive their formulas from a confusion matrix and explain the trade-off between them.
Precision and Recall are evaluation metrics for classification models, derived from the confusion matrix:
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actual Positive | TP | FN |
| Actual Negative | FP | TN |
Precision: Of all instances predicted positive, how many are actually positive?
Recall (Sensitivity): Of all actual positive instances, how many were correctly predicted?
Trade-off:
- Increasing precision often reduces recall and vice versa.
- High precision + low recall: model is conservative, misses many positives (e.g., cautious spam filter).
- High recall + low precision: model catches most positives but many false alarms (e.g., disease screening).
The F1-Score balances both:
The choice depends on the application: recall matters in cancer detection, precision matters in spam filtering.
Explain Cross-Validation. Describe k-fold cross-validation with a diagram-style explanation and state its advantages.
Cross-Validation is a resampling technique used to evaluate ML models on limited data by partitioning the dataset into subsets for training and validation, giving a more reliable estimate of model performance.
k-Fold Cross-Validation:
- Split the dataset into equal-sized subsets (folds).
- For each iteration, use folds for training and 1 fold for validation.
- Repeat times so each fold serves as validation once.
- Average the performance scores.
Illustration (k=5):
Iteration 1: [Test ][Train][Train][Train][Train]
Iteration 2: [Train][Test ][Train][Train][Train]
Iteration 3: [Train][Train][Test ][Train][Train]
Iteration 4: [Train][Train][Train][Test ][Train]
Iteration 5: [Train][Train][Train][Train][Test ]
Final Score:
Advantages:
- Uses all data for both training and testing.
- Reduces overfitting and gives less biased evaluation.
- Provides a more robust estimate of generalization performance.
Special case: When (number of samples), it becomes Leave-One-Out Cross-Validation (LOOCV).
What is a Bayesian Network? Explain its structure, components, and how it enables probabilistic reasoning.
A Bayesian Network (Belief Network) is a Directed Acyclic Graph (DAG) that represents a set of variables and their conditional dependencies via a graphical model.
Components:
- Nodes: Represent random variables.
- Directed Edges: Represent conditional dependencies (causal relationships).
- Conditional Probability Tables (CPTs): Each node has a CPT quantifying the effect of its parents.
Key Property — Chain Rule:
The joint probability distribution factorizes as:
Example: A network with nodes Rain, Sprinkler, and Wet Grass:
- Rain → Wet Grass
- Sprinkler → Wet Grass
- Rain → Sprinkler
Probabilistic Reasoning:
- Inference: Compute the probability of query variables given evidence.
- Supports diagnostic reasoning (effect → cause) and predictive reasoning (cause → effect).
Advantages:
- Compact representation of joint distributions.
- Handles uncertainty naturally.
- Encodes conditional independence to reduce computation.
Distinguish between Supervised and Unsupervised Learning across at least five dimensions.
| Aspect | Supervised Learning | Unsupervised Learning |
|---|---|---|
| Data | Labeled data (input-output pairs) | Unlabeled data (input only) |
| Goal | Predict output for new inputs | Discover hidden patterns/structure |
| Feedback | Guided by known correct answers | No explicit feedback |
| Tasks | Classification, Regression | Clustering, Association, Dimensionality Reduction |
| Algorithms | Linear Regression, SVM, Decision Trees | K-Means, Hierarchical Clustering, PCA |
| Complexity | Easier to evaluate (accuracy known) | Harder to evaluate (no ground truth) |
| Example | Predicting house prices | Grouping customers by behavior |
Summary:
- Supervised learning answers "What is the label?" using training examples with known answers.
- Unsupervised learning answers "What structure exists?" by finding natural groupings or reduced representations without labels.
Explain the role of Linear Algebra in Machine Learning. Describe key concepts such as vectors, matrices, and matrix operations with applied examples.
Linear Algebra is fundamental to ML because data and model parameters are represented as vectors and matrices, enabling efficient computation.
Key Concepts:
- Scalars: Single numbers (e.g., a learning rate).
- Vectors: Ordered arrays representing a data point or feature set. Example feature vector:
- Matrices: 2D arrays; a dataset with samples and features is an matrix.
- Tensors: Multi-dimensional arrays (used in deep learning).
Key Operations:
- Dot Product: Used in computing weighted sums in models:
- Matrix Multiplication: Core of neural network forward passes:
- Transpose: used in normal equations.
- Inverse: Used in the closed-form linear regression solution:
Applications:
- PCA uses eigenvalues/eigenvectors for dimensionality reduction.
- Neural networks rely on matrix operations for efficiency.
- Recommender systems use matrix factorization.
Describe the key concepts of Probability relevant to Machine Learning: random variables, probability distributions, conditional probability, and independence.
Probability provides the mathematical foundation for reasoning under uncertainty in ML.
Key Concepts:
-
Random Variable: A variable whose values result from a random phenomenon.
- Discrete: takes countable values (e.g., dice roll).
- Continuous: takes values in a range (e.g., temperature).
-
Probability Distribution: Describes how probabilities are distributed over values.
- Discrete: Probability Mass Function (PMF), e.g., Bernoulli, Binomial.
- Continuous: Probability Density Function (PDF), e.g., Gaussian:
-
Conditional Probability: Probability of given has occurred:
-
Independence: Events and are independent if:
Relevance to ML:
- Naive Bayes classifiers use conditional probability.
- Gaussian distributions model continuous features.
- Probabilistic models quantify prediction uncertainty.
Explain Reinforcement Learning in detail. Describe its key components and the exploration-exploitation trade-off.
Reinforcement Learning (RL) is a learning paradigm where an agent learns optimal behavior through trial-and-error interactions with an environment, aiming to maximize cumulative reward.
Key Components:
- Agent: The learner/decision-maker.
- Environment: The world the agent interacts with.
- State (): Current situation of the agent.
- Action (): Choices available to the agent.
- Reward (): Feedback signal for an action.
- Policy (): Strategy mapping states to actions.
- Value Function (): Expected long-term reward from a state.
Goal: Maximize expected cumulative discounted reward:
where is the discount factor ().
Exploration vs. Exploitation Trade-off:
- Exploration: Trying new actions to discover their rewards.
- Exploitation: Choosing known actions that yield high rewards.
- A balance is needed; too much exploitation misses better options, too much exploration wastes resources. Strategies like -greedy address this.
Applications: Game AI (AlphaGo), robotics, autonomous vehicles, recommendation systems.
Explain the Naive Bayes Classifier. Why is it called "naive", and what is its main advantage?
The Naive Bayes Classifier is a probabilistic classifier based on Bayes' Theorem with a strong (naive) independence assumption between features.
Formula:
For a class and features :
The predicted class is:
Why "Naive"?
It assumes all features are conditionally independent given the class label. This is rarely true in reality (e.g., words in a sentence are related), but the assumption simplifies computation drastically.
Advantages:
- Fast and computationally efficient.
- Works well with high-dimensional data (e.g., text).
- Requires little training data.
- Performs surprisingly well despite the naive assumption.
Types: Gaussian, Multinomial, Bernoulli Naive Bayes.
Applications: Spam filtering, sentiment analysis, document classification.
Explain the concepts of Overfitting and Underfitting. How can each be detected and prevented?
Overfitting and Underfitting describe two ways a model fails to generalize well.
Underfitting:
- The model is too simple to capture underlying patterns.
- High bias, low variance.
- Poor performance on both training and test data.
- Prevention: Use more complex models, add features, reduce regularization, train longer.
Overfitting:
- The model is too complex and memorizes training data including noise.
- Low bias, high variance.
- Excellent training performance but poor test performance.
- Prevention:
- Regularization (L1/L2).
- Cross-validation.
- More training data.
- Dropout (in neural nets).
- Early stopping.
- Pruning (in decision trees).
Detection:
- Compare training vs. validation error:
- Both high → underfitting.
- Training low, validation high → overfitting.
Goal — Bias-Variance Trade-off: Find the sweet spot minimizing total error:
A medical test for a disease is 95% accurate. The disease affects 1% of the population. If the false positive rate is 5%, calculate the probability that a person actually has the disease given a positive test result using Bayes' Theorem.
Given:
- (prior probability of disease)
- (true positive / sensitivity)
- (false positive rate)
Required:
Bayes' Theorem:
Step 1 — Compute total probability of positive test :
Step 2 — Apply Bayes' Theorem:
Result:
Interpretation: Despite a positive test, there is only about a 16% chance the person actually has the disease. This is because the disease is rare (low prior), demonstrating why base rates matter in probabilistic reasoning.
Compare Classification and Regression in supervised learning. Provide examples and appropriate evaluation metrics for each.
Both Classification and Regression are supervised learning tasks, but they differ in output type.
| Aspect | Classification | Regression |
|---|---|---|
| Output | Discrete class/category | Continuous numeric value |
| Goal | Assign input to a class | Predict a quantity |
| Examples | Spam detection, image recognition | House price, temperature prediction |
| Algorithms | Logistic Regression, SVM, Decision Trees | Linear Regression, Ridge, SVR |
Evaluation Metrics:
Classification:
- Accuracy:
- Precision, Recall, F1-Score
- ROC-AUC curve
- Confusion Matrix
Regression:
- Mean Absolute Error (MAE):
- Mean Squared Error (MSE):
- Root Mean Squared Error (RMSE):
- R-squared (): proportion of variance explained.
Summary: Use classification for categorical predictions and regression for continuous predictions; choose metrics accordingly.
Explain important Descriptive Statistics concepts used in ML: mean, median, mode, variance, standard deviation, and correlation.
Descriptive Statistics summarize and describe the main features of a dataset, essential for understanding data before modeling.
Measures of Central Tendency:
- Mean: Average value.
- Median: Middle value when data is sorted (robust to outliers).
- Mode: Most frequently occurring value.
Measures of Dispersion:
- Variance: Average squared deviation from the mean.
- Standard Deviation: Square root of variance (same units as data).
Measure of Relationship:
- Correlation (Pearson): Measures linear relationship between two variables, ranging from to .
Relevance to ML:
- Detect outliers and skewness.
- Guide feature selection (highly correlated features may be redundant).
- Inform scaling and normalization decisions.
Describe K-Means Clustering algorithm step by step. What are its limitations?
K-Means is an unsupervised clustering algorithm that partitions data into clusters, where each data point belongs to the cluster with the nearest centroid.
Algorithm Steps:
- Choose — the number of clusters.
- Initialize centroids randomly.
- Assignment Step: Assign each data point to the nearest centroid using Euclidean distance:
- Update Step: Recompute each centroid as the mean of points assigned to it:
- Repeat steps 3–4 until centroids stabilize (convergence).
Objective Function (minimize):
Limitations:
- Must specify in advance.
- Sensitive to initial centroid placement.
- Assumes spherical, equal-sized clusters.
- Sensitive to outliers and scaling.
- May converge to local optima.
Tip: The Elbow Method helps choose the optimal .
Explain the concept of Probabilistic Reasoning in AI. Why is it necessary, and how do probabilistic models handle uncertainty?
Probabilistic Reasoning is the process of using probability theory to represent and reason about uncertain knowledge in AI systems.
Why It Is Necessary:
- Real-world information is often incomplete, noisy, or uncertain.
- Logical (deterministic) reasoning cannot handle partial knowledge or ambiguity.
- Enables systems to make rational decisions despite uncertainty.
How Uncertainty Is Handled:
- Representing beliefs as probabilities: Instead of true/false, statements have degrees of belief between 0 and 1.
- Conditional Probability: Updating beliefs given new evidence.
- Bayes' Theorem: Core mechanism for belief updating:
- Bayesian Networks: Compactly represent joint distributions and dependencies.
- Marginalization & Inference: Compute probabilities of query variables.
Key Tools:
- Joint, marginal, and conditional distributions.
- Independence and conditional independence assumptions.
Applications:
- Medical diagnosis, spam filtering, speech recognition, robot localization, and recommendation systems.
Advantage: Provides a principled framework to combine prior knowledge with observed evidence and quantify confidence in conclusions.
Derive the closed-form solution (Normal Equation) for Linear Regression using linear algebra, and explain each step.
Linear Regression models the relationship between features and a target as:
where is the feature matrix and is the parameter vector.
Objective — Minimize Sum of Squared Errors (Cost Function):
Step 1 — Expand:
Step 2 — Differentiate w.r.t. and set to zero:
Step 3 — Solve for :
Step 4 — Normal Equation:
Explanation:
- is an matrix that must be invertible.
- This gives the optimal weights directly without iterative optimization.
Limitation: Computing the inverse is expensive () for large feature counts; gradient descent is preferred for big data.
Explain the difference between Population and Sample in statistics, and describe why sampling is important in Machine Learning.
Population vs. Sample:
| Aspect | Population | Sample |
|---|---|---|
| Definition | Entire set of all data/individuals | Subset drawn from the population |
| Size | Usually very large or infinite | Smaller, manageable |
| Parameters | Described by parameters (, ) | Described by statistics (, ) |
| Measurement | Often impractical to measure fully | Practical and cost-effective |
Why Sampling Is Important in ML:
- Collecting or processing entire populations is often impossible or expensive.
- A well-chosen sample allows efficient training while representing the whole.
- Enables train-test splits and cross-validation.
Sampling Techniques:
- Random Sampling: Every element has equal chance.
- Stratified Sampling: Preserves class proportions (important for imbalanced data).
- Systematic Sampling: Selecting every -th element.
Sampling Bias Warning: A non-representative sample leads to biased models that generalize poorly. Good sampling ensures the training data reflects real-world distribution.
Explain the complete Machine Learning Model Development Pipeline, from data collection to deployment.
The ML Model Development Pipeline is a structured sequence of stages to build, evaluate, and deploy a model.
1. Problem Definition:
- Define the objective and success metrics.
2. Data Collection:
- Gather relevant data from databases, APIs, sensors, etc.
3. Data Preprocessing & Cleaning:
- Handle missing values, remove duplicates, correct errors.
- Handle outliers.
4. Exploratory Data Analysis (EDA):
- Use statistics and visualization to understand patterns and correlations.
5. Feature Engineering:
- Create, transform, encode, and scale features.
- Perform feature selection/dimensionality reduction.
6. Data Splitting:
- Divide into training, validation, and test sets.
7. Model Selection & Training:
- Choose appropriate algorithms and train on the training set.
8. Model Evaluation:
- Use cross-validation and metrics (accuracy, precision, recall, RMSE).
- Tune hyperparameters (e.g., Grid Search).
9. Deployment:
- Integrate the model into production (API, web service).
10. Monitoring & Maintenance:
- Track performance, detect data drift, and retrain as needed.
Key Point: The pipeline is iterative — insights from later stages often lead back to earlier steps for refinement.
Define Machine Learning. Explain the three main paradigms of machine learning with real-world examples for each.
Machine Learning (ML) is a subfield of Artificial Intelligence that enables systems to automatically learn patterns from data and improve their performance on a task without being explicitly programmed for every scenario.
The three main paradigms are:
-
Supervised Learning: The model learns from labeled data (input-output pairs). The goal is to map inputs to known outputs.
- Example: Email spam detection (spam/not spam), house price prediction.
-
Unsupervised Learning: The model learns from unlabeled data to discover hidden patterns or groupings.
- Example: Customer segmentation for marketing, anomaly detection in network traffic.
-
Reinforcement Learning (RL): An agent learns by interacting with an environment, receiving rewards or penalties for its actions to maximize cumulative reward.
- Example: Game-playing AI (AlphaGo), robotics control, self-driving cars.
Each paradigm suits different problem types depending on data availability and the nature of feedback.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →