Exemplo n.º 1
0
def testing(num):
    trainData = samples.loadImagesFile("data/digitdata/trainingimages", num, 28, 28)
    trainLabels = samples.loadLabelsFile("data/digitdata/traininglabels", num)
    testData = samples.loadImagesFile("data/digitdata/testimages", 1000, 28, 28)
    testLabels = samples.loadLabelsFile("data/digitdata/testlabels", 1000)
    validData = samples.loadImagesFile("data/digitdata/validationimages", 1000, 28, 28)
    validLabels = samples.loadLabelsFile("data/digitdata/validationlabels", 1000)

    nb = NaiveBayesClassifier(1,0)
    nb.train(trainData, trainLabels)
    print "***********************************"
    print "*************Test Data*************"
    guess = nb.classify(testData)
    samples.verify(nb,guess,testLabels)
    print "***********************************"
    print "************Valid Data*************"
    guess=nb.classify(validData)
    samples.verify(nb,guess,validLabels)
Exemplo n.º 2
0
def testing(num):
    trainData = samples.loadImagesFile("data/facedata/facedatatrain", num, 60, 70)
    trainLabels = samples.loadLabelsFile("data/facedata/facedatatrainlabels", num)
    testData = samples.loadImagesFile("data/facedata/facedatatest", 150, 60, 70)
    testLabels = samples.loadLabelsFile("data/facedata/facedatatestlabels", 151)
    validData = samples.loadImagesFile("data/facedata/facedatavalidation", 301, 60, 70)
    validLabels = samples.loadLabelsFile("data/facedata/facedatavalidationlabels", 301)

    nb = NaiveBayesClassifier(1, 0)
    nb.train(trainData, trainLabels)
    print "==================================="
    print "Test Data"
    guess = nb.classify(testData)
    samples.verify(nb, guess, testLabels)
    print "==================================="
    print "Validation Data"
    guess = nb.classify(validData)
    samples.verify(nb, guess, validLabels)
Exemplo n.º 3
0
def testing(num):
    trainData = samples.loadImagesFile("data/digitdata/trainingimages", num, 28, 28)
    trainLabels = samples.loadLabelsFile("data/digitdata/traininglabels", num)
    testData = samples.loadImagesFile("data/digitdata/testimages", 1000, 28, 28)
    testLabels = samples.loadLabelsFile("data/digitdata/testlabels", 1000)
    validData = samples.loadImagesFile("data/digitdata/validationimages", 1000, 28, 28)
    validLabels = samples.loadLabelsFile("data/digitdata/validationlabels", 1000)

    nb = NaiveBayesClassifier(1,0)
    nb.train(trainData, trainLabels)
    print "==================================="
    print "Test Data"
    guess = nb.classify(testData)
    samples.verify(nb,guess,testLabels)
    print "==================================="
    print "Validation Data"
    guess=nb.classify(validData)
    samples.verify(nb,guess,validLabels)
def testing(num):
    trainData = samples.loadImagesFile("data/facedata/facedatatrain", num, 60, 70)
    trainLabels = samples.loadLabelsFile("data/facedata/facedatatrainlabels", num)
    testData = samples.loadImagesFile("data/facedata/facedatatest", 150, 60, 70)
    testLabels = samples.loadLabelsFile("data/facedata/facedatatestlabels", 151)
    validData = samples.loadImagesFile("data/facedata/facedatavalidation", 301, 60, 70)
    validLabels = samples.loadLabelsFile("data/facedata/facedatavalidationlabels", 301)

    perceptron=PerceptronClassifier(trainData, trainLabels,0)
    perceptron.train(trainData, trainLabels,10)
    print "==================================="
    print "Test Data"
    guess=perceptron.classify(testData)
    samples.verify(perceptron, guess, testLabels)
    print "==================================="
    print "Validation Data"
    guess=perceptron.classify(validData)
    samples.verify(perceptron,guess,validLabels)
def testing(num):
    trainData = samples.loadImagesFile("data/digitdata/trainingimages", num, 28, 28)
    trainLabels = samples.loadLabelsFile("data/digitdata/traininglabels", num)
    testData = samples.loadImagesFile("data/digitdata/testimages", 1000, 28, 28)
    testLabels = samples.loadLabelsFile("data/digitdata/testlabels", 1000)
    validData = samples.loadImagesFile("data/digitdata/validationimages", 1000, 28, 28)
    validLabels = samples.loadLabelsFile("data/digitdata/validationlabels", 1000)

    perceptron=PerceptronClassifier(trainData, trainLabels,0)
    perceptron.train(trainData, trainLabels,10)
    print "***********************************"
    print "*************Test Data*************"
    guess=perceptron.classify(testData)
    samples.verify(perceptron, guess, testLabels)
    print "***********************************"
    print "************Valid Data*************"
    guess=perceptron.classify(validData)
    samples.verify(perceptron,guess,validLabels)
def testing(num):
    trainData = samples.loadImagesFile("data/digitdata/trainingimages", num, 28, 28)
    trainLabels = samples.loadLabelsFile("data/digitdata/traininglabels", num)
    testData = samples.loadImagesFile("data/digitdata/testimages", 1000, 28, 28)
    testLabels = samples.loadLabelsFile("data/digitdata/testlabels", 1000)
    validData = samples.loadImagesFile("data/digitdata/validationimages", 1000, 28, 28)
    validLabels = samples.loadLabelsFile("data/digitdata/validationlabels", 1000)

    perceptron=PerceptronClassifier(trainData, trainLabels,0)
    perceptron.train(trainData, trainLabels,10)
    print "==================================="
    print "Test Data"
    guess=perceptron.classify(testData)
    samples.verify(perceptron, guess, testLabels)
    print "==================================="
    print "Validation Data"
    guess=perceptron.classify(validData)
    samples.verify(perceptron,guess,validLabels)
