# Candidate Elimination Algorithm & its Procedure

Prerequisite: Version Space in Machine Learning

The Candidate Elimination Algorithm computes the version space containing all hypotheses from H that are consistent with an observed sequence of training examples.

It begins by initializing the version space to the set of all hypotheses in H, that is, by initializing the G boundary set to contain the most general hypotheses in H

G_{0 } ← {<?,?,?,?,?,?,?>}

And initializing the S boundary set to contain the most specific hypothesis.

S_{0 }← {<0,0,0,0,0,0,0>}

These two boundary sets delimit the entire hypothesis space because every other hypothesis in H is both more general than S_{0 }and more specific than G_{0}.

As each training example is considered, the S and G boundary sets are generalized and specialized, respectively to eliminate from the version space any hypothesis found inconsistent with the new training example.

After all the examples have been processed, the computed version space contains all the hypotheses consistent with these examples and hypotheses.

#### The Candidate Elimination Algorithm goes as follows -

- Initialize G to the set of maximally general hypotheses in H.
- Initialize S to the set of maximally specific hypotheses in H.
- For each training example d
- If d is a positive example
- Remove from G any hypothesis that does not include.
- For each hypothesis s in S that does not include d, remove s from S.
- Add to S all minimal generalizations h of s such that h includes d, and
- Some member of G is more general than h
- Remove from S any hypothesis that is more general than another hypothesis in S.

- For each training example d
- If d is a negative example
- Remove from S any hypothesis that does not include.
- For each hypothesis g in G that does not include d
- Remove g from G

- Add to G all minimal generalizations h of g such that
- h does not include d and
- Some member of S is more specific than h

- Remove from G any hypothesis that is less general than another hypothesis in G.
- If G or S, ever becomes empty, data not consistent (with H).