Linear Regression with Scikit-Learn
- 84Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary objective of the medical-expense machine-learning problem?
What is the primary objective of the medical-expense machine-learning problem?
84 questions
- 1
What is the primary objective of the medical-expense machine-learning problem?
- A
To estimate a new customer's annual medical charges from personal information
- B
To predict whether an insurance company will open a new branch
- C
To classify customers into geographic regions using their medical histories
- D
To determine which hospitals provide the lowest treatment costs
Correct answer
ATo estimate a new customer's annual medical charges from personal information
Explanation
The model uses information such as age, sex, BMI, children, smoking habits, and region to estimate annual medical expenditure for new customers.
- A
- 2
Why would an insurance company use estimated medical expenses when setting premiums?
- A
The estimates replace the need to collect any customer information
- B
The estimates help determine how much to charge customers for insurance
- C
The estimates identify which employees should receive promotions
- D
The estimates determine which customers are legally allowed to apply
Correct answer
BThe estimates help determine how much to charge customers for insurance
Explanation
The estimated annual medical expenditure can be used as a major factor in determining the insurance premium offered to a customer.
- A
- 3
What role does historical customer data play in the medical-expense problem?
- A
It contains predictions that must be copied directly into the new system
- B
It provides only the names of customers who may apply in the future
- C
It eliminates the need to define a target variable for the model
- D
It provides examples linking customer characteristics to actual medical charges
Correct answer
DIt provides examples linking customer characteristics to actual medical charges
Explanation
Historical records contain input features and the actual charges incurred, allowing a model to learn their relationship and predict charges for new customers.
- A
- 4
Which sequence best represents the standard supervised machine-learning workflow described?
- A
Choose a chart, remove all numerical columns, and manually assign predictions
- B
Train on the test set, evaluate on the same rows, and deploy immediately
- C
Create inputs and targets, train a model, make predictions, and measure error
- D
Make predictions, delete the targets, train a model, and ignore the error
Correct answer
CCreate inputs and targets, train a model, make predictions, and measure error
Explanation
The workflow consists of preparing inputs and targets, fitting a model, generating predictions, and evaluating those predictions against known targets.
- A
- 5
Why should a test set generally be kept separate from model training?
- A
It replaces the need for a validation set during experimentation
- B
It allows the model to memorize the examples before evaluation
- C
It ensures that every feature is converted into a categorical variable
- D
It provides an unbiased estimate of performance on previously unseen data
Correct answer
DIt provides an unbiased estimate of performance on previously unseen data
Explanation
A test set should remain unused until the end so that its performance reflects how the model may perform on unseen real-world data.
- A
- 6
What is overfitting?
- A
A model performs poorly on both training data and unseen data
- B
A model always predicts the most frequent target class
- C
A model uses too few features to represent any useful relationship
- D
A model performs very well on training data but poorly on unseen data
Correct answer
DA model performs very well on training data but poorly on unseen data
Explanation
Overfitting occurs when a model memorizes training examples or noise instead of learning relationships that generalize to new examples.
- A
- 7
What is the usual purpose of a validation set?
- A
To provide hidden labels for a public competition leaderboard
- B
To compare model versions and tune choices during development
- C
To replace the training set after the model has been fitted
- D
To guarantee that the model will never make a false prediction
Correct answer
BTo compare model versions and tune choices during development
Explanation
The validation set is used during experimentation to compare models, hyperparameters, preprocessing choices, and other development decisions.
- A
- 8
Why is a time-based split preferable to a random split for many time-series problems?
- A
It ensures that all observations from one feature remain together
- B
It guarantees that every class has exactly the same number of examples
- C
It removes the need to evaluate the model on a test set
- D
It prevents the model from using future observations to predict the past
Correct answer
DIt prevents the model from using future observations to predict the past
Explanation
For time-series data, training on earlier dates and evaluating on later dates better simulates future deployment and avoids temporal leakage.
- A
- 9
What distinguishes a regression problem from a classification problem?
- A
Regression predicts categories, whereas classification predicts continuous measurements
- B
Regression predicts continuous values, whereas classification predicts discrete classes
- C
Regression cannot use historical data, whereas classification requires historical data
- D
Regression uses unlabeled data, whereas classification always uses unlabeled data
Correct answer
BRegression predicts continuous values, whereas classification predicts discrete classes
Explanation
Regression predicts quantities such as medical charges or house prices, while classification assigns inputs to classes such as yes/no or benign/malignant.
- A
- 10
Which task is a binary classification problem?
- A
Estimating a customer's annual medical expenditure
- B
Forecasting the selling price of a house
- C
Predicting tomorrow's exact temperature
- D
Predicting whether it will rain tomorrow
Correct answer
DPredicting whether it will rain tomorrow
Explanation
Rain prediction assigns each observation to one of two classes: rain or no rain.
- A
- 11
Which task is a regression problem?
- A
Predicting the exact sales amount for a store
- B
Determining whether a tumor is malignant
- C
Identifying which handwritten digit appears in an image
- D
Assigning customers to high-risk or low-risk groups
Correct answer
APredicting the exact sales amount for a store
Explanation
Store-sales prediction seeks a continuous numerical value, so it is a regression problem.
- A
- 12
What is an example of multiclass classification?
- A
Identifying whether an image represents one of ten handwritten digits
- B
Predicting the temperature at a specific ocean location
- C
Predicting whether a customer smokes or does not smoke
- D
Estimating the annual cost of a medical insurance claim
Correct answer
AIdentifying whether an image represents one of ten handwritten digits
Explanation
Handwritten-digit recognition assigns an image to one of ten classes, from zero through nine.
- A
- 13
What makes a problem supervised learning?
- A
The training data contains no target information at all
- B
The algorithm must always create exactly two clusters
- C
The model is written entirely with manually coded rules
- D
The training data includes target labels or values to learn from
Correct answer
DThe training data includes target labels or values to learn from
Explanation
Supervised learning uses labeled examples, such as known rain outcomes or known medical charges.
- A
- 14
What is the main goal of unsupervised learning?
- A
To maximize training accuracy on a labeled test set
- B
To discover structure or patterns in data without target labels
- C
To predict a known target using labeled historical examples
- D
To replace every numerical feature with a binary feature
Correct answer
BTo discover structure or patterns in data without target labels
Explanation
Unsupervised learning works without labels and is commonly used for clustering, dimensionality reduction, and discovering structure.
- A
- 15
Which task is most naturally unsupervised?
- A
Predicting annual medical charges from customer characteristics
- B
Classifying a tumor as benign or malignant
- C
Grouping mall customers into segments without predefined segment labels
- D
Predicting whether a loan applicant will repay the loan
Correct answer
CGrouping mall customers into segments without predefined segment labels
Explanation
Customer segmentation can group observations without known labels, making it an unsupervised clustering task.
- A
- 16
What relationship does a simple linear regression model assume?
- A
The target is generated by repeatedly grouping similar observations
- B
The target is determined only by the nearest training example
- C
The target is a weighted combination of the input features plus an intercept
- D
The target is always one of two categorical labels
Correct answer
CThe target is a weighted combination of the input features plus an intercept
Explanation
Linear regression models the target as a linear combination of features, with learned weights and an intercept.
- A
- 17
In a one-feature linear regression model, what does the slope represent?
- A
The percentage of predictions that belong to the positive class
- B
The predicted target value when every feature equals zero
- C
The rate at which the predicted target changes as the feature changes
- D
The average distance between all training observations
Correct answer
CThe rate at which the predicted target changes as the feature changes
Explanation
The slope determines how much the predicted target changes for a change in the input feature.
- A
- 18
In a linear regression equation, what does the intercept represent?
- A
The number of features used to train the model
- B
The average error produced by the model on the training set
- C
The highest possible value of the target variable
- D
The predicted target value when the input feature is zero
Correct answer
DThe predicted target value when the input feature is zero
Explanation
The intercept is the point where the fitted line crosses the target axis, corresponding to a zero input.
- A
- 19
What are the input and target in the one-feature medical-charge example?
- A
Age is the input and medical charges are the target
- B
Medical charges are the input and age is the target
- C
Region is the input and BMI is the target
- D
Smoking status is the input and region is the target
Correct answer
AAge is the input and medical charges are the target
Explanation
The model uses age to estimate the annual medical charges.
- A
- 20
Why can adding BMI produce little improvement in a non-smoker medical-charge model?
- A
BMI has a weak observed relationship with charges in that subset
- B
BMI automatically replaces the age feature during training
- C
BMI cannot be represented as a numerical feature
- D
BMI is always identical for every customer in the dataset
Correct answer
ABMI has a weak observed relationship with charges in that subset
Explanation
The content reports a weak correlation between BMI and charges for non-smokers, so adding BMI changes the loss very little.
- A
- 21
What is a residual in regression?
- A
The average value of every input feature in the dataset
- B
The number of features that were removed before training
- C
The difference between an actual target and its model prediction
- D
The distance between two cluster centers
Correct answer
CThe difference between an actual target and its model prediction
Explanation
A residual measures how far a prediction is from the corresponding actual target.
- A
- 22
Why are residuals squared when computing mean squared error?
- A
Squaring converts categorical labels into numerical features
- B
Squaring guarantees that every prediction equals the target
- C
Squaring removes all outliers from the dataset automatically
- D
Squaring prevents positive and negative errors from canceling out
Correct answer
DSquaring prevents positive and negative errors from canceling out
Explanation
Positive and negative residuals could otherwise cancel, making a bad model appear accurate.
- A
- 23
What does root mean squared error measure?
- A
The proportion of rows assigned to the largest cluster
- B
The typical magnitude of prediction error in the target's units
- C
The number of decision-tree leaves in a trained model
- D
The percentage of categorical values converted to one-hot vectors
Correct answer
BThe typical magnitude of prediction error in the target's units
Explanation
RMSE summarizes how far predictions are from actual targets and returns to the original target units after taking the square root.
- A
- 24
How does root mean absolute error differ from root mean squared error?
- A
Absolute error always produces a larger value than squared error
- B
Absolute error can only be used for classification problems
- C
Absolute error gives less extra emphasis to large outliers than squared error
- D
Absolute error requires categorical features to be one-hot encoded
Correct answer
CAbsolute error gives less extra emphasis to large outliers than squared error
Explanation
Squaring makes large errors contribute disproportionately, whereas absolute error uses their magnitudes without squaring.
- A
- 25
Which optimization method is described as directly solving for the best linear-regression parameters on small datasets?
- A
Ordinary least squares
- B
One-hot encoding
- C
Bootstrap aggregation
- D
Mini-batch clustering
Correct answer
AOrdinary least squares
Explanation
Ordinary least squares uses direct matrix operations and works well for relatively small datasets.
- A
- 26
Why is stochastic gradient descent useful for large datasets?
- A
It iteratively improves parameters without requiring the same direct matrix computation
- B
It guarantees perfect predictions after one update
- C
It converts every categorical feature into a single class
- D
It removes the need for a target column during training
Correct answer
AIt iteratively improves parameters without requiring the same direct matrix computation
Explanation
Stochastic gradient descent uses an iterative approach and is better suited to very large datasets than direct least-squares calculations.
- A
- 27
How does logistic regression differ from linear regression for binary classification?
- A
It uses cluster centers instead of learned feature weights
- B
It applies a sigmoid function so the output can be interpreted as a probability
- C
It removes all input features and predicts only the majority class
- D
It replaces the target with a continuous medical-charge value
Correct answer
BIt applies a sigmoid function so the output can be interpreted as a probability
Explanation
Logistic regression first forms a weighted sum and then passes it through the sigmoid function, producing a value between zero and one.
- A
- 28
What does the sigmoid function do in logistic regression?
- A
It forces every prediction to equal exactly zero or one
- B
It squashes the weighted sum into the range from zero to one
- C
It converts every categorical input into a separate column
- D
It calculates the distance between two geographic locations
Correct answer
BIt squashes the weighted sum into the range from zero to one
Explanation
The sigmoid maps the model's linear output to a value between zero and one, which is interpreted as a class probability.
- A
- 29
What loss function is commonly associated with logistic regression in the lesson?
- A
Root mean squared error only
- B
Cross-entropy loss
- C
The inertia of a clustering model
- D
The Gini score of a decision-tree split
Correct answer
BCross-entropy loss
Explanation
The lesson describes cross-entropy as the loss used to compare predicted probabilities with binary target values.
- A
- 30
How should a logistic-regression probability be interpreted for rain prediction?
- A
As the model's estimated probability that rain will occur
- B
As the percentage of training rows that were removed
- C
As the distance from the weather station to the nearest cloud
- D
As the number of millimeters of rainfall already observed
Correct answer
AAs the model's estimated probability that rain will occur
Explanation
For a rain/no-rain problem, the sigmoid output represents the model's estimated probability of rain.
- A
- 31
What does a confusion matrix distinguish in a binary classifier?
- A
Core points, edge points, centroids, and noise points
- B
Means, medians, standard deviations, and quartiles
- C
Training rows, validation rows, test rows, and duplicate rows
- D
True positives, true negatives, false positives, and false negatives
Correct answer
DTrue positives, true negatives, false positives, and false negatives
Explanation
A confusion matrix breaks predictions down by whether the actual and predicted classes agree or disagree.
- A
- 32
What is a false negative in the rain-prediction example?
- A
The model predicts no rain when it actually rains
- B
The model predicts rain when rain occurs
- C
The model predicts rain when it actually does not rain
- D
The model predicts no rain when no rain occurs
Correct answer
AThe model predicts no rain when it actually rains
Explanation
A false negative occurs when the actual class is positive, such as rain, but the model predicts the negative class.
- A
- 33
Why might accuracy be misleading for the Australian rain dataset?
- A
The dataset contains only numerical features
- B
The test set contains more labels than the training set
- C
The model produces no predictions for the training set
- D
The no-rain class is much more common than the rain class
Correct answer
DThe no-rain class is much more common than the rain class
Explanation
Because the classes are imbalanced, a model can obtain high accuracy by predicting no rain frequently while still missing many rainy days.
- A
- 34
What is the purpose of imputing missing values?
- A
To convert predictions into probabilities after training
- B
To increase the number of categorical classes automatically
- C
To replace missing entries with usable values before model training
- D
To remove the target column from every dataset
Correct answer
CTo replace missing entries with usable values before model training
Explanation
Many machine-learning algorithms cannot train with missing values, so imputation fills them using a chosen strategy.
- A
- 35
Why might the median be preferred over the mean for imputing income?
- A
The median converts income into a categorical feature
- B
The median automatically preserves every missing value
- C
The median can only be calculated for binary variables
- D
The median is less affected by extreme income outliers
Correct answer
DThe median is less affected by extreme income outliers
Explanation
Highly skewed variables such as income can have outliers that distort the mean, making the median more representative.
- A
- 36
What is the main purpose of feature scaling?
- A
To ensure that the model uses the target as an input
- B
To place numerical features on comparable ranges during optimization
- C
To guarantee that every feature has a positive correlation
- D
To remove all categorical columns from the original dataset
Correct answer
BTo place numerical features on comparable ranges during optimization
Explanation
Features with large numeric ranges can dominate loss calculations and optimization, so scaling gives features a more equal influence.
- A
- 37
What does a min-max scaler generally do?
- A
It maps each numerical feature into a specified range such as zero to one
- B
It replaces each feature with its median category
- C
It creates a separate decision tree for every feature
- D
It converts a target label into a confusion matrix
Correct answer
AIt maps each numerical feature into a specified range such as zero to one
Explanation
Min-max scaling uses each feature's minimum and maximum to transform its values into a common range.
- A
- 38
What is one-hot encoding?
- A
Replacing every category with the same numerical mean
- B
Removing categorical columns before model training
- C
Sorting all categories according to their frequency
- D
Representing each category with its own binary indicator column
Correct answer
DRepresenting each category with its own binary indicator column
Explanation
One-hot encoding creates a column for each category, with a one indicating the applicable category and zeros elsewhere.
- A
- 39
When can an ordered categorical feature reasonably be mapped to numbers?
- A
When the categories have a meaningful natural order related to the target
- B
When the feature is already the target column
- C
When the categories are arbitrary geographic names
- D
When every category occurs exactly once in the dataset
Correct answer
AWhen the categories have a meaningful natural order related to the target
Explanation
Ordered categories such as cold, warm, and hot may be mapped to numbers when their order has meaningful predictive significance.
- A
- 40
Why should target-derived columns be excluded from model inputs?
- A
They make one-hot encoding mathematically impossible
- B
They prevent the use of any numerical features
- C
They can leak information unavailable when the model is used in practice
- D
They always reduce the number of available training examples
Correct answer
CThey can leak information unavailable when the model is used in practice
Explanation
A feature derived from the target may give the model information it would not have at prediction time, producing misleadingly high performance.
- A
- 41
What does a decision tree represent?
- A
A hierarchy of binary decisions leading to a final prediction
- B
A sequence of random predictions that ignores the inputs
- C
A weighted average of every feature with no conditional branching
- D
A collection of unrelated cluster centers
Correct answer
AA hierarchy of binary decisions leading to a final prediction
Explanation
Decision trees repeatedly apply conditions to divide data until reaching leaf nodes containing predictions.
- A
- 42
How does a decision-tree classifier choose a split conceptually?
- A
It selects the feature with the largest numerical values regardless of labels
- B
It searches for a feature and threshold that produce a good class separation
- C
It chooses a threshold without considering the target classes
- D
It always chooses the first feature in alphabetical order
Correct answer
BIt searches for a feature and threshold that produce a good class separation
Explanation
The tree evaluates candidate features and thresholds and chooses a split that improves class purity according to its criterion.
- A
- 43
What does a low Gini score indicate for a decision-tree split?
- A
The model has no training examples remaining
- B
The split leaves the child groups maximally mixed
- C
The split produces relatively pure child groups
- D
The tree has reached its maximum possible depth
Correct answer
CThe split produces relatively pure child groups
Explanation
A low Gini score means the resulting groups are more homogeneous, while a perfect split has a Gini score of zero.
- A
- 44
Why can an unrestricted decision tree achieve nearly perfect training accuracy?
- A
It automatically removes all difficult examples from the training set
- B
It predicts the majority class for every training observation
- C
It uses the validation labels during every split
- D
It can keep splitting until it effectively memorizes individual training examples
Correct answer
DIt can keep splitting until it effectively memorizes individual training examples
Explanation
A deep tree can create leaf nodes containing individual or nearly individual examples, allowing it to memorize the training data.
- A
- 45
How does limiting maximum tree depth help reduce overfitting?
- A
It makes the model use every available feature at every split
- B
It prevents the tree from creating an excessively detailed hierarchy
- C
It forces every leaf to contain exactly one training example
- D
It guarantees that training accuracy will equal validation accuracy
Correct answer
BIt prevents the tree from creating an excessively detailed hierarchy
Explanation
A depth limit restricts model complexity, encouraging the tree to learn broader patterns instead of memorizing individual examples.
- A
- 46
What is a hyperparameter?
- A
A target value copied from the validation set into the training set
- B
A numerical error produced only after deployment
- C
A category created automatically by one-hot encoding
- D
A modeling choice specified before or during training rather than learned as a model parameter
Correct answer
DA modeling choice specified before or during training rather than learned as a model parameter
Explanation
Values such as maximum depth, number of estimators, and learning rate are hyperparameters selected by the practitioner.
- A
- 47
What is regularization intended to accomplish?
- A
To maximize training accuracy regardless of validation performance
- B
To add the target column to the feature matrix
- C
To remove the need for feature engineering
- D
To reduce overfitting by limiting effective model complexity
Correct answer
DTo reduce overfitting by limiting effective model complexity
Explanation
Regularization constrains a model so that it generalizes better to unseen data, even if training accuracy decreases slightly.
- A
- 48
What is a random forest?
- A
A clustering algorithm that always creates random groups
- B
An ensemble of decision trees whose predictions are combined
- C
A linear model with randomly selected coefficients
- D
A single decision tree with no depth limitation
Correct answer
BAn ensemble of decision trees whose predictions are combined
Explanation
A random forest trains multiple varied decision trees and combines their outputs.
- A
- 49
How does a random forest combine predictions for classification?
- A
It always chooses the prediction of the deepest tree
- B
It typically uses voting among the individual trees
- C
It averages the feature names returned by each tree
- D
It selects the class with the largest numerical label
Correct answer
BIt typically uses voting among the individual trees
Explanation
For classification, the forest commonly returns the class receiving the most votes from its constituent trees.
- A
- 50
How does a random forest combine predictions for regression?
- A
It converts every numerical prediction into a class label
- B
It typically averages the numerical predictions of the trees
- C
It returns the prediction from the first tree only
- D
It chooses the smallest prediction from the forest
Correct answer
BIt typically averages the numerical predictions of the trees
Explanation
For regression, the numerical outputs of the trees are generally averaged.
- A
- 51
Why can combining many varied trees improve generalization?
- A
Averaging guarantees that the training data contains no noise
- B
Different trees make different errors that can partially cancel when combined
- C
The forest removes all observations that individual trees misclassify
- D
Every tree is forced to make exactly the same prediction
Correct answer
BDifferent trees make different errors that can partially cancel when combined
Explanation
Randomization creates diverse trees, and combining their predictions can reduce the effect of individual errors.
- A
- 52
What does the number of estimators control in a random forest?
- A
The number of decision trees in the forest
- B
The maximum number of values in each feature
- C
The number of target classes in the dataset
- D
The percentage of missing values to impute
Correct answer
AThe number of decision trees in the forest
Explanation
The estimators setting determines how many decision trees are trained and combined.
- A
- 53
Why does a random forest use random feature subsets during splits?
- A
To remove all categorical features from the dataset
- B
To guarantee that the most important feature is never selected
- C
To make trees more diverse rather than creating near-identical trees
- D
To force every tree to use only one feature
Correct answer
CTo make trees more diverse rather than creating near-identical trees
Explanation
Randomly selecting candidate features for splits increases diversity among trees and supports the ensemble's error-cancellation effect.
- A
- 54
What is bootstrapping in a random forest?
- A
Selecting only the target column for each tree
- B
Removing every duplicate row before training
- C
Training every tree on the exact same complete dataset
- D
Training each tree on a random sample drawn with replacement
Correct answer
DTraining each tree on a random sample drawn with replacement
Explanation
Bootstrapping creates varied training samples by randomly selecting rows with replacement for individual trees.
- A
- 55
What is the wisdom-of-the-crowd analogy intended to illustrate?
- A
One expert's prediction is always better than all other predictions
- B
Different predictions should never be combined
- C
Averaging many imperfect estimates can produce a strong overall estimate
- D
Random guesses become exact when only two people participate
Correct answer
CAveraging many imperfect estimates can produce a strong overall estimate
Explanation
The analogy illustrates how combining diverse imperfect predictions can be more reliable than relying on one predictor.
- A
- 56
What is gradient boosting's initial prediction for every input in the described regression process?
- A
A randomly selected target from the test set
- B
The largest feature value in each input row
- C
The prediction of the deepest possible decision tree
- D
The average value of the target column
Correct answer
DThe average value of the target column
Explanation
Gradient boosting begins by predicting the average target value for all observations.
- A
- 57
What does each subsequent tree in gradient boosting attempt to predict?
- A
The average value of every categorical column
- B
The class labels of a separate validation set
- C
The original input features without transformation
- D
The residual errors left by the current combined model
Correct answer
DThe residual errors left by the current combined model
Explanation
Each new tree is trained to correct the errors remaining after the previous predictions.
- A
- 58
What is the learning rate in gradient boosting used for?
- A
To convert regression targets into binary labels
- B
To scale each new tree's contribution to the combined prediction
- C
To determine the number of categorical features in the dataset
- D
To select the initial average target value
Correct answer
BTo scale each new tree's contribution to the combined prediction
Explanation
The learning rate controls how strongly each newly trained tree changes the existing model.
- A
- 59
Why can a lower learning rate require more boosting iterations?
- A
A lower learning rate increases the number of target classes
- B
A lower learning rate removes all residual information
- C
Each tree becomes unable to use any input features
- D
Each tree makes a smaller update, so more updates are needed
Correct answer
DEach tree makes a smaller update, so more updates are needed
Explanation
Smaller updates improve the model more gradually, often requiring more trees to reach a comparable fit.
- A
- 60
Why is gradient boosting called boosting?
- A
The algorithm boosts the number of missing values before training
- B
New models are added to improve or correct an existing model
- C
The algorithm always increases every feature value
- D
It combines only identical models without sequential dependence
Correct answer
BNew models are added to improve or correct an existing model
Explanation
Boosting refers to sequentially adding models whose purpose is to improve the current combined predictor.
- A
- 61
How does gradient boosting differ from random forests?
- A
Boosting uses no trees, while random forests use only linear regression
- B
Boosting trees correct previous errors, while forest trees are generally trained independently
- C
Boosting requires unlabeled data, while random forests require no data
- D
Boosting averages identical trees, while random forests train one tree
Correct answer
BBoosting trees correct previous errors, while forest trees are generally trained independently
Explanation
Gradient boosting builds trees sequentially to correct residuals, whereas random forests combine independently trained randomized trees.
- A
- 62
What does feature engineering involve?
- A
Using the test target to construct new training columns
- B
Transforming, combining, or augmenting existing data to create more useful features
- C
Replacing the model with a manually written prediction rule
- D
Removing every feature that has a nonzero correlation with the target
Correct answer
BTransforming, combining, or augmenting existing data to create more useful features
Explanation
Feature engineering creates representations that make it easier for a model to learn useful relationships.
- A
- 63
Why can extracting year, month, day, and hour from a date improve a model?
- A
It guarantees that all dates become categorical targets
- B
It exposes temporal patterns that a raw date string may hide
- C
It removes the need for a validation set
- D
It prevents the model from learning seasonal behavior
Correct answer
BIt exposes temporal patterns that a raw date string may hide
Explanation
Separate date components allow models to learn patterns associated with seasons, weekdays, times of day, and calendar periods.
- A
- 64
Why might store sales be modeled separately from days when the store is closed?
- A
Closed stores contain the most useful sales variation
- B
A model cannot accept any rows containing a store identifier
- C
Removing closed stores guarantees perfect future predictions
- D
Closed stores have zero sales by rule, so the model need not learn that relationship
Correct answer
DClosed stores have zero sales by rule, so the model need not learn that relationship
Explanation
If sales are always zero when a store is closed, that case can be handled directly instead of spending model capacity learning it.
- A
- 65
What is a baseline model used for?
- A
To provide a simple benchmark that more sophisticated models should beat
- B
To guarantee the final model has no errors
- C
To replace the need for a business-defined evaluation metric
- D
To train the model using only the test set
Correct answer
ATo provide a simple benchmark that more sophisticated models should beat
Explanation
Simple baselines, such as always predicting the mean or majority class, establish a reference point for evaluating more complex approaches.
- A
- 66
Why should a machine-learning practitioner compare a model with a dumb baseline?
- A
Comparison with a baseline eliminates the need for testing
- B
A baseline always contains more information than the training data
- C
A complex model may perform no better than a simple rule
- D
A dumb model automatically reveals every causal relationship
Correct answer
CA complex model may perform no better than a simple rule
Explanation
A model is useful only if it improves meaningfully over simple alternatives such as predicting the mean or majority class.
- A
- 67
What is stacking in ensemble learning?
- A
Encoding each feature with a single binary value
- B
Training another model to combine predictions from several base models
- C
Adding more rows to every bootstrap sample
- D
Training one decision tree with progressively deeper branches
Correct answer
BTraining another model to combine predictions from several base models
Explanation
Stacking uses the outputs of multiple models as inputs to a new model that learns how to combine them.
- A
- 68
Why should model results be presented using business-relevant metrics?
- A
Stakeholders need to understand whether the model satisfies the practical objective
- B
Technical loss functions always have direct business meanings
- C
Stakeholders generally use model code instead of model outputs
- D
Business metrics prevent all false positives and false negatives
Correct answer
AStakeholders need to understand whether the model satisfies the practical objective
Explanation
The selected evaluation metric should reflect what the business considers important, such as error magnitude, precision, recall, or operational cost.
- A
- 69
What is the main danger of interpreting correlation as causation?
- A
Causal relationships are determined automatically by scatter plots
- B
A positive correlation always means that one feature causes another
- C
A relationship may arise from a third factor or bias rather than direct cause and effect
- D
Correlation coefficients cannot ever be computed for numerical data
Correct answer
CA relationship may arise from a third factor or bias rather than direct cause and effect
Explanation
Two variables can correlate because one causes the other, the reverse is true, or both are influenced by another variable.
- A
- 70
What does K-means clustering require the practitioner to specify?
- A
The maximum number of categorical features
- B
The exact prediction for every new observation
- C
The target label for every observation
- D
The desired number of clusters
Correct answer
DThe desired number of clusters
Explanation
The K in K-means is the number of clusters the algorithm is instructed to create.
- A
- 71
How does K-means assign an observation to a cluster?
- A
It assigns the observation to the nearest cluster centroid
- B
It assigns every observation to the largest cluster
- C
It assigns observations randomly and never updates them
- D
It uses the first categorical feature as the cluster label
Correct answer
AIt assigns the observation to the nearest cluster centroid
Explanation
K-means compares each observation with the cluster centroids and assigns it to the closest one.
- A
- 72
What is a centroid in K-means clustering?
- A
The target label provided for supervised learning
- B
The number of iterations used by the algorithm
- C
The most distant observation from every other point
- D
The mean position of the observations assigned to a cluster
Correct answer
DThe mean position of the observations assigned to a cluster
Explanation
After assignment, K-means recalculates each cluster center as the dimension-wise mean of its members.
- A
- 73
What does inertia measure in K-means?
- A
The number of labeled examples in the training set
- B
The total within-cluster variation around the cluster centers
- C
The percentage of predictions that are false positives
- D
The maximum depth of an induced decision tree
Correct answer
BThe total within-cluster variation around the cluster centers
Explanation
Inertia summarizes the within-cluster spread; lower values indicate that points are closer to their assigned centroids.
- A
- 74
What is an elbow curve used for in K-means analysis?
- A
To help select a cluster count after inertia begins to level off
- B
To calculate the sigmoid probability for a classification model
- C
To measure the percentage of missing values in a feature
- D
To determine the maximum depth of a decision tree
Correct answer
ATo help select a cluster count after inertia begins to level off
Explanation
The elbow method plots inertia against the number of clusters and looks for a point where additional clusters provide diminishing improvement.
- A
- 75
How does DBSCAN differ fundamentally from K-means?
- A
DBSCAN uses point density and can identify noise without requiring a fixed cluster count
- B
DBSCAN can only cluster labeled data
- C
DBSCAN assigns every point to the nearest mean
- D
DBSCAN always requires exactly three centroids before training
Correct answer
ADBSCAN uses point density and can identify noise without requiring a fixed cluster count
Explanation
DBSCAN uses neighborhood density controlled by parameters such as epsilon and minimum samples, and it can label isolated points as noise.
- A
- 76
What is a core point in DBSCAN?
- A
A point that is farther from every other point than the epsilon radius
- B
A point with at least the required number of neighbors within the epsilon radius
- C
A point that must always be labeled as noise
- D
The mean of all points in a K-means cluster
Correct answer
BA point with at least the required number of neighbors within the epsilon radius
Explanation
A core point satisfies the minimum-neighbor requirement within its epsilon neighborhood.
- A
- 77
What is the purpose of principal component analysis?
- A
To assign every observation to a predefined class
- B
To create a separate decision tree for every feature
- C
To replace all missing values with column means
- D
To reduce dimensionality while preserving as much variance as possible
Correct answer
DTo reduce dimensionality while preserving as much variance as possible
Explanation
PCA projects high-dimensional data onto fewer directions that capture as much of the original variance as possible.
- A
- 78
Why is t-SNE commonly used in machine learning workflows?
- A
It guarantees the best possible clustering for every dataset
- B
It directly predicts continuous target values for deployment
- C
It replaces the need to encode categorical variables
- D
It helps visualize high-dimensional data in two or three dimensions
Correct answer
DIt helps visualize high-dimensional data in two or three dimensions
Explanation
t-SNE is primarily used to visualize local relationships in high-dimensional data after reducing it to a small number of dimensions.
- A
- 79
What is the main purpose of saving preprocessing objects with a trained model?
- A
Saving them guarantees that the model will never overfit
- B
The model cannot make predictions unless the original CSV is deleted
- C
New inputs must undergo the same transformations used during training
- D
Preprocessing objects contain the hidden test labels
Correct answer
CNew inputs must undergo the same transformations used during training
Explanation
The same imputer, scaler, encoder, feature order, and other transformations must be applied to new data before prediction.
- A
- 80
What is the role of a Flask application in the described deployment example?
- A
It trains every possible machine-learning model automatically
- B
It provides a web interface and routes requests to the machine-learning model
- C
It replaces the need to serialize the trained model
- D
It converts all model predictions into database tables
Correct answer
BIt provides a web interface and routes requests to the machine-learning model
Explanation
Flask is used to create a web application that receives user input, applies preprocessing, invokes the model, and returns a result.
- A
- 81
What is an API route in the deployment example?
- A
A URL endpoint that accepts structured data and returns a structured prediction
- B
A special category created during one-hot encoding
- C
A local file that stores the model's training loss
- D
A chart displaying the distribution of feature values
Correct answer
AA URL endpoint that accepts structured data and returns a structured prediction
Explanation
The API route accepts a request, such as JSON containing an email body, and returns a prediction in a machine-readable format.
- A
- 82
Why is a trained model commonly serialized with a tool such as joblib?
- A
To convert a regression model into a clustering model
- B
To increase the number of features available during training
- C
To automatically correct biased training data
- D
To save and reload the model without retraining it from scratch
Correct answer
DTo save and reload the model without retraining it from scratch
Explanation
Serialization stores the trained model and supporting objects so they can be loaded later for prediction or deployment.
- A
- 83
What should be included when saving a deployable machine-learning pipeline?
- A
Only the raw training CSV and the notebook's visualizations
- B
Only the final prediction for the most recent input
- C
The model, preprocessing objects, relevant column names, and feature-order information
- D
Only the validation accuracy and the model's title
Correct answer
CThe model, preprocessing objects, relevant column names, and feature-order information
Explanation
Deployment requires everything needed to transform new inputs in the same way and pass the resulting features to the trained model.
- A
- 84
Why should model projects be documented and published clearly?
- A
Publishing ensures that every model becomes causal rather than correlational
- B
Documentation eliminates the need to test predictions
- C
Publishing automatically increases the model's validation accuracy
- D
Documentation improves understanding and communicates methods and results to others
Correct answer
DDocumentation improves understanding and communicates methods and results to others
Explanation
Explaining the problem, data, features, models, experiments, limitations, and results helps both the practitioner and stakeholders understand the project.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.