def main(argv):
    train_set, test_set = data.readFile(argv[1])
    index, _data = getData(train_set)
    n_estimators = np.arange(0.1, 0.5, 0.01)
    for n_estimator in n_estimators:
        model = training(_data, argv[2], n_estimator)
    testing(model, test_set)
Ejemplo n.º 2
0
def refreshLevelData():
    objects.lvl_names, objects.times, objects.player_pos, objects.beatTimes = data.readFile('level data.txt')

    objects.levelButtonList = []
    objects.timeList = []
    for lvl in range(len(objects.lvl_names)):
        objects.levelButtonList.append(button.textButton('%s' %objects.lvl_names[lvl], 40, 0, -50))
        objects.timeList.append(button.textButton('%s s' %float(objects.times[lvl]), 30, 0, -50))
        objects.beatList.append(button.textButton('%s s' %float(objects.beatTimes[lvl]), 30, 0, -50))
Ejemplo n.º 3
0
def main(argv):
    training_set, testing_set = data.readFile(argv[1])
    training_X, training_y = features_labels(training_set)
    testing_X, testing_y = features_labels(testing_set)
    model, error = svm(training_X, training_y, testing_X, testing_y)
    print(error)
    print()
    model, error = gbr(training_X, training_y, testing_X, testing_y)
    print(error)
    print()
    model, error = rfr(training_X, training_y, testing_X, testing_y)
    print(error)
    print()
    model, error = mlr(training_X, training_y, testing_X, testing_y)
    print(error)
    print()
Ejemplo n.º 4
0
def main():

    global args, max_length
    args = parser.parse_args()

    if args.eval:

        if not os.path.exists(args.output_dir):
            print("Output directory do not exists")
            exit(0)
        try:
            model = EncoderDecoder().load(args.output_dir)
            print("Model loaded successfully")
        except:
            print("The trained model could not be loaded...")
            exit()

        test_pairs = readFile(args.test_file)

        outputs = model.evaluatePairs(test_pairs, rand=False, char=args.char)
        writeToFile(outputs, os.path.join(args.output_dir, "output.pkl"))
        reference = []
        hypothesis = []

        for (hyp, ref) in outputs:
            if args.char or args.char_bleu:
                reference.append([list(ref)])
                hypothesis.append(list(hyp))
            else:
                reference.append([ref.split(" ")])
                hypothesis.append(hyp.split(" "))

        bleu_score = compute_bleu(reference, hypothesis)
        print("Bleu Score: " + str(bleu_score))

        print(
            model.evaluateAndShowAttention(
                "L'anglais n'est pas facile pour nous.", char=args.char))
        print(
            model.evaluateAndShowAttention(
                "J'ai dit que l'anglais est facile.", char=args.char))
        print(
            model.evaluateAndShowAttention(
                "Je n'ai pas dit que l'anglais est une langue facile.",
                char=args.char))
        print(
            model.evaluateAndShowAttention("Je fais un blocage sur l'anglais.",
                                           char=args.char))

    else:
        input_lang, output_lang, pairs = prepareData(args.train_file)

        print(random.choice(pairs))

        if args.char:
            model = EncoderDecoder(args.hidden_size, input_lang.n_chars,
                                   output_lang.n_chars, args.drop, args.tfr,
                                   args.max_length, args.lr, args.simple,
                                   args.bidirectional, args.dot, False, 1)
        else:
            model = EncoderDecoder(args.hidden_size, input_lang.n_words,
                                   output_lang.n_words, args.drop, args.tfr,
                                   args.max_length, args.lr, args.simple,
                                   args.bidirectional, args.dot, args.multi,
                                   args.num_layers)

        model.trainIters(pairs,
                         input_lang,
                         output_lang,
                         args.n_iters,
                         print_every=args.print_every,
                         plot_every=args.plot_every,
                         char=args.char)
        model.save(args.output_dir)
        model.evaluatePairs(pairs, char=args.char)
Ejemplo n.º 5
0
import pygame
import button, data, funcs
from constants import *
pygame.font.init()

blockList = []
bulletList = []
enemyList = []
decalList = []
health_battery = []
barList = []
mainButtonList = [button.textButton('Choose Level', 20, WIN_WIDTH/2, (WIN_HEIGHT/2)-40),
                  button.textButton('Instructions', 20, WIN_WIDTH/2, (WIN_HEIGHT/2)),
                  button.textButton('Quit', 20, WIN_WIDTH/2, (WIN_HEIGHT/2)+40)]

lvl_names, times, player_pos, beatTimes = data.readFile('level data.txt')

levelButtonList = []
timeList = []
beatList = []
for level in range(len(lvl_names)):
    levelButtonList.append(button.textButton('%s' %lvl_names[level], 40, 0, -50))
    timeList.append(button.textButton('%s s' %float(times[level]), 30, 0, -50))
    beatList.append(button.textButton('%s s' %float(beatTimes[level]), 30, 0, -50))


pageButtonList = [button.textButton('<=', 30, 50, WIN_HEIGHT-50),
                  button.textButton('main', 20, WIN_WIDTH/2, WIN_HEIGHT-50),
                  button.textButton('=>', 30, WIN_WIDTH-50, WIN_HEIGHT-50)]
    
characterButtonList = []
import sys
import data
import models
import matplotlib.pyplot as plt

training_set, testing_set = data.readFile(sys.argv[1])
training_X, training_Y = models.features_labels(training_set)
testing_X, testing_Y = models.features_labels(testing_set)
model, err = models.gbr(training_X, training_Y, testing_X, testing_Y)
prediction = model.predict(testing_X)
diff = [testing_Y[i] - prediction[i] for i in range(len(testing_Y))]
plt.plot(testing_Y, diff, 'bo')
plt.axhline(0, color='red')
plt.savefig(r"figure_1.png")