Inductive learning is learning from examples.

The inductive learning hypothesis says any hypothesis found to approximate the target function well over a sufficiently large set of training examples will also approximate the target function well over other unobserved examples.

Decision Trees

A decision tree is used to approximate discrete-valued target functions, it is a disjunction of conjunctions of constraints on feature values of instances / data points. The learnt trees are effectively sets of if-then rules.

Each node is a test of the value of a feature for a data point. Each leaf node is the value to be returned.

Example decision tree

Given the dataset:

We may generate the tree:

Trivially, there exists a consistent decision tree for any training set where we have one path to each leaf for each example. Path tests each feature in turn and follows value for example.

However this will not generalise, we prefer to find more compact decision trees.

After we pick a feature, one of five things can happen:

  1. Remaining examples are positive, we are done and answer “yes”.
  2. Remaining examples are negative, we are done and answer “no”.
  3. There are some positive / negative examples, choose best feature to split on.
  4. If there are no examples left, we must return a default value. We could use plurality classification: best guess based on parent node. Could be majority, i.e. yes if most examples at parent are “yes”. Could be random pick, weighted by ratio of examples at parent node.
  5. If there are no features left, but there are still positive / negative examples then we could use plurality classification. This may occur due to noise / unobservability of features.

Decision Tree Learning Algorithm

def DTL(examples, attributes, parent_examples):
	if examples is empty:
		return plurality_value(parent_examples)
	else if all examples have same classification:
		return common_classification(examples)
	else:
		best = most_important_attribute(attributes, examples)
		tree = new decision tree with root best
		for value in best:
			examples = { elements of examples with best = value }
			remaining_attributes = attributes - best
			subtree = DTL(examples, remaining_attributes, examples)
			add branch to tree with label value and subtree
	return tree

Entropy

We will measure information in a feature by looking at how it reduces entropy.

Entropy (probability distribution)

Entropy in a probability distribution is Maximum for a uniform distribution, minimum for a single point.

Link to original

log2

Link to original

Suppose we have a set of positive and negative examples at the root. If we had to pick the class at this point, we could compute probability based on examples.

Chance of Class would be . So we have a probability distribution over classes, and we can compute the entropy of :

Example: for 12 restaurant examples, so the entropy is .

Information Gain

Information gain (entropy)

A feature splits the examples into subsets , each of these subsets is a new branch in the decision tree which have their own entropy. We can measure how ‘good’ is by the reduction in entropy of and entropy of all of the , this difference is called the information gain:

So the entropy of collectively is the weighted sum of their entropies.

Link to original

Example: putting it all together

Assuming has positive and negative examples, the entropy is:

And so the gain is:

The feature with the biggest is the one to pick.

Information gain has an inherent bias, it favours features that have many values.

Imagine if you add a restaurant name or time to the example: the name creates a unique classification (hence information gain would have its highest value for this feature) With enough precision, time would also uniquely identify each case.

Gain Ratio

Gain Ratio

Gain Ratio is a new metric that incorporates another metric split information that penalises features with lots of values (we ask what the value of the feature is):

We now use gain ratio as the new way of picking the best feature.

Link to original

Gini Ratio

Gini impurity is an alternative to choose best features. Suppose we have a set of positive and negative examples at root, we assign a probability based on the number of examples.

Gini Ratio

The Gini Ratio (Gini Impurity) is a measure of statistical dispersion, i.e. a measure of inequality (probability of this classification mislabelling a randomly selected example):

Where is the number of classes.

Link to original

Example: putting it together

Now if we have just two classes, we find:

If we have a feature that splits into subsets , then the Gini impurity of these sets is To pick a feature, we calculate for each feature, and pick the feature with the lowest impurity.

Overfitting

The DTL grows the tree just enough to perfectly classify all examples however it can easily lead to overfitting if:

  • the set is too small; or
  • the set contains noise

Given two decision trees and , is said to overfit the training data if:

  1. has a smaller error than on the training data
  2. has a smaller error than on all other instances

Two main approaches to prevent overfitting are:

  1. Stop growing tree earlier (don’t get to point of overfitting)
  2. (possibly) overfit then prune the tree (seems more successful)

Reduced error pruning

In reduced error pruning:

  • consider every branch in tree as a candidate for pruning
  • remove the branch, make the root of the branch into a leaf
  • use plurality classification for examples at leaf
  • test the new tree
  • keep a branch pruned if the pruned tree performs better on some validation set than the original tree did
  • repeat while it is possible to prune a branch and improve performance

However we now need (1) training data, (2) pruning data, and (3) test data. (this is a problem when data is limited, so we take another approach)

