예제 #1
0
 def test_submission(self):
     train_data = extract_features(load_adult_train_data())
     valid_data = extract_features(load_adult_valid_data())
     model = submission(train_data)
     predictions = [predict(model, p) for p in train_data]
     print
     print
     print "Training Accuracy:", accuracy(train_data, predictions)
     predictions = [predict(model, p) for p in valid_data]
     print "Validation Accuracy:", accuracy(valid_data, predictions)
     print
예제 #2
0
 def test_submission(self):
     train_data = extract_features(load_adult_train_data())
     valid_data = extract_features(load_adult_valid_data())
     model = submission(train_data)
     predictions = [predict(model, p) for p in train_data]
     print()
     print()
     print("Training Accuracy:", accuracy(train_data, predictions))
     predictions = [predict(model, p) for p in valid_data]
     print("Validation Accuracy:", accuracy(valid_data, predictions))
     print()
예제 #3
0
 def test_submission(self):
     """Overall test.
     """
     train_data = extract_features(load_adult_train_data())
     valid_data = extract_features(load_adult_valid_data())
     model = submission(train_data)
     predictions = [predict(model, p) for p in train_data]
     print("Training Accuracy: {0}".format(
         accuracy(train_data, predictions)))
     predictions = [predict(model, p) for p in valid_data]
     print("Validation Accuracy: {0}".format(
         accuracy(valid_data, predictions)))
예제 #4
0
def test_submission():
    valid_data = test_data
    model = submission(train_data)
    predictions = [predict(model, p) for p in train_data]
    print
    print
    # print predictions
    train_accuracy = accuracy(train_data, predictions)
    print "Training Accuracy:", train_accuracy
    # print train_data
    predictions = [predict(model, p) for p in valid_data]
    valid_accuracy = accuracy(valid_data, predictions)
    print "Validation Accuracy:", valid_accuracy
    print
    return train_accuracy, valid_accuracy
예제 #5
0
    def test_neural_net(self):
        print "Testing neural net.."
        print
        #getting data using 80% of data as training.
        #If you want to test soething other than 3 vs 5, just change the input to loadmnist.
        #For example, loadmnist(1, 7)
        data = loadmnist(3, 5)
        train_data = data[:int(len(data)*0.8)]
        validation_data =data[int(len(data)*0.8):]

        #train the model
        m = neural_net(train_data)

        #evaluate
        predictions = [m.predict(p) for p in train_data]
        print "Training Accuracy:", accuracy(train_data, predictions)
        predictions = [m.predict(p) for p in validation_data]
        print "Validation Accuracy:", accuracy(validation_data, predictions)
예제 #6
0
    def test_neural_net(self):
        print "Testing neural net.."
        print
        #getting data using 80% of data as training.
        #If you want to test soething other than 3 vs 5, just change the input to loadmnist.
        #For example, loadmnist(1, 7)
        data = loadmnist(3, 5)
        train_data = data[:int(len(data)*0.8)]
        validation_data =data[int(len(data)*0.8):]

        #train the model
        m = neural_net(train_data)

        #evaluate
        predictions = [m.predict(p) for p in train_data]
        print "Training Accuracy:", accuracy(train_data, predictions)
        predictions = [m.predict(p) for p in validation_data]
        print "Validation Accuracy:", accuracy(validation_data, predictions)
예제 #7
0
 def test_accuracy(self):
     data = extract_features(load_adult_train_data())
     a = accuracy(data, [0.4]*len(data))
     self.assertAlmostEqual(a, 0.751077514754)
예제 #8
0
 def test_accuracy(self):
     data = extract_features(load_adult_train_data())
     a = accuracy(data, [0]*len(data))
     self.assertAlmostEqual(a, 0.751077514754)
예제 #9
0
 def test_accuracy(self):
     data = [dict([('label',np.matrix([1]))]) for i in range(25)]+[dict([('label',np.matrix([0]))]) for i in range(75)]
     a = accuracy(data, [np.matrix([0]) for i in range(len(data))])
     self.assertAlmostEqual(a, 0.75)
예제 #10
0
파일: app.py 프로젝트: knightx7/challenger
        max_num_faces = max(max_num_faces, len(item_dict))

        # predict for result of one picture
        predictions = []
        for i in range(0, len(item_dict)):
            face = {}
            face["faceRectangle"] = item_dict[i]["faceRectangle"]
            face["result"] = (predict(
                model, extract_features_single_point(item_dict[i]["scores"]))
                              >= 0.5)
            predictions.append(face)
        predictions_all.append(predictions)

    print max_num_faces
    return predictions_all, max_num_faces


if __name__ == "__main__":
    # prepare the model
    train_data = extract_features(load_adult_train_data())
    model = submission(train_data)
    print model
    predictions = [predict(model, p) for p in train_data]
    print
    print
    print "Training Accuracy:", accuracy(train_data, predictions)

    app.run(host='ec2-52-206-17-234.compute-1.amazonaws.com',
            port=8000,
            threaded=True)
예제 #11
0
def test_accuracy():
    data = train_data
    a = accuracy(data, [0] * len(data))
예제 #12
0
 def test_accuracy(self):
     """Tests the accuracy calculation.
     """
     data = extract_features(load_adult_train_data())
     a = accuracy(data, [0] * len(data))
     self.assertAlmostEqual(a, 0.7636129)
예제 #13
0
 def test_accuracy(self):
     data = [dict([('label',np.matrix([1]))]) for i in range(25)]+[dict([('label',np.matrix([0]))]) for i in range(75)]
     a = accuracy(data, [np.matrix([0]) for i in range(len(data))])
     self.assertAlmostEqual(a, 0.75)