54 lines
1.6 KiB
Python
Executable File
54 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
USAGE = """fx-csv: Creates CSV output from results.
|
|
|
|
Examples:
|
|
|
|
fx-csv knn_k ./main kfold/0/knn/params/k kfold/results/p_correct >knn_k.csv
|
|
fx-csv knn_k ./main kfold/*/knn/params/k kfold/*/results/p_correct
|
|
fx-csv knn_k ./main /params/knn/k kfold/*/results/p_correct
|
|
|
|
All of these look at results for all trials created from executable ./main
|
|
and the label "knn_k". Each path specified is a column in the resulting CSV
|
|
file. Each match found is saved as a row in the file.
|
|
|
|
The paths allow a little bit of flexibility with the * operator.
|
|
The * operator can be used in any position in the path names, and
|
|
just means to consider every directory in that path. It is okay to combine
|
|
paths with and without a * (as in the third example), and the result is to
|
|
show all combinations (for experienced database folk, this is similar in
|
|
idea to a database "natural join" operation.)
|
|
|
|
Another feature is that you can select only a subset. For example:
|
|
|
|
fx-csv knn_k ./main params/a=1 params/b results/val
|
|
|
|
gives you a csv with a, b, and val as the columns, but only selects rows
|
|
that contain a=1.
|
|
|
|
See also fx-latex for creating LaTeX tables.
|
|
|
|
"""
|
|
|
|
import pm
|
|
import util
|
|
import datastore
|
|
import fxsys
|
|
import fx # use FASTexec argument parsing
|
|
|
|
import sys
|
|
import os
|
|
|
|
if len(fx.extra_args) < 3:
|
|
print USAGE
|
|
sys.exit(1)
|
|
|
|
label = fx.extra_args[0]
|
|
exename = os.path.abspath(fx.extra_args[1])
|
|
paths = fx.extra_args[2:]
|
|
|
|
experiment = fxsys.SimpleExperiment(os.path.abspath("."), exename, label)
|
|
|
|
relative_paths = ["*/" + fxsys.OUTPUT_FNAME + ":/" + path.lstrip("/") for path in paths]
|
|
datastore.select_fields_to_csv_file(sys.stdout, experiment.path, relative_paths)
|