Introduction to Machine Learning
- 124Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the main difference between traditional AI problem-solving and machine learning?
124 questions
- 1
What is the main difference between traditional AI problem-solving and machine learning?
Model answer
Traditional AI is given explicit instructions for solving a task, whereas machine learning gives the computer data or patterns from which it learns how to perform the task.
Explanation
Machine learning allows the computer to infer patterns and determine how to perform a task rather than following a fully specified procedure.
- 2
What is supervised learning?
Model answer
Supervised learning is a machine learning task in which the computer receives a dataset of input-output pairs and learns a function that maps inputs to outputs.
Explanation
The output associated with each input provides guidance, or supervision, during training.
- 3
Why are labels important in supervised learning?
Model answer
Labels identify the correct output associated with each input, allowing the computer to learn the relationship between inputs and outputs.
Explanation
For example, a human may label weather data as rainy or not rainy so the model can learn to predict those categories.
- 4
What is the goal of a supervised learning model after training?
Model answer
The goal is to learn a function that can use previously observed relationships to predict outputs for new inputs.
Explanation
A successful model should not merely memorize its training data; it should also generalize to unfamiliar inputs.
- 5
What is classification in supervised learning?
Model answer
Classification is the task of assigning inputs to discrete categories, such as rainy or not rainy and authentic or counterfeit.
Explanation
The model predicts which predefined class best describes each input.
- 6
What is regression in supervised learning?
Model answer
Regression is the task of learning a function that maps inputs to continuous numerical outputs rather than discrete categories.
Explanation
Predicting sales from advertising spending is an example because sales are represented by a real-number value.
- 7
How do classification and regression differ?
Model answer
Classification predicts discrete categories, while regression predicts continuous numerical values.
Explanation
Predicting rain or no rain is classification; predicting the amount of sales is regression.
- 8
How can weather data be structured for supervised classification?
Model answer
Each data point can contain input features such as humidity and air pressure, along with a human-provided label indicating whether it rained.
Explanation
The labeled historical observations allow a model to learn how humidity and pressure relate to rainfall.
- 9
What is a hypothesis function in supervised learning?
Model answer
A hypothesis function, denoted by h, is a model that attempts to approximate the unknown function f that maps inputs to outputs.
Explanation
The actual relationship f is generally unknown, so learning attempts to construct an estimate h that agrees with it as often as possible.
- 10
How does nearest neighbor classification classify a new input?
Model answer
It assigns the new input to the class of the single training data point closest to it.
Explanation
The method assumes that nearby points are likely to belong to the same category.
- 11
Why might a new weather data point be classified as rainy using nearest neighbor classification?
Model answer
It may be classified as rainy if its humidity and pressure values place it closest to a previously observed rainy day.
Explanation
The prediction is based on similarity in the feature space rather than on an explicit weather rule.
- 12
What is the main weakness of using only one nearest neighbor?
Model answer
A single nearby point may be misleading, especially when it is surrounded by many points from another class or is an outlier.
Explanation
Considering only one neighbor ignores the broader pattern of nearby data.
- 13
What does the parameter k represent in k-nearest-neighbor classification?
Model answer
The parameter k specifies how many of the closest training points are considered when classifying a new input.
Explanation
For example, k may be set to 3, 5, or 7 to include multiple neighboring points.
- 14
How does k-nearest-neighbor classification determine the class of an input?
Model answer
It assigns the input to the most common class among its k nearest data points.
Explanation
Each neighbor effectively casts one vote, and the class with the most votes is selected.
- 15
If three of the five nearest neighbors indicate rain and two indicate no rain, what classification does k-nearest-neighbor use?
Model answer
It classifies the input as rainy because the rainy class receives three of the five votes.
Explanation
The algorithm chooses the majority class among the selected neighbors.
- 16
Why can different machine learning algorithms produce different results on the same classification problem?
Model answer
Different algorithms make different assumptions about the data and have different strengths and trade-offs.
Explanation
An algorithm that performs well on one dataset may be less suitable for another, so multiple approaches are often tested.
- 17
What is one computational drawback of a naive nearest neighbor implementation?
Model answer
It may be slow because it must calculate the distance from a new input to every stored data point.
Explanation
Neighbor-search data structures and data-pruning techniques can reduce this computational cost.
- 18
How can the nearest neighbor approach be improved computationally?
Model answer
It can be improved by using data structures that find neighbors efficiently or by removing irrelevant data points.
Explanation
Both strategies reduce the amount of distance computation required for each prediction.
- 19
What is a decision boundary in classification?
Model answer
A decision boundary is a separator that divides the feature space into regions associated with different classes.
Explanation
In two dimensions, a decision boundary may be represented by a line separating rainy and non-rainy observations.
- 20
What does it mean for data to be linearly separable?
Model answer
Data is linearly separable when a line, or its higher-dimensional equivalent, can perfectly divide the classes.
Explanation
Every point from one class lies on one side of the boundary and every point from the other class lies on the other side.
- 21
Why might real-world data fail to be linearly separable?
Model answer
Real-world data may contain noise, outliers, and overlapping observations that prevent any single line from separating the classes perfectly.
Explanation
A useful boundary may still make mostly correct predictions even when some points are misclassified.
- 22
In a weather classification example, what do x1​ and x2​ represent?
Model answer
x1​ represents humidity and x2​ represents air pressure.
Explanation
These variables are input features used by the hypothesis function to predict rain or no rain.
- 23
What is a linear combination of input variables?
Model answer
It is an expression formed by multiplying each input by a weight and adding the results, often with an additional constant term.
Explanation
For two inputs, the expression can be written as w0​+w1​x1​+w2​x2​.
- 24
What do the weights in a linear classification model represent?
Model answer
The weights determine how strongly the input variables influence the prediction and determine the position and slope of the decision boundary.
Explanation
Changing the weights changes the line or boundary used to separate the classes.
- 25
What role does the constant weight w0​ play in a linear classifier?
Model answer
The constant weight allows the boundary to shift upward or downward rather than being fixed in one position.
Explanation
It is included as an intercept term and is multiplied by the constant input 1.
- 26
How can a linear hypothesis classify a data point as rainy or not rainy?
Model answer
It computes w0​+w1​x1​+w2​x2​; a result greater than or equal to 0 can represent rain, while a result below 0 represents no rain.
Explanation
The sign of the weighted sum indicates which side of the decision boundary contains the input.
- 27
Why are classification labels often represented numerically as 1 and 0?
Model answer
Numerical labels make mathematical comparisons and calculations easier; for example, 1 can represent rain and 0 can represent no rain.
Explanation
The numerical outputs can be compared directly with the result of the hypothesis function.
- 28
What are the weight and input vectors in the two-feature example?
Model answer
The weight vector is oldsymbol{w} = (w_0,w_1,w_2) and the input vector is oldsymbol{x} = (1,x_1,x_2).
Explanation
The constant 1 ensures that the intercept weight w0​ has a corresponding input and that both vectors have equal length.
- 29
What is the dot product of the weight and input vectors?
Model answer
The dot product is oldsymbol{w}oldsymbol{oldsymbol{7}}oldsymbol{x} = w_0 + w_1x_1 + w_2x_2.
Explanation
It is calculated by multiplying corresponding vector elements and adding the products.
- 30
Why must the weight and input vectors have the same length for a dot product?
Model answer
Each weight must be paired with a corresponding input value so that all corresponding products can be calculated.
Explanation
The intercept weight is paired with the constant input 1, while the other weights are paired with the feature values.
- 31
What does it mean to say that a hypothesis is parameterized by its weights?
Model answer
It means that the particular function produced by the hypothesis depends on the values chosen for its weights.
Explanation
Different weight vectors produce different decision boundaries and therefore different predictions.
- 32
What is the main idea of the perceptron learning rule?
Model answer
The perceptron learning rule adjusts the model's weights using labeled examples so that future predictions better match the actual labels.
Explanation
The algorithm can begin with arbitrary weights and update them as it processes training examples.
- 33
What happens to the perceptron weights when a data point is classified correctly?
Model answer
The weights remain unchanged because the difference between the actual output and the predicted output is zero.
Explanation
With no prediction error, the update term contributes nothing to the weights.
- 34
What happens when the actual output is greater than the predicted output in a perceptron update?
Model answer
The update is positive, so the relevant weights increase and make a larger future output more likely.
Explanation
The adjustment responds to the error represented by the difference between the actual and predicted values.
- 35
What happens when the actual output is less than the predicted output?
Model answer
The update is negative, so the relevant weights decrease and make a smaller future output more likely.
Explanation
For example, predicting 1 when the true label is 0 should reduce the model's tendency to produce a positive classification.
- 36
What is the learning rate b1 in the perceptron learning rule?
Model answer
The learning rate b1 controls how much the weights change in response to each training example.
Explanation
A larger b1 produces larger updates, while a smaller b1 produces smaller updates.
- 37
What is a threshold function?
Model answer
A threshold function produces one output when its input reaches or exceeds a threshold and another output when its input falls below that threshold.
Explanation
In the classification example, values on one side produce 1 and values on the other side produce 0.
- 38
What limitation does a hard threshold function have?
Model answer
It provides only discrete outcomes and does not express how confident the model is in a prediction.
Explanation
Inputs just above and far above the threshold receive the same output even though they may represent different confidence levels.
- 39
How does logistic regression address the limitation of a hard threshold?
Model answer
It uses a soft logistic function that produces values between 0 and 1 instead of only 0 or 1.
Explanation
Intermediate values, such as 0.7, can indicate a stronger likelihood of one class without absolute certainty.
- 40
Why can a logistic function be interpreted as expressing confidence?
Model answer
Its continuous output between 0 and 1 can represent the estimated likelihood that an input belongs to a particular category.
Explanation
Values near 0 or 1 suggest greater confidence, while intermediate values suggest more uncertainty.
- 41
What is the motivation behind a support vector machine?
Model answer
A support vector machine seeks a decision boundary that separates classes while generalizing well to new data.
Explanation
It avoids choosing a boundary merely because it classifies the available training points correctly.
- 42
What is a maximum-margin separator?
Model answer
A maximum-margin separator is a decision boundary that maximizes the distance between the boundary and the nearest points from the different classes.
Explanation
A larger margin generally provides more tolerance for new points near the boundary and can improve generalization.
- 43
What are support vectors?
Model answer
Support vectors are the data points closest to the decision boundary and are used to determine the margin.
Explanation
The support vector machine attempts to maximize the distance between these critical points and the boundary.
- 44
What is a hyperplane?
Model answer
A hyperplane is the higher-dimensional equivalent of a line used as a decision boundary.
Explanation
Support vector machines can use hyperplanes when inputs have more than two dimensions.
- 45
How can support vector machines help with data that is not linearly separable?
Model answer
They can operate in higher-dimensional spaces where a different boundary, such as a curved boundary in the original space, may separate the classes more effectively.
Explanation
A circular boundary in two dimensions can result from finding a linear separator in a transformed higher-dimensional representation.
- 46
What is the purpose of linear regression in a regression problem?
Model answer
It finds a line that approximates the relationship between input values and continuous output values.
Explanation
For example, a line can estimate sales for a given advertising budget.
- 47
How can advertising data be used in a regression model?
Model answer
Past observations can pair advertising spending with resulting sales, allowing the model to predict sales for a new advertising budget.
Explanation
Advertising spending is the input and sales are the continuous numerical output.
- 48
What is a loss function?
Model answer
A loss function measures how poorly a model's predictions match the actual outputs.
Explanation
The loss for individual examples can be combined to evaluate the overall performance of a hypothesis.
- 49
How is evaluating a hypothesis related to optimization?
Model answer
Evaluating a hypothesis can be treated as minimizing a cost or loss function that measures prediction errors.
Explanation
The goal is to find a hypothesis with a low total loss, analogous to finding a minimum in an optimization problem.
- 50
How does the 0-1 loss function evaluate a classification prediction?
Model answer
It assigns a loss of 0 when the prediction is correct and a loss of 1 when the prediction is incorrect.
Explanation
The function considers whether the predicted category matches the actual category, not how close the prediction was numerically.
- 51
What is empirical loss?
Model answer
Empirical loss is the total loss obtained by adding the individual losses across the observed dataset.
Explanation
For 0-1 loss, it equals the number of misclassified data points.
- 52
How would a classification boundary with four errors be evaluated using 0-1 loss?
Model answer
Its total empirical loss would be 4, because each of the four incorrect classifications contributes a loss of 1.
Explanation
Correctly classified points contribute 0 and do not increase the total.
- 53
Why is 0-1 loss unsuitable for judging how close a regression prediction is?
Model answer
It only distinguishes correct from incorrect outcomes and does not measure the numerical distance between a prediction and the actual value.
Explanation
Regression requires a loss function that recognizes that a small numerical error is better than a large one.
- 54
What is L1​ loss?
Model answer
L1​ loss measures the absolute difference between actual and predicted values, summed across the data points: a3 |y - b7|.
Explanation
It measures how far predictions are from the actual values while treating the magnitude of each error directly.
- 55
What does L1​ loss represent geometrically in an advertising-and-sales graph?
Model answer
It represents the vertical distance between each observed sales value and the value predicted by the regression line.
Explanation
The total loss is found by adding these individual vertical distances.
- 56
What is L2​ loss?
Model answer
L2​ loss measures the squared difference between actual and predicted values, summed across the data points: a3 (y - b7)^2.
Explanation
Squaring the errors makes large errors contribute disproportionately more to the total loss.
- 57
How do L1​ and L2​ loss differ in their treatment of large errors?
Model answer
L1​ loss penalizes errors according to their absolute size, while L2​ loss penalizes large errors more heavily by squaring them.
Explanation
The choice depends on whether large errors or outliers should receive especially strong influence.
- 58
When might L2​ loss be preferred over L1​ loss?
Model answer
L2​ loss may be preferred when it is especially important to minimize large errors.
Explanation
Because errors are squared, unusually poor predictions have a stronger effect on the optimization.
- 59
When might L1​ loss be preferable?
Model answer
L1​ loss may be preferable when a dataset contains outliers that should not dominate the model's fit.
Explanation
It penalizes large errors less harshly than L2​ loss.
- 60
What is overfitting?
Model answer
Overfitting occurs when a model fits the training data too closely and consequently performs poorly on new data.
Explanation
An overfit model may achieve very low training error while failing to capture patterns that generalize.
- 61
Why is minimizing training loss alone dangerous?
Model answer
Minimizing training loss alone can encourage a model to memorize the available data rather than learn a pattern that generalizes.
Explanation
A highly complex boundary or curve may classify every training example correctly but make poor predictions on unseen examples.
- 62
How can an overly complex classification boundary indicate overfitting?
Model answer
A complex boundary may separate every training point correctly while treating noise or outliers as meaningful patterns.
Explanation
Such a boundary is likely to perform poorly on new observations that do not match the exact training arrangement.
- 63
How can an overly flexible regression curve indicate overfitting?
Model answer
A curve that passes through every training point may have zero training loss but fail to predict the relationship for new input values.
Explanation
Perfectly connecting the observed points can model noise instead of the underlying trend.
- 64
What is regularization?
Model answer
Regularization is the process of penalizing complex hypotheses in order to favor simpler models that are more likely to generalize.
Explanation
It modifies the optimization objective so that model complexity matters in addition to prediction loss.
- 65
How does regularization change the cost function?
Model answer
It adds a complexity penalty to the empirical loss, so the cost reflects both prediction error and model complexity.
Explanation
A model with slightly higher loss may be preferred if it is substantially simpler and more likely to generalize.
- 66
What role does the parameter bb play in regularization?
Model answer
The parameter bb controls how strongly complexity is penalized; a larger bb applies a stronger penalty.
Explanation
A smaller bb places less emphasis on simplicity, while the appropriate value depends on the dataset and task.
- 67
What is holdout cross-validation?
Model answer
Holdout cross-validation divides the data into a training set used to fit the model and a testing set used to evaluate it on unseen examples.
Explanation
Separating the sets provides evidence about whether the model generalizes beyond its training data.
- 68
Why should the testing set not be used to train the model?
Model answer
The testing set must remain unseen during training so it can provide an unbiased test of how well the model generalizes.
Explanation
Testing on training data could hide overfitting because the model has already seen those examples.
- 69
What is the main disadvantage of a single holdout split?
Model answer
Some available data is excluded from training, and the evaluation may depend heavily on the particular random split.
Explanation
Using less training data may reduce model quality, especially when the dataset is small.
- 70
How does k-fold cross-validation work?
Model answer
It divides the data into k subsets, trains on k−1 subsets, tests on the remaining subset, and repeats until each subset has served as the test set.
Explanation
The process produces k performance results, which are often averaged to estimate overall performance.
- 71
Why can k-fold cross-validation use data more efficiently than a single holdout split?
Model answer
Every data point can participate in training during some runs and in testing during another run.
Explanation
This allows more of the dataset to contribute to model fitting while still evaluating on unseen subsets in each run.
- 72
What is reinforcement learning?
Model answer
Reinforcement learning is a form of machine learning in which an agent learns from experience by receiving numerical rewards or punishments after taking actions.
Explanation
The agent uses these outcomes to improve its future decisions rather than learning from a fixed set of labeled input-output pairs.
- 73
What is an agent in reinforcement learning?
Model answer
An agent is the decision-making entity, such as a robot or computer program, that takes actions in an environment.
Explanation
The agent observes its situation, chooses actions, and learns from the resulting outcomes.
- 74
What does an environment provide to a reinforcement-learning agent?
Model answer
After an action, the environment provides a new state and a numerical reward or punishment.
Explanation
These outcomes are the information the agent uses to learn which actions are beneficial or harmful.
- 75
What is a state in reinforcement learning?
Model answer
A state is the situation or configuration in which the agent currently finds itself.
Explanation
Examples include a game position or the agent's location in a grid.
- 76
What is an action in reinforcement learning?
Model answer
An action is a choice the agent can make while in a particular state.
Explanation
Different states may allow different sets of actions, each of which can lead to different outcomes.
- 77
How do rewards and punishments guide reinforcement learning?
Model answer
Positive rewards encourage actions or action sequences, while negative rewards discourage them.
Explanation
Through repeated experience, the agent learns what to do and what to avoid.
- 78
How could reinforcement learning train a walking robot?
Model answer
The robot could receive positive rewards for making useful forward steps and negative rewards for undesirable outcomes such as falling.
Explanation
By repeatedly trying actions and observing their consequences, the robot can learn effective movement patterns.
- 79
What is a Markov decision process?
Model answer
A Markov decision process is a model for decision-making that represents states, available actions, probabilistic transitions, and rewards.
Explanation
It formalizes how an agent interacts with an environment over a sequence of decisions.
- 80
How does a Markov decision process extend a Markov chain?
Model answer
A Markov chain transitions between states according to probabilities, whereas a Markov decision process also allows an agent to choose actions that influence transitions and produce rewards.
Explanation
The agent has control over which available action is taken in each state.
- 81
What does the transition model in a Markov decision process specify?
Model answer
It specifies the probability of reaching a next state given the current state and the action taken.
Explanation
In a deterministic environment, the next state is certain; in a stochastic environment, several next states may be possible.
- 82
What does the reward function in a Markov decision process specify?
Model answer
It specifies the reward received for starting in a state, taking an action, and reaching a next state.
Explanation
Rewards can be positive or negative and can be accumulated over a sequence of actions.
- 83
What is the purpose of Q learning?
Model answer
Q learning learns a function Q(s,a) that estimates the value of taking action a in state s.
Explanation
The estimated value reflects the reward expected from the action, including relevant future rewards.
- 84
How is the Q function initialized in the described Q-learning approach?
Model answer
The function is initially set so that Q(s,a)=0 for every state and action.
Explanation
The agent begins without knowledge of which actions are valuable and updates the estimates through experience.
- 85
What information is used to update a Q value?
Model answer
The update uses the immediate reward and the estimated future reward available after the action.
Explanation
Both current and future consequences matter when judging the value of an action.
- 86
Why might an agent take an action that produces no immediate reward?
Model answer
The action may lead to a future state from which the agent can obtain larger or more valuable rewards later.
Explanation
Q learning balances immediate outcomes with expected future outcomes.
- 87
What does the learning rate b1 control in Q learning?
Model answer
It controls how strongly a new value estimate changes the existing Q value.
Explanation
A value of b1=1 replaces the old estimate with the new one, b1=0 ignores the new information, and intermediate values balance old and new information.
- 88
What is the new value estimate in the Q-learning update based on?
Model answer
It is based on the immediate reward plus the highest estimated Q value among the possible next actions.
Explanation
The agent considers both the reward just received and the best expected continuation from the next state.
- 89
What does discounting future rewards accomplish in Q learning?
Model answer
Discounting makes future rewards count less than immediate rewards.
Explanation
A programmer may use discounting when rewards received sooner should be valued more highly than rewards received later.
- 90
What is a greedy decision-making policy?
Model answer
A greedy policy chooses the action with the highest current estimated value Q(s,a) in the present state.
Explanation
It exploits the agent's existing knowledge by selecting the action believed to produce the greatest reward.
- 91
What is the exploration-exploitation trade-off?
Model answer
Exploitation uses actions already believed to be effective, while exploration tries less-known actions that may lead to better long-term rewards.
Explanation
An agent that only exploits may miss a faster or more rewarding strategy.
- 92
What is the epsilon-greedy algorithm?
Model answer
The epsilon-greedy algorithm chooses a random action with probability b5 and the currently best-known action with probability 1-b5.
Explanation
This method combines exploration of unfamiliar actions with exploitation of known valuable actions.
- 93
Why might epsilon be decreased over time?
Model answer
Epsilon may be decreased so that the agent explores more early in training and exploits its learned knowledge more often later.
Explanation
Early exploration helps discover possibilities, while later exploitation uses the information already acquired.
- 94
How can game playing provide rewards for reinforcement learning?
Model answer
The agent can receive a positive reward for winning and a negative reward for losing, then use those outcomes to learn which actions are effective.
Explanation
The agent does not need explicit instructions about every good or bad move if the final game result provides feedback.
- 95
What are the rules of the game of Nim described in the content?
Model answer
Players take turns removing one or more objects from exactly one pile, and the player who removes the last object loses.
Explanation
A move may remove any positive number of objects from one selected pile.
- 96
How can a Nim game state be represented for an AI?
Model answer
A state can be represented by the number of remaining objects in each pile.
Explanation
With four piles, a state is described by four numbers, and actions specify how many objects to remove from a selected pile.
- 97
Why is Nim relatively suitable for basic reinforcement learning?
Model answer
Nim has relatively few possible states and actions, making it feasible to learn values for many state-action combinations.
Explanation
Games such as chess have vastly larger state spaces, making exhaustive learning impractical.
- 98
What is function approximation in reinforcement learning?
Model answer
Function approximation estimates action values using a general function based on features of states rather than storing a separate value for every state-action pair.
Explanation
It allows learning to generalize across similar states when the complete state space is too large to explore.
- 99
Why is function approximation useful in large state spaces?
Model answer
It is useful because exploring and storing values for every possible state and action may be infeasible.
Explanation
The model can learn patterns from state features and apply them to situations resembling previously observed ones.
- 100
What is unsupervised learning?
Model answer
Unsupervised learning learns patterns from data that has no provided labels or additional feedback.
Explanation
Unlike supervised learning, the algorithm must discover structure without being told the correct category for each example.
- 101
What is clustering?
Model answer
Clustering is the task of organizing unlabeled objects into groups whose members are similar to one another.
Explanation
The groups are discovered from the structure of the data rather than from human-provided labels.
- 102
Give one application of clustering in genetic research.
Model answer
Clustering can group genes that are similar across a population or across different species.
Explanation
Grouping similar genes can help researchers analyze relationships in genetic data.
- 103
How can clustering be applied to images?
Model answer
Pixels can be grouped into clusters representing different regions or parts of an image.
Explanation
Pixels with similar properties may be assigned to the same image segment.
- 104
How can clustering be used in market research?
Model answer
It can divide consumers into groups with similar characteristics so that organizations can target groups with appropriate products or advertisements.
Explanation
The groups are formed from patterns in consumer data rather than from preassigned labels.
- 105
What is the main objective of k-means clustering?
Model answer
k-means clustering divides data points into k clusters based on their proximity to cluster centers.
Explanation
The value of k must be chosen, and different choices can be tested for suitability.
- 106
How does k-means clustering begin?
Model answer
It begins by choosing k initial cluster centers, often at random.
Explanation
The initial centers provide starting points for assigning data points to clusters.
- 107
How are points initially assigned in k-means clustering?
Model answer
Each point is assigned to the cluster whose center is closest to it.
Explanation
This creates an initial grouping based on distance from the current centers.
- 108
What does it mean to recenter a cluster in k-means?
Model answer
The cluster center is moved to the mean, or average position, of all points currently assigned to that cluster.
Explanation
Clusters with more points in one direction have their centers pulled toward those points.
- 109
What iterative steps does k-means clustering repeat?
Model answer
It repeatedly assigns points to their nearest centers and then moves each center to the mean of its assigned points.
Explanation
The assignments and centers are updated until the grouping stabilizes.
- 110
When does the k-means algorithm stop?
Model answer
It stops when assigning points to the nearest centers produces no further changes in cluster membership.
Explanation
At that point, the algorithm has reached an equilibrium for the chosen initialization and value of k.
- 111
What type of data is required for supervised learning compared with unsupervised learning?
Model answer
Supervised learning requires labeled input-output pairs, whereas unsupervised learning uses data without labels.
Explanation
Labels guide supervised prediction, while unsupervised methods discover structure independently.
- 112
What is scikit-learn?
Model answer
Scikit-learn is a Python library that provides implementations of many machine learning algorithms and utilities.
Explanation
It allows programmers to use models such as perceptrons, support vector classifiers, and nearest-neighbor classifiers without implementing them from scratch.
- 113
What kind of data is contained in the banknotes dataset?
Model answer
Each banknote has four measured input features and a human-provided label indicating whether it is authentic or counterfeit.
Explanation
The labels make the dataset suitable for supervised binary classification.
- 114
How are the banknote labels encoded in the described dataset?
Model answer
A label of 0 represents an authentic banknote, while a label of 1 represents a counterfeit banknote.
Explanation
The numerical labels provide the target outputs that the classifier must learn to predict.
- 115
Why is the banknotes task a classification problem?
Model answer
It requires assigning each banknote to one of two discrete categories: authentic or counterfeit.
Explanation
The model predicts a category rather than a continuous numerical quantity.
- 116
What is the purpose of separating evidence from labels when reading the banknotes data?
Model answer
The evidence contains the input features used for prediction, while the label contains the target output the model must learn to predict.
Explanation
Keeping these lists aligned ensures that each feature vector is paired with its correct classification.
- 117
What does the
fitoperation do in the described scikit-learn workflow?Model answer
It trains the selected model using the training inputs and their corresponding labels.
Explanation
Scikit-learn performs the model-fitting algorithm using the supplied training data.
- 118
What does the
predictoperation do in the described workflow?Model answer
It uses the trained model to generate predicted labels for the testing inputs.
Explanation
The predictions are then compared with the known testing labels to evaluate performance.
- 119
How is classification accuracy calculated in the banknotes example?
Model answer
Accuracy is determined by comparing predicted labels with actual labels and calculating the proportion of predictions that match.
Explanation
Correct and incorrect predictions can be counted separately before computing the overall accuracy.
- 120
What was the reported result of the perceptron model on one banknotes split?
Model answer
It correctly classified 679 bills and incorrectly classified 7, producing an accuracy close to 99%.
Explanation
The result illustrates that a perceptron can perform very well on this particular dataset and split.
- 121
What was the reported result of the support vector classifier on one banknotes split?
Model answer
It correctly classified 682 bills and incorrectly classified 4, producing an accuracy of about 99.4%.
Explanation
The comparison shows that different models can have slightly different performance on the same data.
- 122
Why might repeated experiments produce different banknote results?
Model answer
The data is randomly shuffled and split, so each experiment may use slightly different training and testing sets.
Explanation
Performance can therefore vary depending on which examples appear in each subset.
- 123
What does
train_test_splitprovide in scikit-learn?Model answer
It automatically divides a dataset into training and testing subsets according to a specified proportion.
Explanation
For example, a testing proportion of 0.5 assigns half the data to testing and the remainder to training.
- 124
What is the practical advantage of using scikit-learn?
Model answer
It allows programmers to apply and compare machine learning models quickly without implementing all of their mathematical details themselves.
Explanation
This makes it easier to train, test, and experiment with several algorithms in practical applications.

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