Exemplo n.º 1
0
def calculatePredictions(learnTreeGenerator, docs1, docs2, predictionRatio1, predictionRatio2):
    numDocuments1 = len(docs1)
    numDocuments2 = len(docs2)
    for learnTree in learnTreeGenerator:
        numCorrectPredictionDocs1 = 0
        numCorrectPredictionDocs2 = 0
        for doc in docs1:
            prediction = DTN.predict(learnTree, doc)
            if prediction == doc[-1]:
                # if the prediction was correct
                numCorrectPredictionDocs1+= 1
        
        for doc in docs2:
            prediction = DTN.predict(learnTree, doc)
            if prediction == doc[-1]:
                numCorrectPredictionDocs2+= 1
        
        predictionRatio1.append(numCorrectPredictionDocs1/numDocuments1 * 100)
        predictionRatio2.append(numCorrectPredictionDocs2/numDocuments2 * 100)
Exemplo n.º 2
0
 def __init__(self, dataset, features, mode):
     self.dTree = DTN.computeFirstNode(dataset, features, mode)
     self.mode = mode