Exemplo n.º 1
0
 def test_configuration(self, conf_dict):
     params = Params.ConfigurableParams(conf_dict)
     print("[GridSearch] Starting CrossValidation with id {}".format(
         params.ID))
     name = self.model_name + "_" + str(params.ID)
     cv = KFoldCrossValidation(self.train_set,
                               self.train_labels,
                               params=params,
                               K=Params.NUM_FOLDS,
                               model_name=name)
     try:
         cv.perform()
         cv.dump()
         self.results[name] = cv.mean_accuracy
         print("{}\t{}".format(name, cv.mean_accuracy))
     except:
         print("[RandomSearch] Problem with CrossValidation with id {}".
               format(params.ID))
         cv.report_error()
     print("[GridSearch] Ended CrossValidation with id {}".format(
         params.ID))
Exemplo n.º 2
0
    validation_s = MLCUP2017.cup_validation_set
    validation_l = MLCUP2017.cup_validation_labels

    mues = MLCUP2017.mean_per_attribute_dataset[len(train_s[0]) + 1:]
    sigmas = MLCUP2017.std_per_attribute_dataset[len(train_s[0]) + 1:]

    print("mues {}".format(mues))
    print("sigmas {}".format(sigmas))

    for model_name, params_dict in best_models_with_high_epochs:

        model_name = os.path.basename(model_name)

        print("MODEL {}".format(model_name))

        params = Params.ConfigurableParams(params_dict)
        params.MAX_EPOCH = int(params_dict["mean epochs"])

        myNN = NeuralNetwork.NeuralNetwork(params)

        for size in params.LAYERS_SIZE:
            myNN.addLayer(size)

        myNN.set_train(train_s, train_l)
        myNN.set_validation(validation_s, validation_l)

        myNN.learn()

        Plotting.plot_loss_accuracy_per_epoch(myNN)

        a = Statistics.MEELoss()