• Home
  • Textbooks
  • Artificial Intelligence. A Modern Approach [Global Edition]
  • Learning from Examples

Artificial Intelligence. A Modern Approach [Global Edition]

Stuart Russell, Peter Norvig

Chapter 18

Learning from Examples - all with Video Answers

Educators


Chapter Questions

Problem 1

Consider the problem faced by an infant learning to speak and understand a language. Explain how this process fits into the general learning model. Describe the percepts and actions of the infant, and the types of learning the infant must do. Describe the subfunctions the infant is trying to learn in terms of inputs and outputs, and available example data.

Check back soon!
03:01

Problem 1

Prove that a decision list can represent the same function as a decision tree while using at most as many rules as there are leaves in the decision tree for that function. Give an example of a function represented by a decision list using strictly fewer rules than the number of leaves in a minimal-sized decision tree for that same function.

Jennifer Stoner
Jennifer Stoner
Numerade Educator
00:17

Problem 2

Repeat Exercise 18.1 for the case of learning to play tennis (or some other sport with which you are familiar). Is this supervised learning or reinforcement learning?

Deborah Taylor
Deborah Taylor
Numerade Educator

Problem 3

Draw a decision tree for the problem of deciding whether to move forward at a road intersection, given that the light has just turned green.

Check back soon!
00:18

Problem 4

We never test the same attribute twice along one path in a decision tree. Why not?

Maxime Rossetti
Maxime Rossetti
Numerade Educator

Problem 5

Suppose we generate a training set from a decision tree and then apply decision-tree learning to that training set. Is it the case that the learning algorithm will eventually return the correct tree as the training-set size goes to infinity? Why or why not?

Check back soon!

Problem 6

In the recursive construction of decision trees, it sometimes happens that a mixed set of positive and negative examples remains at a leaf node, even after all the attributes have been used. Suppose that we have positive examples and negative examples.
a. Show that the solution used by DECISION-TREE-LEARNING, which picks the majority classification, minimizes the absolute error over the set of examples at the leaf.
b. Show that the class probability $(+)$ minimizes the sum of squared errors.

Check back soon!
01:48

Problem 7

Suppose that an attribute splits the set of examples into subsets $k$ and that each subset has $k$ positive examples and ${ }_k$ negative examples. Show that the attribute has strictly positive information gain unless the ratio $k(k+k)$ is the same for all .

Robin Corrigan
Robin Corrigan
Numerade Educator

Problem 8

Consider the following data set comprised of three binary input attributes $(1.2$, and 3) and one binary output:
$$
\begin{array}{|c|c|c|c|c|}
\hline \text { Example } & 1 & 2 & 3 & \text { Output } \\
\hline \mathbf{x}_1 & 1 & 0 & 0 & 0 \\
\mathbf{x}_2 & 1 & 0 & 1 & 0 \\
\mathbf{x}_3 & 0 & 1 & 0 & 0 \\
\mathbf{x}_4 & 1 & 1 & 1 & 1 \\
\mathbf{x}_5 & 1 & 1 & 0 & 1 \\
\hline
\end{array}
$$
Use the algorithm in Figure 18.5 (page 702) to learn a decision tree for these data. Show the computations made to determine the attribute to split at each node.

Check back soon!
04:15

Problem 9

Construct a data set (set of examples with attributes and classifications) that would cause the decision-tree learning algorithm to find a non-minimal-sized tree. Show the tree constructed by the algorithm and the minimal-sized tree that you can generate by hand.

Chris Trentman
Chris Trentman
Numerade Educator

Problem 10

This exercise considers ${ }^2$ pruning of decision trees (Section 18.3.5).
a. Create a data set with two input attributes, such that the information gain at the root of the tree for both attributes is zero, but there is a decision tree of depth 2 that is consistent with all the data. What would ${ }^2$ pruning do on this data set if applied bottom up? If applied top down?
b. Modify Decision-Tree-Learning to include ${ }^2$-pruning. You might wish to consult Quinlan (1986) or Kearns and Mansour (1998) for details.

Check back soon!

Problem 11

