foundations of computational agents
The simplest case for learning is when there are no input features and where there is a single target feature. This is the base case for many of the learning algorithms and corresponds to the case where all inputs are ignored. In this case, a learning algorithm predicts a single value for the target feature for all of the examples. The prediction that minimizes the error depends on the error that is being minimized.
Suppose is a set of examples and is a numeric feature. The best an agent can do is to make a single point estimate, , for all examples. The errors for this case are
The 0/1 error on of prediction is .
The sum-of-squares error on of prediction is .
The absolute error on of prediction is .
The worst-case error on of prediction is .
Suppose is the multiset of values of for .
A prediction that minimizes the error is a mode; one of the values that appears most often. When there are multiple modes, any can be chosen.
The prediction that minimizes the sum-of-squares error on is the mean of (the average value).
The absolute error is minimized by any median of . A median is the middle number when the values are sorted; a number such that half or more of values of less than or equal to and half or more are greater than or equal to . For example, for the numbers , any number between and is a median.
The value that minimizes the worst-case error is , where is the maximum value and is the minimum value.
The details of the proof are left as an exercise. The proof sketch is as follows.
This should be obvious.
Differentiate the formula for the sum-of-squares error with respect to and set to zero. This is elementary calculus.
The absolute error is a piecewise linear function of . The slope for a value that is not in depends on the number of elements greater minus the number of elements less than that value: is a minimum if there are the same number of elements greater than as there are less than .
This prediction has a worst-case error of ; increasing or decreasing the prediction will increase the error.
When the target feature has domain , the training examples can be summarized in two numbers: , the number of examples with the value 0, and , the number of examples with value 1. The prediction for each new case is the same number, .
The optimal prediction depends on the optimality criteria. The value of the optimality criteria for the training examples can be computed analytically and can be optimized analytically. The results are summarized in Figure 7.5.
|measure||prediction for||prediction for|
|the training data||training data|
|0/1 error||if else if||0 if else 1|
|absolute error||0 if else 1|
Notice that optimizing the absolute error means predicting the median, which in this case is also the mode. The error is linear in , and so has a minimum at one of the ends.
The optimal prediction for the training data for the other criteria is to predict the empirical frequency: the proportion of 1s in the training data, namely . This can be seen as a prediction of the probability. The empirical frequency is often called the maximum-likelihood estimate.
This analysis does not specify the optimal prediction for the test data. We would not expect the empirical frequency of the training data to be the optimal prediction for the test data for maximizing the likelihood or minimizing the entropy. If or if , all of the training data are classified the same. However, if just one of the test examples is not classified in this way, the likelihood would be 0 (its lowest possible value) and the entropy would be infinite. This is an example of overfitting. See Exercise 1.