Exemplo n.º 7
0
def testing(num):
    trainData = samples.loadImagesFile("data/facedata/facedatatrain", num, 60,
                                       70)
    trainLabels = samples.loadLabelsFile("data/facedata/facedatatrainlabels",
                                         num)
    testData = samples.loadImagesFile("data/facedata/facedatatest", 150, 60,
                                      70)
    testLabels = samples.loadLabelsFile("data/facedata/facedatatestlabels",
                                        151)
    validData = samples.loadImagesFile("data/facedata/facedatavalidation", 301,
                                       60, 70)
    validLabels = samples.loadLabelsFile(
        "data/facedata/facedatavalidationlabels", 301)

    nb = NaiveBayesClassifier(1, 0)
    nb.train(trainData, trainLabels)
    print "***********************************"
    print "************Test Data**************"
    guess = nb.classify(testData)
    samples.verify(nb, guess, testLabels)
    print "***********************************"
    print "***********Valid Data**************"
    guess = nb.classify(validData)
    samples.verify(nb, guess, validLabels)
Exemplo n.º 8
0
def testing(num):
    trainData = samples.loadImagesFile("data/facedata/facedatatrain", num, 60,
                                       70)
    trainLabels = samples.loadLabelsFile("data/facedata/facedatatrainlabels",
                                         num)
    testData = samples.loadImagesFile("data/facedata/facedatatest", 150, 60,
                                      70)
    testLabels = samples.loadLabelsFile("data/facedata/facedatatestlabels",
                                        151)
    validData = samples.loadImagesFile("data/facedata/facedatavalidation", 301,
                                       60, 70)
    validLabels = samples.loadLabelsFile(
        "data/facedata/facedatavalidationlabels", 301)

    perceptron = PerceptronClassifier(trainData, trainLabels, 0)
    perceptron.train(trainData, trainLabels, 10)
    print "==================================="
    print "Test Data"
    guess = perceptron.classify(testData)
    samples.verify(perceptron, guess, testLabels)
    print "==================================="
    print "Validation Data"
    guess = perceptron.classify(validData)
    samples.verify(perceptron, guess, validLabels)
Exemplo n.º 9
0
import samples
import features
import numpy as np

if __name__ == "__main__":
    trainData = samples.loadImagesFile("data/digitdata/trainingimages", 5000, 28, 28)
    trainBF=features.batchExtract(trainData,0)
    np.save("traindigitbasic",trainBF)
    testData = samples.loadImagesFile("data/digitdata/testimages", 1000, 28, 28)
    testBF=features.batchExtract(testData,0)
    np.save("testdigitbasic",testBF)
    validData = samples.loadImagesFile("data/digitdata/validationimages", 1000, 28, 28)
    validBF=features.batchExtract(validData,0)
    np.save("validationdigitbasic",validBF)

    trainAF=features.batchExtract(trainData,1)
    np.save("traindigitadvanced",trainAF)
    testAF=features.batchExtract(testData,1)
    np.save("testdigitadvanced",testAF)
    validAF=features.batchExtract(validData,1)
    np.save("validationdigitadvanced",validAF)

    trainData = samples.loadImagesFile("data/facedata/facedatatrain", 451, 60, 70)
    trainBF=features.batchExtract(trainData,0)
    np.save("trainfacebasic",trainBF)
    testData = samples.loadImagesFile("data/facedata/facedatatest", 150, 60, 70)
    testBF=features.batchExtract(testData,0)
    np.save("testfacebasic",testBF)
    validData = samples.loadImagesFile("data/facedata/facedatavalidation", 301, 60, 70)
    validBF=features.batchExtract(validData,0)
    np.save("validationfacebasic",validBF)
Exemplo n.º 10
0
import samples
import features
import numpy as np

if __name__ == "__main__":
    trainData = samples.loadImagesFile("data/digitdata/trainingimages", 5000,
                                       28, 28)
    trainBF = features.batchExtract(trainData, 0)
    np.save("traindigitbasic", trainBF)
    testData = samples.loadImagesFile("data/digitdata/testimages", 1000, 28,
                                      28)
    testBF = features.batchExtract(testData, 0)
    np.save("testdigitbasic", testBF)
    validData = samples.loadImagesFile("data/digitdata/validationimages", 1000,
                                       28, 28)
    validBF = features.batchExtract(validData, 0)
    np.save("validationdigitbasic", validBF)

    trainAF = features.batchExtract(trainData, 1)
    np.save("traindigitadvanced", trainAF)
    testAF = features.batchExtract(testData, 1)
    np.save("testdigitadvanced", testAF)
    validAF = features.batchExtract(validData, 1)
    np.save("validationdigitadvanced", validAF)

    trainData = samples.loadImagesFile("data/facedata/facedatatrain", 451, 60,
                                       70)
    trainBF = features.batchExtract(trainData, 0)
    np.save("trainfacebasic", trainBF)
    testData = samples.loadImagesFile("data/facedata/facedatatest", 150, 60,
                                      70)