Exemplo n.º 1
0
            labels.append(label)
        for i in range(0, 10):
            arr = [random.randint(10, 20) * np.sign(random.random() - 0.5) for x in range(0, 2)]
            label = 'yes'  # Note: this is artificially misclassified
            arrs.append(arr)
            labels.append(label)
             
        ann = Ann(arrs, labels, n_h=2)
        (models, test_accuracies, test_costs) = ann.train()
         
        best_test_accuracy = 0
        best_i = -1
        for i in range(0, len(test_accuracies)):
            if (test_accuracies[i] > best_test_accuracy):
                best_test_accuracy = test_accuracies[i]
                best_i = i
                 
        if (best_i > -1):
            model_name = models[i].name
            directory = '../Ann-models'
            path_to_file = directory + '/' + model_name
            if not os.path.exists(directory):
                os.makedirs(directory)
            pickle.dump(models[i], open(path_to_file, 'wb'))
        else:
            logger.error('Error!')
    
if __name__ == "__main__":
    Ann.init_logger('debug')
    unittest.main()
                for x in range(0, 2)
            ]
            label = 'yes'  # Note: this is artificially misclassified
            arrs.append(arr)
            labels.append(label)

        ann = Ann(arrs, labels, n_h=2)
        (models, test_accuracies, test_costs) = ann.train()

        best_test_accuracy = 0
        best_i = -1
        for i in range(0, len(test_accuracies)):
            if (test_accuracies[i] > best_test_accuracy):
                best_test_accuracy = test_accuracies[i]
                best_i = i

        if (best_i > -1):
            model_name = models[i].name
            directory = '../Ann-models'
            path_to_file = directory + '/' + model_name
            if not os.path.exists(directory):
                os.makedirs(directory)
            pickle.dump(models[i], open(path_to_file, 'wb'))
        else:
            logger.error('Error!')


if __name__ == "__main__":
    Ann.init_logger('debug')
    unittest.main()