示例#1
0
def decisionListLearning(examples):
    #if examples are empty then return trivial list node
    #with predicted label as 'No'/False
    if len(examples) == 0:
        return ListNode({}, {}, {}, False)
    #find a test S.T. subset of examples either all +ve or -ve
    (selectedAttributes, isSelectedIncl, selectedPureLabel, selectedOp) \
        = findTest(examples, Attribute.getAttributes())
    if not len(selectedAttributes):
        raise (DListCreationErr('couldn\'t find attributes for even split.'))

    listNode =  ListNode(selectedAttributes, isSelectedIncl, selectedOp,\
                             selectedPureLabel)
    #set next node from list learned by remaining examples
    listNode.setNextNode(decisionListLearning(filterExamples(examples,\
                                                            selectedAttributes,\
                                                            isSelectedIncl,\
                                                            selectedOp)))
    return listNode
示例#2
0
def decisionListLearning(examples):
    #if examples are empty then return trivial list node
    #with predicted label as 'No'/False
    if len(examples) == 0:
        return ListNode({}, {}, {}, False)
    #find a test S.T. subset of examples either all +ve or -ve
    (selectedAttributes, isSelectedIncl, selectedPureLabel, selectedOp) \
        = findTest(examples, Attribute.getAttributes())
    if not len(selectedAttributes):
        raise(DListCreationErr('couldn\'t find attributes for even split.'))

    listNode =  ListNode(selectedAttributes, isSelectedIncl, selectedOp,\
                             selectedPureLabel)
    #set next node from list learned by remaining examples
    listNode.setNextNode(decisionListLearning(filterExamples(examples,\
                                                            selectedAttributes,\
                                                            isSelectedIncl,\
                                                            selectedOp)))
    return listNode