def TrainAndTestMultiDigitsPerceptron(): digits = [i for i in xrange(0, 10)] print "Running the Multi Digits Perceptron" print "the digits it shall descriminate between: " + digits.__str__() print "Extracting the Training Data" img, lbl = rn.getData(digits, "training") print "Training the Multi Digit Perceptron:" MulitDigitPerc = pr.MultiDigitPerceptron(digits, img, lbl, int(alpha * len(lbl))) print "Error on the Training data: " print str(pr.TestClassifier(img, lbl, MulitDigitPerc) * 100.0) + "%" print "Extracting the Testing Data" img, lbl = rn.getData(digits, "testing") print "False Classification on the Testing data: " + str( pr.TestClassifier(img, lbl, MulitDigitPerc) * 100.0) + "%"
def TrainAndTestWeakMultiDigitPerceptron(): digits = [i for i in xrange(0, 10)] print "Running the Weak Multi Digit Perceptron" fullimg, lbl = rn.getData(digits, "training") reducedList = rn.getReductionList(colnum, rownum) img = rn.ReduceSetDimension(reducedList, fullimg) perc = pr.MultiDigitPerceptron(digits, img, lbl, int(alpha * len(lbl))) print "Error on the Training data: " + str( pr.TestClassifier(img, lbl, perc) * 100.0) + "%" print "(out of " + str(len(lbl)) + " samples)" print "Extracting the Testing Data" fullimg, lbl = rn.getData(digits, "testing") img = rn.ReduceSetDimension(reducedList, fullimg) print "Error on the Testing data: " + str( pr.TestClassifier(img, lbl, perc) * 100.0) + "%" print "(out of " + str(len(lbl)) + " samples)"
def TrainAndTestBinPerceptron(): if len(digits) > 2: print "digits should be 2 digits in the case of Binary Perceptron" print "Running the Binary Perceptron" print "the digits it shall descriminate between: " + str( digits[0]) + "," + str(digits[1]) print "the label 1 will be given to the digit " + str(digits[0]) img, lbl = rn.getData(digits, "training") binlbl = rn.BinaryLabels(lbl, digit) perc = pr.Perceptron(img, binlbl, int(alpha * len(binlbl))) print "Error on the Training data: " + str( pr.TestClassifier(img, binlbl, perc) * 100.0) + "%" print "(out of " + str(len(binlbl)) + " samples)" print "Extracting the Testing Data" img, lbl = rn.getData(digits, "testing") binlbl = rn.BinaryLabels(lbl, digit) print "Error on the Testing data: " + str( pr.TestClassifier(img, binlbl, perc) * 100.0) + "%" print "(out of " + str(len(binlbl)) + " samples)"
def TrainAndTestWeakBinPerceptron(): if len(digits) > 2: print "digits should be 2 digits in the case of Binary Perceptron" print "Running the Weak Binary Perceptron" print "the digits it shall descriminate between: " + str( digits[0]) + "," + str(digits[1]) fullimg, lbl = rn.getData(digits, "training") binlbl = rn.BinaryLabels(lbl, digit) reducedList = rn.getReductionList(colnum, rownum) img = rn.ReduceSetDimension(reducedList, fullimg) perc = pr.Perceptron(img, binlbl, int(alpha * len(binlbl))) print "Error on the Training data: " + str( pr.TestClassifier(img, binlbl, perc) * 100.0) + "%" print "(out of " + str(len(binlbl)) + " samples)" print "Extracting the Testing Data" fullimg, lbl = rn.getData(digits, "testing") img = rn.ReduceSetDimension(reducedList, fullimg) binlbl = rn.BinaryLabels(lbl, digit) print "Error on the Testing data: " + str( pr.TestClassifier(img, binlbl, perc) * 100.0) + "%" print "(out of " + str(len(binlbl)) + " samples)"