The standard DECISION-TREE-LEARNING algorithm described in the chapter does not handle cases in which some examples have missing attribute values.
a. First, we need to find a way to classify such examples, given a decision tree that includes tests on the attributes for which values can be missing. Suppose that an example $\mathbf{x}$ has a missing value for attribute and that the decision tree tests for at a node that $\mathbf{x}$ reaches. One way to handle this case is to pretend that the example has all possible values for the attribute, but to weight each value according to its frequency among all of the examples that reach that node in the decision tree. The classification algorithm should follow all branches at any node for which a value is missing and should multiply the weights along each path. Write a modified classification algorithm for decision trees that has this behavior.
b. Now modify the information-gain calculation so that in any given collection of examples at a given node in the tree during the construction process, the examples with missing values for any of the remaining attributes are given "as-if" values according to the frequencies of those values in the set .

Check back soon!

Problem 12

In Section 18.3.6, we noted that attributes with many different possible values can cause problems with the gain measure. Such attributes tend to split the examples into numerous small classes or even singleton classes, thereby appearing to be highly relevant according to the gain measure. The gain-ratio criterion selects attributes according to the ratio between their gain and their intrinsic information content-that is, the amount of information contained in the answer to the question, "What is the value of this attribute?" The gain-ratio criterion therefore tries to measure how efficiently an attribute provides information on the correct classification of an example. Write a mathematical expression for the information content of an attribute, and implement the gain ratio criterion in DECISION-TREE-LEARNING.

Check back soon!

Problem 13

Suppose you are running a learning experiment on a new algorithm for Boolean classification. You have a data set consisting of 100 positive and 100 negative examples. You plan to use leave-one-out cross-validation and compare your algorithm to a baseline function, a simple majority classifier. (A majority classifier is given a set of training data and then always outputs the class that is in the majority in the training set, regardless of the input.) You expect the majority classifier to score about $50 \%$ on leave-one-out cross-validation, but to your surprise, it scores zero every time. Can you explain why?

Check back soon!
View

Problem 14

Suppose that a learning algorithm is trying to find a consistent hypothesis when the classifications of examples are actually random. There are Boolean attributes, and examples are drawn uniformly from the set of $2^n$ possible examples. Calculate the number of examples required before the probability of finding a contradiction in the data reaches 0.5 .

Rashmi Sinha
Rashmi Sinha
Numerade Educator

Problem 16

This exercise concerns the expressiveness of decision lists (Section 18.5).
a. Show that decision lists can represent any Boolean function, if the size of the tests is not limited.
b. Show that if the tests can contain at most literals each, then decision lists can represent any function that can be represented by a decision tree of depth

Check back soon!
01:55

Problem 17

Suppose a 7-nearest-neighbors regression search returns $\{4,2.8,4,9,11,100\}$ as the 7 nearest values for a given value. What is the value of " that minimizes the ${ }_1$ loss function on this data? There is a common name in statistics for this value as a function of the values; what is it? Answer the same two questions for the ${ }_2$ loss function.

Kaylee Mcclellan
Kaylee Mcclellan
Numerade Educator
02:04

Problem 18

Figure 18.31 showed how a circle at the origin can be linearly separated by mapping from the features $\left(\begin{array}{ll}1 & 2\end{array}\right)$ to the two dimensions $\left(\begin{array}{cc}2 & 2 \\ 1 & 2\end{array}\right)$. But what if the circle is not located at the origin? What if it is an ellipse, not a circle? The general equation for a circle (and hence the decision boundary) is $(1-)^2+(2-)^2-{ }^2=0$, and the general equation for an ellipse is $(1-)^2+(2-)^2-1=0$.
a. Expand out the equation for the circle and show what the weights $i$ would be for the decision boundary in the four-dimensional feature space $\left(\begin{array}{llll}1 & 2 & 2 & 2 \\ 1 & 2\end{array}\right)$. Explain why this means that any circle is linearly separable in this space.
b. Do the same for ellipses in the five-dimensional feature space $\left(\begin{array}{lllll}1 & 2, & 2 & 2 & 2 \\ & & 1 & 2\end{array}\right)$.

Harshita Goel
Harshita Goel
Numerade Educator
03:09

Problem 19

Construct a support vector machine that computes the XOR function. Use values of +1 and -1 (instead of 1 and 0 ) for both inputs and outputs, so that an example looks like $([-1,1], 1)$ or $([-1,-1],-1)$. Map the input $\left[\begin{array}{ll}1 & 2\end{array}\right]$ into a space consisting of $\quad 1$ and 12 . Draw the four input points in this space, and the maximal margin separator. What is the margin? Now draw the separating line back in the original Euclidean input space.

