def DecisionListLearner(dataset):
def decision_list_learning(examples):<EOL><INDENT>if not examples:<EOL><INDENT>return [(True, False)]<EOL><DEDENT>t, o, examples_t = find_examples(examples)<EOL>if not t:<EOL><INDENT>raise Failure<EOL><DEDENT>return [(t, o)] + decision_list_learning(examples - examples_t)<EOL><DEDENT>def find_examples(examples):<EOL><INDENT>"""<STR_LIT>"""<EOL>unimplemented()<EOL><DEDENT>def passes(example, test):<EOL><INDENT>"<STR_LIT>"<EOL>unimplemented()<EOL><DEDENT>def predict(example):<EOL><INDENT>"<STR_LIT>"<EOL>for test, outcome in predict.decision_list:<EOL><INDENT>if passes(example, test):<EOL><INDENT>return outcome<EOL><DEDENT><DEDENT><DEDENT>predict.decision_list = decision_list_learning(set(dataset.examples))<EOL>return predict<EOL>
[Fig. 18.11]