Commit dd24d8c5 authored by tpetaja1's avatar tpetaja1
Browse files

results handling

parent 409fc927
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
*.pyc
*~
drafts/*
results/*
network_results/*
results/*.csv
network_results/*.csv
matlab/*
+33 −27
Original line number Diff line number Diff line
@@ -164,47 +164,53 @@ class DataHandler(object):
                    f.write("\n")
                f.write("\n\n")

    def write_results(self, datafile, alg_type, alg):
    def write_results(self, datafile, alg_type, alg, splitter=','):
        run_time = datetime.datetime.now()
        results_name = "results/%s_di%sbl%sob%sla%sbe%s_%s.txt" % (
            alg_type, alg.dimension, alg.blocks, alg.obs, alg.lambd,
            alg.beta, run_time.strftime("%Y%m%d%H%M%S"))
        results_name = "results/%s_di%sbl%sob%sla%sbe%s_%s.csv" % (
            alg_type, alg.dimension, alg.blocks, alg.obs, int(alg.lambd),
            int(alg.beta), run_time.strftime("%Y%m%d%H%M%S"))
        with open(results_name, "w") as f:
            f.write("# Information\n")
            f.write("Run datetime: %s\n" %
            f.write("Run datetime, %s\n" %
                    run_time.strftime("%Y-%m-%d %H:%M:%S"))
            f.write("Data file: %s\n" % datafile)
            f.write("Algorithm type: %s\n" % alg.__class__.__name__)
            f.write("Penalty function: %s\n" % alg.penalty_function)
            f.write("Data dimension: %s\n" % alg.dimension)
            f.write("Blocks: %s\n" % alg.blocks)
            f.write("Observations in a block: %s\n" % alg.obs)
            f.write("Rho: %s\n" % alg.rho)
            f.write("Beta: %s\n" % alg.beta)
            f.write("Lambda: %s\n" % alg.lambd)
            f.write("Processes used: %s\n" % alg.processes)
            f.write("Total edges: %s\n" % alg.real_edges)
            f.write("Total edgeless: %s\n" % alg.real_edgeless)
            f.write("Data file, %s\n" % datafile)
            f.write("Algorithm type, %s\n" % alg.__class__.__name__)
            f.write("Penalty function, %s\n" % alg.penalty_function)
            f.write("Data dimension, %s\n" % alg.dimension)
            f.write("Blocks, %s\n" % alg.blocks)
            f.write("Observations in a block, %s\n" % alg.obs)
            f.write("Rho, %s\n" % alg.rho)
            f.write("Beta, %s\n" % alg.beta)
            f.write("Lambda, %s\n" % alg.lambd)
            f.write("Processes used, %s\n" % alg.processes)
            f.write("Total edges, %s\n" % alg.real_edges)
            f.write("Total edgeless, %s\n" % alg.real_edgeless)
            f.write("\n")
            f.write("# Results\n")
            f.write("Algorithm run time: %s seconds\n" % alg.run_time)
            f.write("Iterations to complete: %s\n\n" % alg.iteration)
            f.write("Correct positive edges: %s\n" % alg.correct_positives)
            f.write("All positives: %s\n" % alg.all_positives)
            f.write("F1 Score: {0:.3f}\n"
            f.write("Algorithm run time, %s seconds\n" % alg.run_time)
            f.write("Iterations to complete, %s\n\n" % alg.iteration)
            f.write("Correct positive edges, %s\n" % alg.correct_positives)
            f.write("All positives, %s\n" % alg.all_positives)
            f.write("F1 Score, {0:.3f}\n"
                    .format(alg.f1score))
            try:
                f.write("Temporal deviations ratio (max/mean): {0:.3f}\n"
                f.write("Temporal deviations ratio (max/mean), {0:.3f}\n"
                        .format(alg.dev_ratio))
            except ValueError:
                f.write("Temporal deviations ratio (max/mean): %s\n"
                f.write("Temporal deviations ratio (max/mean), %s\n"
                        % alg.dev_ratio)
            f.write("Temporal deviations: ")
            f.write("Temporal deviations ")
            for dev in alg.deviations:
                try:
                    f.write("{0:.3f} ".format(dev))
                    f.write(",{0:.3f}".format(dev))
                except ValueError:
                    f.write("%s" % dev)
                    f.write(",%s" % dev)
            f.write("\nNormalized Temporal deviations ")
            for dev in alg.norm_deviations:
                try:
                    f.write(",{0:.3f}".format(dev))
                except ValueError:
                    f.write(",%s" % dev)
            f.write("\n")


+1 −0
Original line number Diff line number Diff line
Results from real data are saved into this folder.
+0 −24
Original line number Diff line number Diff line
# Information
Run datetime: 2017-09-07 00:10:12
Data file: synthetic_data/1000x20_20170823203622.csv
Algorithm type: DynamicGL
Penalty function: n/a
Data dimension: 20
Blocks: 50
Observations in a block: 20
Rho: 21
Beta: 0
Lambda: 22
Processes used: 25
Total edges: 1000
Total edgeless: 8500

# Results
Algorithm run time: 0.555 seconds
Iterations to complete: n/a

Correct positive edges: 406
All positives: 667
F1 Score: 0.487
Temporal deviations ratio (max/mean): 2.194
Temporal deviations: 0.666 0.409 0.563 0.261 0.433 0.503 0.460 0.433 0.396 0.506 0.475 0.383 0.676 0.581 0.519 0.566 0.405 0.449 0.453 0.346 0.542 0.445 0.489 0.535 1.000 0.441 0.437 0.445 0.581 0.485 0.365 0.542 0.478 0.413 0.478 0.396 0.482 0.456 0.441 0.482 0.341 0.392 0.355 0.274 0.226 0.437 0.280 0.325 0.286 
+0 −24
Original line number Diff line number Diff line
# Information
Run datetime: 2017-09-07 00:09:08
Data file: synthetic_data/1000x20_20170823203622.csv
Algorithm type: ParallelTVGL
Penalty function: Group Lasso
Data dimension: 20
Blocks: 50
Observations in a block: 20
Rho: 6.7
Beta: 50
Lambda: 7
Processes used: 25
Total edges: 1000
Total edgeless: 8500

# Results
Algorithm run time: 16.2 seconds
Iterations to complete: 1622

Correct positive edges: 873
All positives: 884
F1 Score: 0.927
Temporal deviations ratio (max/mean): 26.417
Temporal deviations: 0.000 0.000 0.000 0.053 0.000 0.053 0.000 0.000 0.000 0.000 0.000 0.000 0.053 0.000 0.074 0.053 0.000 0.053 0.000 0.000 0.000 0.000 0.000 0.053 1.000 0.053 0.074 0.053 0.000 0.053 0.053 0.000 0.000 0.000 0.053 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.053 0.074 
Loading