Sriram Soundarrajan
Sriram Soundarrajan
Numerade Educator

Problem 20

Consider an ensemble learning algorithm that uses simple majority voting among leamed hypotheses. Suppose that each hypothesis has error and that the errors made by each hypothesis are independent of the others'. Calculate a formula for the error of the ensemble algorithm in terms of and, and evaluate it for the cases where $=5,10$, and 20 and $=01,0.2$, and 0.4 . If the independence assumption is removed, is it possible for the ensemble error to be worse than ?

Check back soon!

Problem 21

Construct by hand a neural network that computes the XOR function of two inputs. Make sure to specify what sort of units you are using.

Check back soon!

Problem 22

A simple perceptron cannot represent XOR (or, generally, the parity function of its inputs). Describe what happens to the weights of a four-input, hard-threshold perceptron, beginning with all weights set to 0.1 , as examples of the parity function arrive.

Check back soon!
01:38

Problem 23

Recall from Chapter 18 that there are $2^{2^n}$ distinct Boolean functions of inputs. How many of these are representable by a threshold perceptron?

Adriano Chikande
Adriano Chikande
Numerade Educator

Problem 24

Consider the following set of examples, each with six inputs and one target output:
$$
\begin{array}{|l|llllllllllllll|}
\hline 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
2 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 1 & 0 & 1 & 1 \\
3 & 1 & 1 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 1 & 1 \\
4 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 1 & 1 & 0 & 1 \\
5 & 0 & 0 & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 & 0 & 0 & 1 & 0 \\
6 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 & 0 \\
\hline & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
\hline
\end{array}
$$
a. Run the perceptron learning rule on these data and show the final weights.
b. Run the decision tree learning rule, and show the resulting decision tree.
c. Comment on your results.

Check back soon!

Problem 25

Section 18.6.4 (page 725) noted that the output of the logistic function could be interpreted as a probability assigned by the model to the proposition that $(\mathbf{x})=1$; the probability that $(\mathbf{x})=0$ is therefore $1-$. Write down the probability as a function of $\mathbf{x}$ and calculate the derivative of $\log$ with respect to each weight ${ }_i$. Repeat the process for $\log (1-)$. These calculations give a learning rule for minimizing the negative-log-likelihood loss function for a probabilistic hypothesis. Comment on any resemblance to other learning rules in the chapter.

Check back soon!

Problem 26

Suppose you had a neural network with linear activation functions. That is, for each unit the output is some constant times the weighted sum of the inputs.
a. Assume that the network has one hidden layer. For a given assignment to the weights $\mathbf{w}$, write down equations for the value of the units in the output layer as a function of $\mathbf{w}$ and the input layer $\mathbf{x}$, without any explicit mention of the output of the hidden layer. Show that there is a network with no hidden units that computes the same function.
b. Repeat the calculation in part (a), but this time do it for a network with any number of hidden layers.
c. Suppose a network with one hidden layer and linear activation functions has input and output nodes and $h$ hidden nodes. What effect does the transformation in part (a) to a network with no hidden layers have on the total number of weights? Discuss in particular the case $h \ll$.

Check back soon!

Problem 27

Implement a data structure for layered, feed-forward neural networks, remembering to provide the information needed for both forward evaluation and backward propagation. Using this data structure, write a function NEURAL-NETWORK-OUTPUT that takes an example and a network and computes the appropriate output values.

Check back soon!

Problem 28

The neural network whose learning performance is measured in Figure 18.25 has four hidden nodes. This number was chosen somewhat arbitrarily. Use a cross-validation method to find the best number of hidden nodes.

Check back soon!

Problem 29

Consider the problem of separating data points into positive and negative examples using a linear separator. Clearly, this can always be done for $=2$ points on a line of dimension $=1$, regardless of how the points are labeled or where they are located (unless the points are in the same place).
a. Show that it can always be done for $=3$ points on a plane of dimension $=2$, unless they are collinear.
b. Show that it cannot always be done for $=4$ points on a plane of dimension $=2$.
c. Show that it can always be done for $=4$ points in a space of dimension $=3$, unless they are coplanar.
d. Show that it cannot always be done for $=5$ points in a space of dimension $=3$.
e. The ambitious student may wish to prove that points in general position (but not $+1)$ are linearly separable in a space of dimension $\quad-1$.

Check back soon!