Command line

Installing EvoDAG puts four commands on your PATH:

Command Purpose
EvoDAG-params search the parameter space at random and store what it found
EvoDAG-train train a model (or an ensemble) and store it in a file
EvoDAG-predict load a model and predict a data set
EvoDAG-utils inspect models and parameter files, and combine models

All four accept -h / --help, --version (prints EvoDAG and the version), and --verbose LEVEL, which sets the level of the EvoDAG logger from the standard logging module as an integer (10 shows debug messages, 20 informational ones). -u / --cpu-cores is the number of processes to use.

A short session

Take a comma separated file train.csv without a header, one example per row, the class in the last column, and a file test.csv with the same columns except the class.

# train an ensemble of 30 models with the default parameters
EvoDAG-train -C -n 30 -u 4 -m model.evodag train.csv

# predict the test set, one class per line
EvoDAG-predict -m model.evodag -o predictions.txt test.csv

To let EvoDAG look for good parameters first, run the search and give its output to EvoDAG-train:

EvoDAG-params -C -r 734 -u 4 -P params.json train.csv
EvoDAG-train -P params.json -n 30 -u 4 -m model.evodag train.csv

Data formats

CSV

A CSV file has one example per line and the values separated by commas, with no header line. Blank lines are skipped, and a file whose name ends in .gz is read compressed.

  • Training files (EvoDAG-params, EvoDAG-train): the last column is the target, either a class or, for regression, a real number. A value in a feature column that is not a number is replaced by an integer that identifies that text; the correspondence is stored with the model, so that the same text maps to the same number when predicting.
  • Class labels that are numbers are used as such. Labels that are text are replaced by integers while training and mapped back to your text by EvoDAG-predict. When the labels are numbers the predictions are printed as numbers, for example 1.0.
  • Files to predict, and the test set of EvoDAG-train: only features, with no target column. The number of columns must not be smaller than the number used for training.
  • Several targets: with --output-dim k the last k columns are k real targets (see --output-dim below).

JSON

With -j / --json the file has one JSON object per line. There are two layouts.

The first one gives each feature as a key that is the position of the feature written as a string; features that are missing count as zero, which makes it a convenient way to write sparse data. The target is under the key klass. The number of features is the number of keys (minus one for klass) unless the object has a key num_terms:

{"0": 1.5, "3": 0.25, "klass": "spam", "num_terms": 4}

The second layout gives all the features in a list under the key vec:

{"vec": [1.5, 0.0, 0.0, 0.25], "klass": "spam"}

If an object has both vec and vecsize, vec is read as a list of [position, value] pairs of a vector with vecsize positions, again sparse. The environment variables KLASS and VEC change the names klass and vec.

EvoDAG-params

Samples points from the space of parameters, trains EvoDAG with each one on the training set (three runs with different seeds) and writes the configurations sorted by the median fitness on the validation part, best first. The output is a JSON list; each element is a full set of parameters plus its fitness (the three values obtained) and the time that it took. The space that is sampled is parameter_values.json, described in Parameters. For classification every configuration has the random selection of the arguments and the random choice of the individual that leaves; with -R those two keys are left out.

EvoDAG-params [-C | -R] [-r N] [-P FILE] [options] training_set
Option Meaning
training_set the training file (positional)
-C, --classifier the task is classification (one of -C or -R is required)
-R, --regressor the task is regression
-r N, --optimize-parameters N number of points to sample; 734 by default
-P FILE, --parameters FILE where to write the result; training_set.EvoDAGparams if omitted (a name ending in .gz is compressed)
--parameters-values FILE a JSON file with the values to sample, instead of parameter_values.json
--output-dim K number of targets at the end of each row; 1 by default
--only-paramsfiles do not train anything: write each sampled configuration as N_params.json inside a new directory named by -P
-e N, --early_stopping_rounds N fix this parameter to N during the search
-p N, --popsize N fix the population size to N during the search
-s N, --seed N seed of the sampling; 0 by default
--time-limit SECONDS fix the time limit
-j, --json the training file is JSON
-u N, --cpu-cores N processes to use; 1 by default
--version, --verbose LEVEL, -h, --help as for every command

