Esempio n. 1
0
 def build_Classifier_Train_Test(self, feature_extractor):
     self.q21 = q2_1()
     classifier = self.q21.evaluate_features(feature_extractor, 2)
     train = self.q21.maintrain
     test = self.q21.maintest
     testClaassify = self.q21.testClassify
     return classifier, train, test, testClaassify
Esempio n. 2
0
 def build_Classifier_Train_Test(self, feature_extractor):
     self.q21 = q2_1()
     classifier = self.q21.evaluate_features(feature_extractor, 2)
     train = self.q21.maintrain
     test = self.q21.maintest
     testClaassify = self.q21.testClassify
     return classifier,train,test, testClaassify
Esempio n. 3
0
def main():
    q21 = q2_1()
    x = []
    y = []
    pos = ['N', 'VG', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(1)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)
    
    pos = ['N', 'V', 'VG', 'VN', 'VN', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(2)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)
    
    pos = ['V', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(3)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)
    
    pos = ['ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(4)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)
    
    pos = ['N', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(5)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)
    
    pylab.bar(x, y, width=0.02, facecolor='blue', align='center')
    pylab.xlabel('POS')
    pylab.ylabel("Accuracy")
    pylab.title("Accuracy for each pos set")
    pylab.grid(False)
    pylab.show()
    return
Esempio n. 4
0
def main():
    q21 = q2_1()
    x = []
    y = []
    pos = ['N', 'VG', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(1)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)

    pos = ['N', 'V', 'VG', 'VN', 'VN', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(2)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)

    pos = ['V', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(3)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)

    pos = ['ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(4)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)

    pos = ['N', 'ADJ', 'ADV']
    print pos
    extractor = make_pos_extractor(pos)
    classifier = q21.evaluate_features(extractor, 10)
    x.append(5)
    acc = accuracy(q21.maintest, q21.testClassify)
    y.append(acc)

    pylab.bar(x, y, width=0.02, facecolor='blue', align='center')
    pylab.xlabel('POS')
    pylab.ylabel("Accuracy")
    pylab.title("Accuracy for each pos set")
    pylab.grid(False)
    pylab.show()
    return
Esempio n. 5
0
def main():
    q21 = q2_1()
    print "bag of words extractor:"
    firstClassifier = q21.evaluate_features(bag_of_words, 10)
    oldClassify = q21.testClassify
    print "top k frequent words without stop words extractor:"
    extractor = make_topK_non_stopword_extractor(10000, stopset)
    secondClassifier = q21.evaluate_features(extractor, 10)
    newClassify = q21.testClassify
    #identifying documents that classified differently and report new positive, new negative
    noPos, noNeg = newTaggs(oldClassify, newClassify)
    print "No of documents that the classifier classify them as pos in bag of words extractor and neg in top k extractor is:", noNeg
    print "No of documents that the classifier classify them as neg in bag of words extractor and pos in top k extractor is:", noPos
    #drawing plot of accuract vs. K/W
    plotGraph(q21, 5000)
    return
Esempio n. 6
0
def main():
    q21 = q2_1()
    print "bag of words extractor:"
    firstClassifier = q21.evaluate_features(bag_of_words, 10)
    oldClassify = q21.testClassify
    print "top k frequent words without stop words extractor:"
    extractor = make_topK_non_stopword_extractor(10000, stopset)
    secondClassifier = q21.evaluate_features(extractor, 10)
    newClassify = q21.testClassify
    #identifying documents that classified differently and report new positive, new negative
    noPos, noNeg = newTaggs(oldClassify, newClassify)
    print "No of documents that the classifier classify them as pos in bag of words extractor and neg in top k extractor is:", noNeg
    print "No of documents that the classifier classify them as neg in bag of words extractor and pos in top k extractor is:", noPos
    #drawing plot of accuract vs. K/W
    plotGraph(q21, 5000)
    return
Esempio n. 7
0
def main():
    q21 = q2_1()

    print "bigram Extractor:"
    #evaluate bigram extractor
    extractor = make_bigram_extractor()
    classifier = q21.evaluate_features(extractor, 4)

    print "bag of words extractor:"
    #evaluate bag of words extractor
    extractor = bag_of_words
    classifier = q21.evaluate_features(extractor, 4)

    print "all bigram unigram extractor"
    #evaluate all bigrams and all unigrams extractor
    extractor = make_bigram_unigram_extractor()
    classifier = q21.evaluate_features(extractor, 4)

    print "good bigram unigram extractor:"
    #evaluate good bigrams and all unigrams extractor
    extractor = make_good_bigram_unigram_extractor(100)
    classifier = q21.evaluate_features(extractor, 4)

    return
Esempio n. 8
0
def main():
    q21 = q2_1()
    
    print "bigram Extractor:"
    #evaluate bigram extractor
    extractor = make_bigram_extractor()
    classifier = q21.evaluate_features(extractor, 4)
    
    print "bag of words extractor:"
    #evaluate bag of words extractor
    extractor = bag_of_words
    classifier = q21.evaluate_features(extractor, 4)
    
    print "all bigram unigram extractor"
    #evaluate all bigrams and all unigrams extractor
    extractor = make_bigram_unigram_extractor()
    classifier = q21.evaluate_features(extractor, 4)
    
    print "good bigram unigram extractor:"
    #evaluate good bigrams and all unigrams extractor
    extractor = make_good_bigram_unigram_extractor(100)
    classifier = q21.evaluate_features(extractor, 4)
    
    return