Exemplo n.º 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()
Exemplo n.º 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
Exemplo n.º 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)))
Exemplo n.º 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
Exemplo n.º 5
0
        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)
Exemplo n.º 6
0
def predict():
    train_data = return_train_data()
    test_data = return_test_data()
    model = submission(train_data)

    print test_data[0]