EvoDAG-train

Trains the model and stores it. Models are stored with pickle in a gzip file, together with the correspondence of text values to numbers.

EvoDAG-train (-C | -R | -P FILE) [-n N] [-m FILE] [options] training_set
Option Meaning
training_set the training file (positional)
-C, --classifier classification with the default parameters (default_parameters.json, described in Parameters: the random choice of the arguments and of the individual that leaves, and macro-F1 as fitness)
-R, --regressor regression with the default parameters (default_parameters_r.json, the ordinary selections)
-P FILE, --parameters FILE use the parameters of a file written by EvoDAG-params; the first configuration (the best) is used. The task is read from the file; -C, -R and -P are mutually exclusive, and one of them is required
--kw JSON a JSON object with parameters that override the defaults, for instance --kw '{"popsize": 500}'
-n N, --ensemble-size N number of models in the ensemble; 30 by default. With -n 1 a single model is trained
-m FILE, --model FILE where to store the model; the training file name up to its first dot followed by .evodag.gz if omitted
-t FILE, --test_set FILE a test set, in the format of the files to predict, evaluated while the models are trained
-s N, --seed N seed of the first model (the next ones use the following integers); when omitted, the seed in the parameters is used (0 by default)
--output-dim K number of targets at the end of each row; 1 by default. For several real targets use it with -R and --kw '{"multiple_outputs": true}'
-j, --json the training file is JSON
-u N, --cpu-cores N processes used to train the ensemble; 1 by default
--version, --verbose LEVEL, -h, --help as for every command

While an ensemble is trained, the models that are done are written to a directory named after the model file with _dir appended, which is removed when the training ends. Because of that, a training that was interrupted can be started again with the same command and goes on from the models that were finished.

EvoDAG-predict

Loads a model written by EvoDAG-train and predicts a file.

EvoDAG-predict -m FILE [-o FILE] [options] test_set
Option Meaning
test_set the file to predict (positional), features only
-m FILE, --model FILE the model
-o FILE, --output-file FILE where to write the predictions; test_set.evodag.csv if omitted
--predict-proba write, for each example, the probability of each class (the fraction of the models that vote for it)
--decision-function write the decision function (the median of the models’ outputs) instead of the class
--raw-outputs write the outputs of every model, side by side
-j, --json the file to predict is JSON
-u N, --cpu-cores N processes used to evaluate the models; 1 by default
--version, --verbose LEVEL, -h, --help as for every command

By default the output has one line per example with the class (or, for regression, the predicted value). The other three options write the values of each example in one line, separated by commas. --predict-proba and --raw-outputs need an ensemble, that is a model trained with -n greater than 1.

EvoDAG-utils

A collection of small tools. Which one runs depends on the flag; only the first of these flags found is used, in the order of the table.

EvoDAG-utils [flag] [-o FILE] model_file
Option Meaning
model_file the model or the parameters file (positional)
-G, --graphviz write the model in the dot language to the file given with -o (for an ensemble -o is a directory with one file per model)
--remove-terminals with -G, leave the input variables out of the graph
-P, --params-stats model_file is a parameters file from EvoDAG-params; write to -o, as JSON, the most common value of each parameter
--fitness print the median error of the models on their validation part
--size print the median number of nodes of the models
--height print the median height of the models
--used-inputs-number print how many different inputs the model uses
--create-ensemble model_file is a list of model files, separated by spaces, that may contain wildcards; combine them into one ensemble written to -o
-n N, --ensemble-size N with --create-ensemble, keep only the N models with the best validation fitness; all by default
--best-params-file model_file is a directory of model files named K_<anything>.model, where K is the number of a configuration written by EvoDAG-params --only-paramsfiles (for instance one model per seed); it prints the name K_params.json of the configuration whose models have the best median validation fitness
-o FILE, --output-file FILE the output file or directory
-u N, --cpu-cores N processes to use; 1 by default
--version, --verbose LEVEL, -h, --help as for every command