Rule post-pruning

In rule post-pruning (a solution to pruning with limited data):

  1. Build decision tree as before
  2. Create a rule set One rule for each path from root to leaf
  3. Remove preconditions (feature tests) from rules if that improves their accuracy
  4. Sort rules by accuracy and apply them in order / sequence when classifying examples

Broadening decision tree approach

Briefly covered

  • Multivalued features: when features have many values, information gain gives inappropriate estimate of the usefulness of the feature e.g. convert these to boolean tests
  • Continuous / integer input features: infinite sets of possible values Modify our approach to identify split points which give highest information gain e.g.
  • Continuous output values When trying to predict continuous output values we need to create a regression tree which ends with a linear function

Slides 51-52 skipped.

Linear regression

Linear regression is learning a linear function of continuous inputs. The (univariate) equation is of the form: Where subscript indicates the vector . Our goal is to estimate and from the data.

Example: predict house prices by floor area

We want to find the that best fits the data (choose so that is close to for our training examples). To fit the line, we find that minimise .

We use the squared loss function to determine loss:

This is summed over all training examples, and where the data we have are pairs (this is the cost function). So we would like to find: (our optimisation objective)

We can plot the loss / cost function and produce something like this:

Similarly, this works with more axes:

Gradient descent algorithm

To choose the best , we use the gradient descent algorithm which in effect:

  • Start with some initial values for ,
  • Keep changing values until cost / loss function is reduced For each , we update with where is the learning rate and controls how big of a step we take downhill.
    • if is too small, then we take small steps and convergence takes long
    • if is too large, we might miss the minimum and not converge
  • Continue until we reach a minimum

The slope at the minimum is which means .

Batch gradient descent

Consider all the training examples simultaneously, and at each step update using:

  • Guaranteed to converge.
  • Can be slow since we need to compute for all examples at each step.

Stochastic gradient descent

Alternatively, we could do

for each of the examples in turn.

  • Often much quicker.
  • If learning rate is constant, may not converge.

Multivariate linear regression

Now consider we have more variables: and we are interested in a vector of weights :

  • We simplify handling of the wights by creating a dummy attribute to pair with :
  • Then is just the weighted sum of the variable values:

We learn as before by doing gradient descent:

  • Batch gradient descent:
  • Stochastic gradient descent:

We adjust more weights each time.

But we have to avoid overfitting, so we add a regularisation term to the loss function: Where . By intuition, smaller gives smaller functions . is the regularisation parameter which is the trade-off between fitting the data and having a simple function.

Linear classifiers

We can turn a linear function into a classifier, the function defines the decision boundary that separates the two classes.

Example: seismic data due to earthquakes and nuclear explosions

The linear separator is or

Explosions are to the right of the line:

Hence we do classification as follows: otherwise the classifier returns .

Learning curve for linear classifier

Typically variation across runs is very large, the curve is not smooth because boundary is hard: so we can misclassify a lot of examples even a long way into learning.

It can be worse if the data is noisy.

Logistic regression

The linear classifier always predicts or , even for examples close to the boundary. In many tasks, we need more gradated predictions.

We can soften the threshold function (approximate hard threshold with continuous function) hence we use the logistic function as a threshold:

The update function therefore becomes:

"commonly uses cross-entropy loss function" whatever that means???

Convergence is slower, but behaves much more predictably.

Issues with linear separability

We cannot represent with a single linear model.

Ensemble methods

Every classifier has an error rate - will always misclassify some examples. We can use an ensemble to improve on this, i.e. take classifiers and use them on the same example by having them vote on the classification.

For a binary classification and classifiers, error rate drops from (for example) to less than . Assuming the classifiers are independent / different enough.

Boosting extends the idea of an ensemble, in which higher weighted examples are counted as more important during training (e.g. we put more copies into the training set).

Example

Say we start with all examples of equal weight, learning classifier .

  • Test it and increase weights of misclassified examples, and learn .
  • Repeat a few times.
  • Final ensemble is the combination of all classifiers, weighted by how well they perform on the training set.

AdaBoost

The AdaBoost algorithm is a commonly used approach to boosting. Given an initial classifier that is slightly better than random (weak model), AdaBoost can generate an ensemble that will perfectly classify the training set.

Bagging (bootstrap aggregation): given a training set , we create multiple training sets which from each we learn a classifier. To classify an example, we combine the results of the ensemble. The are sampled from with a uniform distribution (with replacement).

To combine results, we typically use voting, but we can use averages too.

what the fuck are you going on about!!!!

random forests:

random subspace method:

0 items under this folder.