Example #1
0
def run_osvm_ova(chunks, dataset_name='unnamed_dataset'):
    print('OSVM ONE VERSUS ALL: %s' % dataset_name)
    printer = Printer(prefix="osvm_target_%s_" % dataset_name)
    start = time.time()
    printer.print_write("\n============================================")
    printer.print_write("============================================")
    printer.print_write("Algoritmo: One-Class Support Vector Machine (OSVM)")
    printer.print_write("Dataset: %s" % dataset_name)
    printer.print_write("# total de atributos: %d" % reduce(sum_attrs, chunks))
    printer.print_write("# total de exemplos: %d" %
                        reduce(sum_instances, chunks))
    printer.print_write(
        "Treino: Apenas com exemplos da classe de interese, estratégia One Versus All"
    )
    printer.print_write("Teste: Com todos os exemplos")
    printer.print_write("============================================")
    printer.print_write("============================================\n")
    for i in range(len(chunks)):
        ova_start = time.time()
        printer.print_write("\n============================================")
        printer.print_write("Rodada %d do OVA" % i)
        printer.print_write("# total de atributos: %d" % chunks[i].shape[1])
        printer.print_write("# total de exemplos: %d" % chunks[i].shape[0])
        printer.print_write("============================================\n")
        osvm.run(
            chunks[i],
            np.concatenate([[elem for elem in chunk] for chunk in chunks]),
            printer)
        ova_end = time.time()
        printer.print_write("\nRodada %d do OVA finalizado em: %.2f segundos" %
                            (i, (ova_end - ova_start)))
    end = time.time()
    printer.print_write("\nFinalizado em: %.2f segundos" % (end - start))
    printer.close_write()
Example #2
0
def run_iforest_all(dataset, dataset_name='unnamed_dataset'):
    print('iForest com todas as classes %s' % dataset_name)
    printer = Printer(prefix="iforest_all_%s_" % dataset_name)
    start = time.time()
    printer.print_write("\n============================================")
    printer.print_write("Algoritmo: Isolation Forest (iForest)")
    printer.print_write("Dataset: %s" % dataset_name)
    printer.print_write("# total de atributos: %d" % dataset.shape[1])
    printer.print_write("# total de exemplos: %d" % dataset.shape[0])
    printer.print_write("Treino: Com todos os exemplos")
    printer.print_write("Teste: Com todos os exemplos")
    printer.print_write("============================================\n")
    iforest.run(dataset, [], printer)
    end = time.time()
    printer.print_write("\nFinalizado em: %.2f segundos" % (end - start))
    printer.close_write()
Example #3
0
def run_osvm_all(dataset, dataset_name='unnamed_dataset'):
    print('OSVM com todas as classes %s' % dataset_name)
    printer = Printer(prefix="osvm_all_%s_" % dataset_name)
    start = time.time()
    printer.print_write("\n============================================")
    printer.print_write("Algoritmo: One-Class Support Vector Machine (OSVM)")
    printer.print_write("Dataset: %s" % dataset_name)
    printer.print_write("# total de atributos: %d" % dataset.shape[1])
    printer.print_write("# total de exemplos: %d" % dataset.shape[0])
    printer.print_write("Treino: Com todos os exemplos")
    printer.print_write("Teste: Com todos os exemplos")
    printer.print_write("============================================\n")
    osvm.run(dataset, [], printer)
    end = time.time()
    printer.print_write("\nFinalizado em: %.2f segundos" % (end - start))
    printer.close_write()