B.To enable computers to learn from data without being explicitly programmed
C.To write complex algorithms that can solve any problem
D.To store large amounts of data efficiently
Correct Answer: To enable computers to learn from data without being explicitly programmed
Explanation:
The core idea of Machine Learning, as defined by Arthur Samuel, is to give computers the ability to learn without being explicitly programmed. It focuses on developing algorithms that can identify patterns and make decisions from data.
Incorrect! Try again.
2Which type of Machine Learning involves training a model on a dataset with labeled outputs?
Types of Machine Learning
Easy
A.Supervised Learning
B.Unsupervised Learning
C.Reinforcement Learning
D.Semi-supervised Learning
Correct Answer: Supervised Learning
Explanation:
Supervised Learning is characterized by the use of labeled data. The algorithm learns to map input features to a known output label, which acts as a 'supervisor' during training.
Incorrect! Try again.
3Grouping customers into different clusters based on their purchasing behavior is an example of what type of machine learning?
Clustering is an unsupervised learning task that involves grouping a set of objects based on similarity, without any predefined labels. Customer segmentation is a classic example.
Incorrect! Try again.
4Which of the following best describes the relationship between Artificial Intelligence (AI) and Machine Learning (ML)?
Difference between ML, AI and Data Science
Easy
A.AI is a subset of ML
B.AI and ML are the same thing
C.ML is a subset of AI
D.AI and ML are completely separate fields
Correct Answer: ML is a subset of AI
Explanation:
Artificial Intelligence is the broad concept of creating machines that can think or act intelligently. Machine Learning is a specific subset of AI that focuses on systems learning from data.
Incorrect! Try again.
5A key characteristic of a parametric model is that it:
Parametric vs Non-parametric models
Easy
A.Has a number of parameters that grows with the data
B.Does not make any assumptions about the data
C.Is always less accurate than a non-parametric model
D.Has a fixed number of parameters and makes strong assumptions about the data's form
Correct Answer: Has a fixed number of parameters and makes strong assumptions about the data's form
Explanation:
Parametric models, like Linear Regression, assume a specific functional form for the relationship they are trying to learn (e.g., a line). The model is fully defined by a fixed number of parameters, regardless of the amount of training data.
Incorrect! Try again.
6Which type of model learns the decision boundary between different classes directly?
Generative vs Discriminative Models
Easy
A.Regression Model
B.Generative Model
C.Clustering Model
D.Discriminative Model
Correct Answer: Discriminative Model
Explanation:
A discriminative model learns the conditional probability . Its primary goal is to learn how to distinguish (discriminate) between different classes by finding a decision boundary.
Incorrect! Try again.
7What is typically the first step in a standard Machine Learning workflow?
Machine Learning Workflow
Easy
A.Data Collection and Preparation
B.Performance Evaluation
C.Model Deployment
D.Model Training
Correct Answer: Data Collection and Preparation
Explanation:
Before any model can be trained, data must be gathered, cleaned, and prepared into a suitable format. This is the foundational first step of any ML project.
Incorrect! Try again.
8What is the primary purpose of a test set in machine learning?
Train-Test data split
Easy
A.To provide an unbiased evaluation of the final model's performance on unseen data
B.To validate and tune hyperparameters
C.To reduce the size of the training dataset
D.To train the model more effectively
Correct Answer: To provide an unbiased evaluation of the final model's performance on unseen data
Explanation:
The test set is held out during training and validation. It is used only once at the very end to estimate how well the model will generalize to new, real-world data.
Incorrect! Try again.
9For a classification problem, what does the Accuracy metric measure?
Overview of Evaluation Metrics
Easy
A.The average squared difference between the predicted and actual values
B.The ratio of true positives to the sum of true positives and false positives
C.The model's confidence in its predictions
D.The proportion of correct predictions out of the total number of predictions
Correct Answer: The proportion of correct predictions out of the total number of predictions
Explanation:
Accuracy is a fundamental classification metric calculated as (Number of Correct Predictions) / (Total Number of Predictions).
Incorrect! Try again.
10When a machine learning model performs very well on the training data but poorly on the test data, what is this phenomenon called?
Overfitting and Underfitting
Easy
A.Underfitting
B.A good fit
C.Overfitting
D.Data leakage
Correct Answer: Overfitting
Explanation:
Overfitting occurs when a model learns the training data too well, including its noise and random fluctuations, and therefore fails to generalize to new, unseen data.
Incorrect! Try again.
11A model that is too simple and fails to capture the underlying patterns in the data, resulting in high error on both training and test sets, is said to be...
Overfitting and Underfitting
Easy
A.Overfitting
B.Underfitting
C.Robust
D.Generalizing
Correct Answer: Underfitting
Explanation:
Underfitting happens when a model is not complex enough to learn the relationship between the features and the target variable, leading to poor performance everywhere.
Incorrect! Try again.
12In the context of the Bias-Variance Trade-off, a model with high bias and low variance typically...
Bias-Variance Trade-off
Easy
A.Is a very complex model
B.Perfectly fits the data
C.Overfits the data
D.Underfits the data
Correct Answer: Underfits the data
Explanation:
High bias means the model makes strong (and often incorrect) assumptions about the data, leading to underfitting. Low variance means the model's predictions are consistent but may be consistently wrong.
Incorrect! Try again.
13Which of the following is a common application of Machine Learning?
Applications and Use-cases of ML
Easy
A.Designing a computer processor
B.Writing an operating system kernel
C.Creating a basic text editor
D.Spam email filtering
Correct Answer: Spam email filtering
Explanation:
Spam filtering is a classic classification problem where machine learning models are trained to distinguish between spam and non-spam (ham) emails based on their content and metadata.
Incorrect! Try again.
14What is the primary data structure used in the NumPy library for numerical computing?
Numpy for Numerical Computing
Easy
A.List
B.DataFrame
C.Dictionary
D.ndarray (N-dimensional array)
Correct Answer: ndarray (N-dimensional array)
Explanation:
NumPy's core object is the ndarray, a powerful and efficient N-dimensional array that supports a wide range of mathematical operations.
Incorrect! Try again.
15Which NumPy function is used to create an array of a specified shape, filled with the number 1?
Creating Arrays
Easy
A.numpy.empty()
B.numpy.zeros()
C.numpy.arange()
D.numpy.ones()
Correct Answer: numpy.ones()
Explanation:
The numpy.ones(shape) function returns a new array of a given shape and type, filled with ones.
Incorrect! Try again.
16What will the following NumPy code produce? import numpy as np; arr = np.arange(5)
Creating Arrays
Easy
A.An array [0, 1, 2, 3, 4, 5]
B.An array [0, 1, 2, 3, 4]
C.An array [1, 2, 3, 4, 5]
D.A single number 5
Correct Answer: An array [0, 1, 2, 3, 4]
Explanation:
np.arange(n) creates an array with values from 0 up to (but not including) n. Therefore, np.arange(5) creates [0, 1, 2, 3, 4].
Incorrect! Try again.
17Given two NumPy arrays, a = np.array([1, 2, 3]) and b = np.array([4, 5, 6]), what is the result of a + b?
Operations on Arrays
Easy
A.An array [5, 7, 9]
B.An error because you cannot add arrays
C.An array [1, 2, 3, 4, 5, 6]
D.An array [[1, 4], [2, 5], [3, 6]]
Correct Answer: An array [5, 7, 9]
Explanation:
When two NumPy arrays of the same shape are added, the operation is performed element-wise. So, the result is [1+4, 2+5, 3+6], which is [5, 7, 9].
Incorrect! Try again.
18If arr = np.array([10, 20, 30]), what is the result of arr / 10?
Operations on Arrays
Easy
A.A single number 2
B.An array [1, 2, 3]
C.An error, division is not supported
D.An array [10, 20, 30, 10]
Correct Answer: An array [1, 2, 3]
Explanation:
This is an example of broadcasting. The scalar 10 is divided element-wise into the array, resulting in [10/10, 20/10, 30/10] which is [1., 2., 3.] (as a float array).
Incorrect! Try again.
19What is NumPy's 'Broadcasting'?
Broadcasting Rule
Easy
A.A way to convert arrays to different data types.
B.A method for sending arrays over a network.
C.A function that makes arrays larger by repeating elements.
D.The ability to perform arithmetic operations on arrays of different but compatible shapes.
Correct Answer: The ability to perform arithmetic operations on arrays of different but compatible shapes.
Explanation:
Broadcasting describes the set of rules by which NumPy performs element-wise operations on arrays of different shapes, effectively 'stretching' the smaller array to match the shape of the larger one without making actual copies of the data.
Incorrect! Try again.
20Which function from NumPy's random module would you use to generate an array of random integers within a specific range?
Random Module
Easy
A.np.random.rand()
B.np.random.choice()
C.np.random.randn()
D.np.random.randint()
Correct Answer: np.random.randint()
Explanation:
np.random.randint(low, high, size) is used to generate an array of a given size with random integers from the 'low' (inclusive) to 'high' (exclusive) range.
Incorrect! Try again.
21A machine learning model demonstrates high variance and low bias. Which of the following strategies is most likely to improve the model's performance on a new, unseen test set?
Bias-Variance Trade-off
Medium
A.Use a smaller set of features for training.
B.Decrease the amount of regularization applied to the model.
C.Increase the complexity of the model (e.g., add more polynomial features).
D.Gather more training data for the model.
Correct Answer: Gather more training data for the model.
Explanation:
High variance indicates overfitting, where the model has learned the training data too well, including its noise. Gathering more training data is a classic technique to reduce variance, as it helps the model learn a more generalizable pattern. Increasing complexity or decreasing regularization would likely worsen the overfitting (increase variance). Using fewer features could simplify the model, which also reduces variance, but gathering more data is a more direct and generally effective approach.
Incorrect! Try again.
22A data scientist trains a decision tree and observes that the training accuracy is 99%, while the validation accuracy is only 72%. This is a clear case of overfitting. Which of the following is the most appropriate next step to mitigate this issue?
Overfitting and Underfitting
Medium
A.Use a larger portion of the data for training and a smaller portion for validation.
B.Prune the tree by setting a reasonable max_depth or increasing min_samples_leaf.
C.Decrease the min_samples_split parameter to allow splits on smaller nodes.
D.Increase the max_depth parameter of the tree to allow it to learn more complex patterns.
Correct Answer: Prune the tree by setting a reasonable max_depth or increasing min_samples_leaf.
Explanation:
The significant gap between training and validation accuracy indicates overfitting. The model is too complex. Pruning the tree by limiting its maximum depth (max_depth) or requiring more samples to form a leaf (min_samples_leaf) are common and effective methods to simplify the model, reduce its variance, and improve its ability to generalize.
Incorrect! Try again.
23You are working with a very large dataset where you suspect the underlying data distribution is highly complex and non-linear. Which type of model is generally more suitable in this scenario and why?
Parametric vs Non-parametric models
Medium
A.A non-parametric model, because it is more flexible and can capture complex patterns without being constrained by a predefined functional form.
B.A parametric model, because it has fewer parameters and is less likely to overfit a large dataset.
C.A non-parametric model, because it is always faster to train than a parametric model.
D.A parametric model, because it makes strong assumptions which simplifies the problem.
Correct Answer: A non-parametric model, because it is more flexible and can capture complex patterns without being constrained by a predefined functional form.
Explanation:
Non-parametric models (like k-Nearest Neighbors or Decision Trees) do not make strong assumptions about the underlying data distribution. Their flexibility allows them to fit a wider range of functional forms, making them suitable for complex data, especially when a large amount of it is available to avoid overfitting.
Incorrect! Try again.
24A team is building a system to generate realistic-looking images of human faces that do not exist in the real world. Which type of model is fundamentally designed for this task?
Generative vs Discriminative Models
Medium
A.A generative model, because it learns the underlying probability distribution of the data, , which allows it to sample new data points.
B.A discriminative model, because it directly models the conditional probability .
C.A discriminative model, because it learns the boundary between different classes of images.
D.A generative model, because it is always computationally less expensive than a discriminative model.
Correct Answer: A generative model, because it learns the underlying probability distribution of the data, , which allows it to sample new data points.
Explanation:
The core purpose of a generative model is to learn the joint probability distribution or the data distribution . By learning this distribution, it can generate new data samples that resemble the training data. Discriminative models, in contrast, learn the decision boundary between classes () and are used for classification, not generation.
Incorrect! Try again.
25An e-commerce company wants to build a system that groups its customers into distinct segments based on their purchasing behavior (e.g., high-spenders, occasional shoppers, brand-loyal). The company does not have pre-defined labels for these segments. This problem falls under which category of machine learning?
Since there are no pre-defined labels for the customer segments, the goal is to discover inherent structures or groups within the data. This task is known as clustering, which is a primary example of unsupervised learning.
Incorrect! Try again.
26An AI agent is being trained to play a complex video game. The agent interacts with the game environment, takes actions (like moving left or jumping), and receives a score (reward) based on its performance. The agent's goal is to learn a policy that maximizes its total score over time. This learning paradigm is best described as:
Types of Machine Learning
Medium
A.Unsupervised Learning
B.Semi-supervised Learning
C.Reinforcement Learning
D.Supervised Learning
Correct Answer: Reinforcement Learning
Explanation:
This scenario perfectly describes reinforcement learning, which involves an agent learning to make a sequence of decisions in an environment to maximize a cumulative reward. The learning happens through trial-and-error interactions rather than labeled examples.
Incorrect! Try again.
27Which statement best articulates the relationship between Artificial Intelligence (AI), Machine Learning (ML), and Data Science?
Difference between ML, AI and Data Science
Medium
A.Data Science is a subset of ML, which in turn is a subset of AI.
B.ML is a core subfield of AI that gives computers the ability to learn without being explicitly programmed. Both are tools and concepts used within the broader, interdisciplinary field of Data Science.
C.AI is a specific implementation of ML, which is a tool used in Data Science.
D.ML and Data Science are synonymous terms for the statistical branch of AI.
Correct Answer: ML is a core subfield of AI that gives computers the ability to learn without being explicitly programmed. Both are tools and concepts used within the broader, interdisciplinary field of Data Science.
Explanation:
This option correctly hierarchies the fields. AI is the broad concept of creating intelligent machines. ML is a primary approach to achieving AI. Data Science is a wider, interdisciplinary field that uses scientific methods, processes, and systems (including ML and AI) to extract knowledge and insights from data.
Incorrect! Try again.
28In a standard machine learning workflow, why is the 'Feature Engineering' step considered critically important?
Machine Learning Workflow
Medium
A.It is the only step where the model's hyperparameters are tuned.
B.It directly influences the model's ability to learn by transforming raw data into a format that better represents the underlying problem, often improving performance more than model selection itself.
C.It is the final step before deploying the model to production.
D.It is primarily concerned with splitting the data into training and testing sets.
Correct Answer: It directly influences the model's ability to learn by transforming raw data into a format that better represents the underlying problem, often improving performance more than model selection itself.
Explanation:
Feature engineering is the art and science of creating informative features from raw data. A well-designed feature can make a simple model outperform a complex one. It's crucial because most algorithms learn from the features they are given, and their quality directly determines the performance ceiling of the model.
Incorrect! Try again.
29Why is it a critical mistake to perform feature scaling (like Min-Max scaling or Standardization) on the entire dataset before splitting it into training and testing sets?
Train-Test data split
Medium
A.It prevents the use of certain models like Decision Trees, which are not sensitive to feature scaling.
B.It makes the training process computationally much slower.
C.It causes data leakage, where information from the test set (e.g., its minimum and maximum values) is used to transform the training set, leading to an overly optimistic and unrealistic performance evaluation.
D.It is not a mistake; scaling before splitting is a standard and recommended practice for convenience.
Correct Answer: It causes data leakage, where information from the test set (e.g., its minimum and maximum values) is used to transform the training set, leading to an overly optimistic and unrealistic performance evaluation.
Explanation:
The test set must remain completely unseen by the model during the entire training process, including preprocessing. If you scale the data before splitting, the scaling parameters (like mean/std or min/max) are calculated using the entire dataset. This means the training process is influenced by the test data, a phenomenon called data leakage. The correct procedure is to fit the scaler on the training data only and then use it to transform both the training and test data.
Incorrect! Try again.
30In a binary classification problem to detect fraudulent transactions, the cost of a False Negative (failing to detect a fraudulent transaction) is extremely high, while the cost of a False Positive (flagging a legitimate transaction as fraud) is relatively low. Which metric is most important to maximize in this scenario?
Overview of Evaluation Metrics
Medium
A.Precision
B.Recall (Sensitivity)
C.Accuracy
D.Specificity
Correct Answer: Recall (Sensitivity)
Explanation:
Recall is calculated as , where TP is True Positives and FN is False Negatives. Maximizing recall means minimizing the number of False Negatives. In this use case, it's crucial to identify as many of the actual fraudulent transactions as possible, even if it means incorrectly flagging some legitimate ones.
Incorrect! Try again.
31A real estate company uses a linear regression model to predict house prices. The model's performance is evaluated using Mean Squared Error (MSE), which yields a value of 900. What is the correct interpretation of the Root Mean Squared Error (RMSE) for this model?
Overview of Evaluation Metrics
Medium
A.The model is, on average, off by $900 in its predictions.
B.The model's accuracy is 90.0%.
C.The model explains 900% of the variance in house prices.
D.The RMSE is 30, meaning the standard deviation of the prediction errors is $30 (in units of thousands, if prices are so).
Correct Answer: The RMSE is 30, meaning the standard deviation of the prediction errors is $30 (in units of thousands, if prices are so).
Explanation:
Root Mean Squared Error (RMSE) is the square root of the Mean Squared Error (MSE). So, . The key advantage of RMSE over MSE is that its units are the same as the target variable (e.g., dollars for house prices). It represents the typical magnitude or standard deviation of the prediction errors.
Incorrect! Try again.
32A streaming service wants to build a feature that suggests movies to users based on their viewing history and the ratings they have given. Which machine learning technique is most directly applicable to this problem?
Applications and Use-cases of ML
Medium
A.Linear Regression
B.Anomaly Detection
C.Clustering
D.Collaborative Filtering / Recommender Systems
Correct Answer: Collaborative Filtering / Recommender Systems
Explanation:
This is the classic use-case for recommender systems. Collaborative filtering is a popular technique within this field that makes automatic predictions (filtering) about the interests of a user by collecting preferences or taste information from many users (collaborating).
Incorrect! Try again.
33Consider two NumPy arrays, A with shape (6, 1, 5) and B with shape (7, 1). If we compute C = A + B, what will be the shape of the resulting array C according to NumPy's broadcasting rules?
Broadcasting Rule
Medium
A.(6, 7, 1)
B.(6, 7, 5)
C.The operation will fail with a ValueError.
D.(1, 7, 5)
Correct Answer: (6, 7, 5)
Explanation:
Broadcasting compares shapes element-wise from right to left, after pre-pending 1s to the smaller shape to match dimensions.
A's shape: (6, 1, 5)
B's shape: (7, 1), pre-pended to (1, 7, 1)
Compare dimensions right-to-left:
Last dim: 5 and 1 are compatible.
Middle dim: 1 and 7 are compatible.
First dim: 6 and 1 are compatible.
The result shape is the maximum size along each dimension: (max(6,1), max(1,7), max(5,1)), which is (6, 7, 5).
Incorrect! Try again.
34Given a NumPy array X with shape (100, 10) representing 100 data samples with 10 features each. Which operation correctly computes the dot product of the transpose of X with X, and what does the resulting matrix represent?
Matrix operations
Medium
A.Z = X * X.T, which results in the covariance matrix.
B.Z = np.matmul(X.T, X), which results in a (10, 10) matrix often related to the feature covariance matrix.
C.Z = np.matmul(X, X.T), which results in a (10, 10) matrix representing sample similarity.
D.Z = X + X.T, which fails because the shapes are incompatible.
Correct Answer: Z = np.matmul(X.T, X), which results in a (10, 10) matrix often related to the feature covariance matrix.
Explanation:
X has shape (100, 10), so its transpose X.T has shape (10, 100). The matrix multiplication X.T @ X involves shapes (10, 100) and (100, 10), resulting in a (10, 10) matrix. This operation is fundamental in many ML algorithms (like calculating the covariance matrix or solving for weights in linear regression), where it captures the relationships between features.
Incorrect! Try again.
35What is the key difference between the operators * and @ when used with two 2D NumPy arrays A and B of shape (3, 3)?
Matrix operations
Medium
A.The * operator is used for matrix inversion, while the @ operator is for matrix multiplication.
B.The * operator performs element-wise multiplication (Hadamard product), while the @ operator performs standard matrix multiplication.
C.The @ operator performs element-wise multiplication, while the * operator performs standard matrix multiplication.
D.They are aliases for the same operation: matrix multiplication.
Correct Answer: The * operator performs element-wise multiplication (Hadamard product), while the @ operator performs standard matrix multiplication.
Explanation:
In NumPy, the * operator is overloaded for element-wise operations. For two arrays of the same shape, it will multiply corresponding elements. The @ operator was introduced in Python 3.5 (and supported by NumPy) specifically for matrix multiplication, equivalent to np.matmul().
Incorrect! Try again.
36You need to create a NumPy array that starts at 10, ends at 50, and has a step of 5 between consecutive elements. Which of the following function calls will NOT produce the desired array [10, 15, 20, 25, 30, 35, 40, 45]?
Creating Arrays
Medium
A.np.arange(10, 50, 5)
B.np.arange(10, 51, 5)
C.np.linspace(10, 45, 8)
D.np.arange(10, 46, 5)
Correct Answer: np.arange(10, 51, 5)
Explanation:
The stop parameter in np.arange is exclusive. So, np.arange(10, 50, 5) produces [10, 15, ..., 45]. np.arange(10, 46, 5) also produces the same result. np.linspace(10, 45, 8) creates 8 evenly spaced points between 10 and 45 inclusive, which is the desired array. However, np.arange(10, 51, 5) will include the number 50 in its output ([10, 15, ..., 45, 50]), which is not the desired array.
Incorrect! Try again.
37Given the NumPy array x = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), what is the result of the expression x[1:, :2]?
Operations on Arrays
Medium
A.array([[4, 5], [7, 8]])
B.array([[2, 3], [5, 6]])
C.array([[1, 2], [4, 5], [7, 8]])
D.array([4, 5])
Correct Answer: array([[4, 5], [7, 8]])
Explanation:
This is an example of NumPy slicing. 1: selects rows from index 1 to the end (the second and third rows). :2 selects columns from the beginning up to (but not including) index 2 (the first and second columns). The intersection of these two selections is the sub-array containing elements [[4, 5], [7, 8]].
Incorrect! Try again.
38You have a NumPy array data with shape (500, 20). You want to find the maximum value within each of the 20 columns. Which command will achieve this and what will be the shape of the result?
Operations on Arrays
Medium
A.np.max(data, axis=1), with shape (500,)
B.np.max(data), which returns a single scalar value
C.data.argmax(axis=1), with shape (500,)
D.np.max(data, axis=0), with shape (20,)
Correct Answer: np.max(data, axis=0), with shape (20,)
Explanation:
To perform an operation along columns, we use axis=0. This collapses the rows and applies the function (np.max) to each column independently. Since there are 20 columns, the resulting array will have 20 values, one for each column's maximum, resulting in a shape of (20,).
Incorrect! Try again.
39What is the primary difference in the distribution of numbers generated by numpy.random.rand(1000) versus numpy.random.randn(1000)?
Random Module
Medium
A.rand generates integers, while randn generates floats.
B.rand generates numbers from a uniform distribution over [0, 1), while randn generates numbers from a standard normal distribution (mean=0, std=1).
C.There is no difference; they are aliases for the same random number generator.
D.rand generates numbers from a standard normal distribution (mean=0, std=1), while randn generates from a uniform distribution between 0 and 1.
Correct Answer: rand generates numbers from a uniform distribution over [0, 1), while randn generates numbers from a standard normal distribution (mean=0, std=1).
Explanation:
This is a fundamental distinction in NumPy's random module. rand provides uniformly distributed random numbers in the half-open interval [0.0, 1.0). randn (the 'n' stands for 'normal') provides samples from the standard normal or Gaussian distribution.
Incorrect! Try again.
40You are running a machine learning experiment that involves random initialization of weights. To ensure that your results are reproducible, which function should you call before any random number generation, and why?
Random Module
Medium
A.np.random.seed(some_integer), to initialize the random number generator to a fixed state.
B.np.random.randn(), to warm up the random number generator.
C.np.random.shuffle(), to ensure the data is properly randomized.
D.np.random.clear(), to reset the random state to be truly random.
Correct Answer: np.random.seed(some_integer), to initialize the random number generator to a fixed state.
Explanation:
Computers generate pseudo-random numbers starting from an initial value called a seed. By setting the seed to a specific integer using np.random.seed(), you ensure that the sequence of 'random' numbers generated will be identical every time the code is run. This is crucial for debugging and making experiments reproducible.
Incorrect! Try again.
41A machine learning model exhibits high variance but low bias. Which of the following strategies is least likely to improve the model's performance on unseen data?
Bias-Variance Trade-off
Hard
A.Using a simpler model architecture with fewer parameters.
B.Implementing L2 regularization by increasing the lambda () parameter.
C.Adding more diverse training examples.
D.Performing feature engineering to add more complex, polynomial features.
Correct Answer: Performing feature engineering to add more complex, polynomial features.
Explanation:
A model with high variance and low bias is overfitting the training data. This means the model is already too complex. Adding more complex polynomial features would further increase the model's complexity, likely exacerbating the overfitting problem. The other options are standard techniques to combat high variance: adding more data helps the model generalize better, regularization penalizes large weights to reduce complexity, and using a simpler model directly addresses the complexity issue.
Incorrect! Try again.
42Consider a classification task where you have a very small, high-dimensional training dataset (e.g., 100 samples, 10,000 features). You need to build a classifier. Which model type is likely to perform better and why?
Generative vs Discriminative Models
Hard
A.A discriminative model like Logistic Regression, because it directly models the decision boundary without wasting resources on the data distribution.
B.A generative model like Naive Bayes, because it makes strong assumptions about data distribution, thus having fewer parameters to estimate.
C.A generative model like a Gaussian Mixture Model, because it can perfectly model the underlying clusters in the data.
D.A discriminative model like a Support Vector Machine with a complex kernel, because it can find a non-linear boundary in the high-dimensional space.
Correct Answer: A generative model like Naive Bayes, because it makes strong assumptions about data distribution, thus having fewer parameters to estimate.
Explanation:
In a 'small n, large p' scenario (few samples, many features), discriminative models like Logistic Regression or SVMs often struggle because they try to estimate a complex decision boundary directly from the limited data, making them prone to overfitting. Generative models like Naive Bayes model the joint probability by making strong independence assumptions. This simplifies the problem to estimating class priors and feature likelihoods, which requires far fewer parameters and is more robust with limited data.
Incorrect! Try again.
43You are choosing between a Linear Regression model and a k-Nearest Neighbors (k-NN) regression model. As the size of the training dataset approaches infinity, what is the fundamental difference in how the 'complexity' of the fitted model is determined?
Parametric vs Non-parametric models
Hard
A.Linear Regression's complexity is determined by the learning rate, while k-NN's complexity is determined by the distance metric used.
B.Linear Regression's complexity is fixed by the number of features, while k-NN's effective complexity grows with as it stores all data points.
C.Both models have complexity that is independent of ; it is only determined by the number of features.
D.Linear Regression's complexity grows with because the coefficients become more precise, while k-NN's complexity is fixed by the choice of .
Correct Answer: Linear Regression's complexity is fixed by the number of features, while k-NN's effective complexity grows with as it stores all data points.
Explanation:
Linear Regression is a parametric model. Its complexity is defined by a fixed number of parameters (coefficients and an intercept), which is determined by the number of features, not the number of training examples (). In contrast, k-NN is a non-parametric model. It doesn't learn explicit parameters in the same way. Its 'model' consists of the entire training dataset, which it must store to make predictions. Therefore, its complexity (in terms of storage and often computation) grows as increases.
Incorrect! Try again.
44Given two NumPy arrays A = np.ones((4, 1, 3)) and B = np.ones((5, 1, 1)). What is the shape of the resulting array from the operation C = A + B?
Numpy Broadcasting Rule
Hard
A.The operation will fail with a ValueError.
B.(5, 4, 3)
C.(1, 5, 3)
D.(4, 5, 3)
Correct Answer: The operation will fail with a ValueError.
Explanation:
Broadcasting works by comparing dimensions from right to left. The shapes are A: (4, 1, 3) and B: (5, 1, 1). Let's compare dimensions:
Rightmost dimension: A has 3, B has 1. This is compatible (1 will be stretched to 3).
Middle dimension: A has 1, B has 1. This is compatible.
Leftmost dimension: A has 4, B has 5. These are not equal, and neither is 1. Therefore, they are not compatible. The broadcasting rules fail at this dimension, and NumPy will raise a ValueError.
Incorrect! Try again.
45You plot a learning curve for your model which shows the training error is very low and has plateaued, while the validation error is significantly higher and has also plateaued. There is a large, persistent gap between the two curves. What is the most effective first step to address this issue?
Overfitting and Underfitting
Hard
A.Decrease the number of features through feature selection.
B.Use a more complex model (e.g., add more layers to a neural network).
C.Increase the regularization strength.
D.Gather more training data.
Correct Answer: Increase the regularization strength.
Explanation:
The described learning curve is a classic sign of high variance (overfitting). The model has learned the training data very well but fails to generalize to the validation data. Using a more complex model would worsen overfitting. Gathering more data could help, but it is often expensive and time-consuming. Increasing regularization strength (e.g., L1 or L2) or decreasing the number of features are direct methods to reduce model complexity and combat overfitting. Increasing regularization is often the most straightforward and effective first step to try.
Incorrect! Try again.
46In a binary classification problem for detecting a rare disease (1% prevalence), model A has an AUROC of 0.85 and an AUPRC of 0.60. Model B has an AUROC of 0.82 and an AUPRC of 0.70. Which model is likely more useful in a practical clinical setting and why?
Evaluation Metrics
Hard
A.Model B, because a higher AUPRC indicates it makes fewer false positive predictions.
B.Model A, because AUROC (Area Under Receiver Operating Characteristic Curve) is a more comprehensive measure of a classifier's performance across all thresholds.
C.Model A, because it has a higher AUROC, indicating better overall separability of the classes.
D.Model B, because AUPRC (Area Under Precision-Recall Curve) is more informative than AUROC for highly imbalanced datasets.
Correct Answer: Model B, because AUPRC (Area Under Precision-Recall Curve) is more informative than AUROC for highly imbalanced datasets.
Explanation:
For imbalanced datasets, AUROC can be misleadingly optimistic. This is because the large number of true negatives (healthy patients) inflates the true negative rate, which is a component of the ROC curve (Specificity = TN / (TN + FP)). The Precision-Recall (PR) curve does not depend on true negatives and focuses on the performance of the positive class. AUPRC is therefore a better indicator of performance on a rare-class detection task. Since Model B has a significantly higher AUPRC, it is likely the more practical and useful model.
Incorrect! Try again.
47Given NumPy arrays W with shape (10, 5), X with shape (100, 10), and b with shape (5,). Which of the following expressions correctly computes the product and results in an array of shape (100, 5)?
Numpy Matrix operations
Hard
A.W.T @ X + b
B.X @ W.T + b
C.X.T @ W + b
D.np.dot(W, X) + b
Correct Answer: X @ W.T + b
Explanation:
Let's analyze the shapes: X is (100, 10), W is (10, 5), so W.T is (5, 10). The matrix multiplication requires the inner dimensions to match. For X @ W.T, the shapes are (100, 10) and (10, 5). The inner dimensions (10 and 10) match, and the resulting shape is (100, 5). The bias vector b has shape (5,). Due to broadcasting, it can be added to the (100, 5) matrix, where it is effectively added to each of the 100 rows. The other options result in shape mismatches or incorrect computations.
Incorrect! Try again.
48You are building a model to predict customer churn. The dataset contains multiple transactions for each customer. Why would a simple random train_test_split on the transaction level be a critical mistake?
Train-Test data split
Hard
A.It will not work because train_test_split requires a 1D array of labels, not grouped data.
B.It leads to data leakage, as transactions from the same customer could end up in both the training and testing sets, violating the independence assumption.
C.It would create an imbalanced dataset, making the model biased towards customers with more transactions.
D.It is computationally inefficient compared to splitting at the customer level.
Correct Answer: It leads to data leakage, as transactions from the same customer could end up in both the training and testing sets, violating the independence assumption.
Explanation:
The fundamental unit of analysis is the customer, not the transaction. If you split randomly at the transaction level, it's highly likely that some transactions from a single customer will be in your training set while others from the same customer are in your test set. The model could then learn customer-specific patterns (like a customer ID implicitly) rather than generalizable churn behaviors. This is a form of data leakage, and the model's performance on the test set will be unrealistically high because it has already 'seen' the customers in the test set during training.
Incorrect! Try again.
49A team is tasked with creating a system that can understand natural language queries, reason about the user's intent, and automatically compose a complex SQL query to retrieve data from a database. The core of this system, which involves understanding and reasoning, falls most squarely under the definition of:
Difference between ML, AI and Data Science
Hard
A.Machine Learning (ML)
B.Data Science
C.Artificial Intelligence (AI)
D.Statistical Modeling
Correct Answer: Artificial Intelligence (AI)
Explanation:
While this system would likely use Machine Learning components (e.g., for NLP), the overall goal described—understanding, reasoning, and automated action—aligns with the broader definition of Artificial Intelligence. AI is the science of making machines that can think and act like humans, encompassing areas like knowledge representation, reasoning, and planning. ML is a subset of AI focused on learning patterns from data. Data Science is a broader field that uses scientific methods, including ML and AI, to extract insights from data, but the core task of 'reasoning and composing a query' is a classic AI problem.
Incorrect! Try again.
50When implementing a machine learning pipeline that includes feature scaling (e.g., Standardization) and k-fold cross-validation, what is the correct procedure to prevent data leakage?
Machine Learning Workflow
Hard
A.The scaling transformer should be fit separately on the training fold and the validation fold to best represent the statistics of each fold.
B.The scaling transformer should be fit on the entire dataset (training + test) before any splitting to ensure all data is on the same scale.
C.The scaling transformer should be fit on the entire training dataset (before splitting into folds) to get a stable estimate of mean and standard deviation.
D.The scaling transformer should be fit on the training fold's data only and then used to transform both the training fold and the validation fold.
Correct Answer: The scaling transformer should be fit on the training fold's data only and then used to transform both the training fold and the validation fold.
Explanation:
To prevent data leakage, any information from the validation set (or test set) must not be used to train the model or any preprocessing step. In k-fold cross-validation, for each fold, the scaler must be 'fit' (i.e., calculate mean and standard deviation) only on the k-1 training partitions. This same fitted scaler is then used to 'transform' both the training partitions and the single validation partition. Fitting the scaler on the entire dataset would leak information about the distribution of the validation/test data into the training process, leading to overly optimistic performance estimates.
Incorrect! Try again.
51Consider the following NumPy code snippet:
python
import numpy as np
np.random.seed(42)
arr1 = np.random.randint(0, 10, 3)
Which of the following statements about the arrays arr1, arr2, and arr3 is true?
Numpy Random Module
Hard
A.All three arrays are different from each other.
B.arr2 and arr3 are identical, but arr1 is different.
C.All three arrays (arr1, arr2, arr3) are identical.
D.arr1 and arr2 are identical, but arr3 is different.
Correct Answer: arr1 and arr2 are identical, but arr3 is different.
Explanation:
The function np.random.seed() resets the state of the pseudo-random number generator (PRNG). The first block sets the seed to 42 and generates arr1. The second block resets the seed back to 42 and then generates arr2. Because the PRNG was reset to the same starting state, the sequence of numbers generated will be identical, making arr1 and arr2 equal. The generation of arr3 happens immediately after arr2without resetting the seed. Therefore, it will draw the next set of numbers from the sequence, making arr3 different from arr2 (and arr1).
Incorrect! Try again.
52Logistic Regression (LR) models the posterior probability directly, while Gaussian Naive Bayes (GNB) models the class conditional probability and the prior . Which statement correctly identifies a key theoretical difference in their resulting decision boundaries?
Generative vs Discriminative Models
Hard
A.LR produces a probabilistic boundary, while GNB produces a deterministic boundary based on Bayes' rule.
B.Both models are guaranteed to produce linear decision boundaries in the original feature space.
C.LR always produces a linear decision boundary, whereas GNB can produce a quadratic decision boundary if the class conditional covariances are different.
D.GNB always produces a linear decision boundary, whereas LR can produce a non-linear decision boundary using polynomial features.
Correct Answer: LR always produces a linear decision boundary, whereas GNB can produce a quadratic decision boundary if the class conditional covariances are different.
Explanation:
A standard Logistic Regression model fits a linear equation to the log-odds, resulting in a linear decision boundary in the feature space. While you can add polynomial features to make it non-linear, the model itself is linear. Gaussian Naive Bayes models each class conditional as a Gaussian. The decision boundary is where . The log of this ratio results in a function that is quadratic in if the covariance matrices for each class are different. If the covariance matrices are assumed to be identical (a common variant is Linear Discriminant Analysis), the quadratic terms cancel out, and the boundary becomes linear. Therefore, GNB can inherently produce a quadratic boundary while standard LR cannot.
Incorrect! Try again.
53In Ridge Regression, the cost function is . How does increasing the regularization parameter from zero affect the bias and variance of the model?
Bias-Variance Trade-off
Hard
A.Both bias and variance increase.
B.Bias decreases and variance increases.
C.Bias increases and variance decreases.
D.Both bias and variance decrease.
Correct Answer: Bias increases and variance decreases.
Explanation:
Increasing adds a larger penalty for the magnitude of the model coefficients (). This forces the coefficients towards zero, making the model simpler and less sensitive to the specific training data points. This reduction in sensitivity to the training data directly leads to a decrease in variance. However, by constraining the coefficients, the model may no longer be able to capture the true underlying relationship in the data, thus moving its average prediction away from the true value. This introduces a systematic error, which means the bias increases.
Incorrect! Try again.
54You have a 3D array of RGB pixel values pixels with shape (1920, 1080, 3) and a 1D array weights with shape (3,) representing weights for the R, G, and B channels. You want to compute a weighted sum for each pixel to convert the image to grayscale, resulting in a 2D array of shape (1920, 1080). Which of the following is the most efficient and correct NumPy expression?
Numpy Broadcasting Rule
Hard
A.np.dot(pixels, weights)
B.np.sum(pixels * weights, axis=2)
C.A loop: result = np.zeros((1920, 1080)); for i in range(3): result += pixels[:,:,i] * weights[i]
D.pixels @ weights
Correct Answer: np.dot(pixels, weights)
Explanation:
Both np.dot(pixels, weights) and pixels @ weights are designed for this operation. For a 3D array (M,N,K) and a 1D array (K,), np.dot and @ perform a sum product over the last axis of the first array and the only axis of the second. pixels is (1920, 1080, 3) and weights is (3,). The operation np.dot(pixels, weights) correctly computes the sum product over the last axis (the channel axis), resulting in an array of shape (1920, 1080). The option np.sum(pixels * weights, axis=2) is also correct and readable, but np.dot is often more optimized for this specific linear algebra operation. The loop is correct but highly inefficient in NumPy. Between the given choices, np.dot is the canonical way to perform this tensor contraction.
Incorrect! Try again.
55Why is the F1-score considered a more balanced measure for imbalanced classification tasks compared to accuracy?
Overview of Evaluation Metrics
Hard
A.F1-score is an arithmetic mean of precision and recall, which gives equal importance to both false positives and false negatives.
B.F1-score is the harmonic mean of precision and recall, which is more sensitive to low values in either metric than the arithmetic mean, thus penalizing models that excel at one at the expense of the other.
C.F1-score incorporates the True Negative rate, which is ignored by accuracy, making it more robust to class imbalance.
D.F1-score is calculated from the area under the ROC curve, which is inherently balanced across all classification thresholds.
Correct Answer: F1-score is the harmonic mean of precision and recall, which is more sensitive to low values in either metric than the arithmetic mean, thus penalizing models that excel at one at the expense of the other.
Explanation:
Accuracy can be misleading in imbalanced datasets. A model could achieve 99% accuracy by simply predicting the majority class every time. The F1-score is defined as . This is the harmonic mean of precision and recall. A key property of the harmonic mean is that it is dominated by the smaller value. Therefore, to achieve a high F1-score, a model must have both high precision and high recall. It cannot 'game' the metric by, for example, having perfect precision but near-zero recall, which would result in a very low F1-score. This property makes it a much more reliable metric for imbalanced classes.
Incorrect! Try again.
56You have trained two logistic regression models on a high-dimensional dataset that is prone to overfitting. Model A uses L1 regularization (Lasso) and Model B uses L2 regularization (Ridge). After tuning, both achieve similar cross-validation scores. What is the most likely difference in the learned coefficient vectors of the two models?
Overfitting and Underfitting
Hard
A.Model B's coefficient vector will likely be sparse, while Model A's will have small, non-zero values.
B.Both models will have sparse coefficient vectors, but Model A's non-zero coefficients will be larger.
C.Both models will have dense coefficient vectors with small values, but Model B's coefficients will be smaller on average.
D.Model A's coefficient vector will likely be sparse (many zeros), while Model B's will have many small, non-zero values.
Correct Answer: Model A's coefficient vector will likely be sparse (many zeros), while Model B's will have many small, non-zero values.
Explanation:
A key difference between L1 and L2 regularization is their effect on model coefficients. L1 regularization adds a penalty proportional to the absolute value of the coefficients (). Due to the geometry of its constraint region (a diamond shape), it tends to shrink some coefficients to exactly zero, performing implicit feature selection. This results in a sparse model. L2 regularization adds a penalty proportional to the squared value of the coefficients (). Its circular constraint region shrinks all coefficients towards zero but rarely sets them to exactly zero. This results in a dense model with small coefficient values.
Incorrect! Try again.
57What is the output of the following NumPy code snippet?
python
import numpy as np
arr = np.arange(12).reshape(4, 3)
idx = np.array([[0, 2], [1, 1]])
result = arr[np.arange(2)[:, np.newaxis], idx]
print(result.shape)
Creating Arrays
Hard
A.(2, 2)
B.(2, 1, 2)
C.The code will raise an IndexError.
D.(2,)
Correct Answer: (2, 2)
Explanation:
This is an example of advanced or 'fancy' indexing. Let's break it down:
arr is a (4, 3) array.
np.arange(2)[:, np.newaxis] creates a column vector [[0], [1]] with shape (2, 1). This will be used to select the rows.
idx is an array [[0, 2], [1, 1]] with shape (2, 2). This will be used to select the columns.
NumPy broadcasts these two index arrays against each other. The (2, 1) row index array is broadcast to (2, 2) to match the column index array. The result is a selection of elements at coordinates (row_indices[i,j], col_indices[i,j]).
For the first row of the output (i=0), it uses row index 0 and column indices [0, 2]. This selects arr[0, 0] and arr[0, 2].
For the second row of the output (i=1), it uses row index 1 and column indices [1, 1]. This selects arr[1, 1] and arr[1, 1].
The shape of the output is determined by the shape of the broadcasted index arrays, which is (2, 2).
Incorrect! Try again.
58A financial company wants to develop a system that groups its clients into distinct segments based on their transaction history, income level, and investment portfolio without any pre-existing labels for these segments. Once segmented, the company's analysts will examine these groups to create targeted marketing strategies. This task is a clear example of:
Types of Machine Learning
Hard
A.Semi-supervised Learning, as analysts will label the data later.
The key phrase is 'without any pre-existing labels'. The goal is to discover inherent structure (the client segments) in the data itself. This is the definition of Unsupervised Learning. More specifically, the task of grouping data points into segments is called clustering. Supervised learning would require pre-labeled data (e.g., a dataset where clients are already labeled as 'high-value', 'at-risk', etc.). Reinforcement learning involves an agent learning through rewards and penalties, which is not applicable here. While analysts will eventually interpret the clusters (giving them meaning), the machine learning task itself is purely unsupervised.
Incorrect! Try again.
59Anomaly detection systems, such as those used for identifying fraudulent credit card transactions, often face the 'concept drift' problem. What is concept drift in this context, and why does it necessitate a specific approach to model maintenance?
Applications and Use-cases of ML
Hard
A.Concept drift describes the natural degradation of the software and hardware infrastructure hosting the model.
B.Concept drift refers to the increasing computational cost of re-training the model as more data is collected.
C.Concept drift is the tendency for models to become biased towards the majority class (non-fraudulent transactions) over time.
D.Concept drift is when the statistical properties of the target variable (fraud) change over time, requiring the model to be continuously retrained or updated on new data.
Correct Answer: Concept drift is when the statistical properties of the target variable (fraud) change over time, requiring the model to be continuously retrained or updated on new data.
Explanation:
Concept drift means that the underlying relationship between input features and the target variable changes over time. In fraud detection, this happens because fraudsters constantly change their tactics to evade detection. A model trained on data from last year may not be effective today because the patterns of what constitutes 'fraud' have evolved. This necessitates a robust MLOps strategy involving continuous monitoring of model performance and frequent retraining on recent data to adapt to these changing patterns. A static model would quickly become obsolete.
Incorrect! Try again.
60What is the primary risk of performing hyperparameter tuning (e.g., using GridSearch CV) on the entire dataset before creating a final train-test split?
Machine Learning Workflow
Hard
A.It will always lead to a model that underfits the data because the hyperparameters are not optimized for the specific training data.
B.It is computationally infeasible as hyperparameter tuning requires a separate validation set which is not available.
C.It causes data leakage from the eventual test set into the hyperparameter selection process, leading to an overly optimistic evaluation of the final model's performance.
D.It violates the assumption of IID (Independently and Identically Distributed) data required by most machine learning algorithms.
Correct Answer: It causes data leakage from the eventual test set into the hyperparameter selection process, leading to an overly optimistic evaluation of the final model's performance.
Explanation:
The test set must be held out and used only once for the final, unbiased evaluation of the chosen model. Hyperparameter tuning is part of the model selection process. If you perform GridSearchCV on the entire dataset, the cross-validation splits within the grid search will use parts of your eventual test set for training during the tuning process. This means the chosen hyperparameters are optimized to perform well on data that includes your test set. When you later evaluate the 'final' model on that same test set, its performance will be artificially inflated because the model's configuration has already been influenced by that data. The correct workflow is: 1) Split data into train and test sets. 2) Perform hyperparameter tuning (e.g., GridSearchCV) only on the train set. 3) Evaluate the final, best model on the held-out test set.