Ejemplo n.º 1
0
def find_solution(P, T):
                
    #test, validation = get_validation_set(P, T, validation_size = 0.33)
    net = build_feedforward(input_number = len(P[0]), hidden_number = 4, output_number = len(T[0]))
    #com = build_feedforward_committee(size = 4, input_number = len(P[0]), hidden_number = 6, output_number = len(T[0]))
    
    epochs = 1000
    
    testset, valset = get_validation_set(P, T, validation_size = 0.01)
    
    print("Training...")
    net = benchmark(train_evolutionary)(net, testset, valset, 100, random_range = 1)
    net = benchmark(traingd)(net, testset, valset, epochs, learning_rate = 0.1, block_size = 1)
    
    #benchmark(train_committee)(com, train_evolutionary, P, T, 100, random_range = 1)
    #benchmark(train_committee)(com, traingd, P, T, epochs, learning_rate = 0.1, block_size = 30)
    
    #P, T = test
    Y = net.sim(P)
    area, best_cut = plotroc(Y, T, 1)
    plot2d2c(net, P, T, figure = 2, cut = best_cut)
    
    #P, T = validation
    #Y = com.sim(P)
    #plotroc(Y, T, 2)
    
#    print("")
#    print("Stats for cut = 0.5")
#    [num_correct_first, num_correct_second, total_performance, num_first, num_second, missed] = stat(Y, T)
    
    #save_network(best, "/export/home/jonask/Projects/aNeuralN/ANNs/classification_gdblock20_rocarea" + str(area) + ".ann")
    #save_network(best, "/export/home/jonask/Projects/aNeuralN/ANNs/classification_genetic_rocarea" + str(area) + ".ann")
    #save_committee(com, "/export/home/jonask/Projects/aNeuralN/ANNs/classification_gdblock30_rocarea" + str(area) + ".anncom")
    #save_committee(com, "/export/home/jonask/Projects/aNeuralN/ANNs/classification_genetic_rocarea" + str(area) + ".anncom")
    
    plt.show()