Command-line Interface

This section contains an overview of command-line applications shipped with this package.

sleepless

Sleep stage classification Benchmark commands.

sleepless [OPTIONS] COMMAND [ARGS]...

analyze

It is possible to pass one or several Python files (or names of sleepless.config entry points or module names) as CONFIG arguments to the command line which contain the parameters listed below as Python variables. The options through the command-line (see below) will override the values of configuration files. You can run this command with <COMMAND> -H example_config.py to create a template config file.

sleepless analyze [OPTIONS] [CONFIG]...

Options

-o, --output-folder <output_folder>

Required Path where to store the analysis (created if does not exist)

-d, --dataset <dataset>

Required A dictionary mapping string keys to a list of sleepless.data.sample.DelayedSample instances implementing datasets to be used for testing the model, possibly including all pre-processing pipelines required. All keys keys defined in the dictionary will be used.The prediction of the samples needs to be run before

-p, --prediction-folder <prediction_folder>

Required folder where prediction have been saved

--detailed

Detailed analysis

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

-H, --dump-config <dump_config>

Name of the config file to be generated

Arguments

CONFIG

Optional argument(s)

Examples:

1. Analyze of ST_subset (from EDF database) where prediction are already computed:
sleepless analyze stedf-filtered -p "/path/to/predictions" -o "/path/to/output_folder"

compare

sleepless compare [OPTIONS] [LABEL_PATH]...

Options

-o, --output-folder <output_folder>

Required Path where to store table and plot

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

Arguments

LABEL_PATH

Optional argument(s)

Examples:

1. Compares system A and B, with their own metric table files:
sleepless compare -vv A path/to/A/metric_table.csv B path/to/B/metric_table.csv

dataset

Commands for listing and verifying datasets.

sleepless dataset [OPTIONS] COMMAND [ARGS]...

check

Checks file access on one or more datasets.

sleepless dataset check [OPTIONS] [DATASET]...

Options

-l, --limit <limit>

Required Limit check to the first N samples in each dataset, making the check sensibly faster. Set it to zero to check everything.

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

Arguments

DATASET

Optional argument(s)

Examples:

1. Check if all files of the EDF dataset can be loaded:
sleepless dataset check -vv EDF
2. Check if all files of multiple installed datasets can be loaded:
sleepless dataset check -vv EDF MASS
3. Check if all files of all installed datasets can be loaded:
sleepless dataset check

list

Lists all supported and configured datasets.

sleepless dataset list [OPTIONS]

Options

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

Examples:

1. To install a dataset, set up its data directory (“datadir”). For
example, to setup access to EDF files you downloaded locally at
the directory “/path/to/edf/files”, edit the RC file (typically
$HOME/.config/sleepless.toml), and add a line like the following:
[datadir]
edf = "/path/to/edf/files"

Note

This setting is case-sensitive.

2. List all raw datasets supported (and configured):
sleepless dataset list

experiment

It is possible to pass one or several Python files (or names of sleepless.config entry points or module names) as CONFIG arguments to the command line which contain the parameters listed below as Python variables. The options through the command-line (see below) will override the values of configuration files. You can run this command with <COMMAND> -H example_config.py to create a template config file.

sleepless experiment [OPTIONS] [CONFIG]...

Options

-o, --output-folder <output_folder>

Required Path where to store the generated model (created if does not exist)

-d, --dataset <dataset>

Required A dictionary mapping string keys to a list of sleepless.data.sample.DelayedSample instances implementing datasets to be used for training and validating the model, possibly including all pre-processing pipelines required. At least one key named train must be available.

-m, --model <model>

Required An instance model to be trained

-mp, --model-parameters <model_parameters>

Required Parameters of model training

--detailed

Detailed analysis

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

-H, --dump-config <dump_config>

Name of the config file to be generated

Arguments

CONFIG

Optional argument(s)

Examples:

1. Run a experiment with a random forest model and with ST_subset (from EDF database):
sleepless analyze stedf-filtered rf-gs-mne -o "/path/to/output_folder"

predict

It is possible to pass one or several Python files (or names of sleepless.config entry points or module names) as CONFIG arguments to the command line which contain the parameters listed below as Python variables. The options through the command-line (see below) will override the values of configuration files. You can run this command with <COMMAND> -H example_config.py to create a template config file.

sleepless predict [OPTIONS] [CONFIG]...

Options

-o, --output-folder <output_folder>

Required Path where to store the predictions (created if does not exist)

-d, --dataset <dataset>

Required A dictionary mapping string keys to a list of sleepless.data.sample.DelayedSample instances implementing datasets to be used for testsing the model, possibly including all pre-processing pipelines required. All keys keys defined in the dictionary will be used.

-m, --model <model>

Required An instance model to be trained

-w, --weight <weight>

Required Path or URL to trained model file (pickle if scikit model)

-mp, --model-parameters <model_parameters>

Required Parameters of model training

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

-H, --dump-config <dump_config>

Name of the config file to be generated

Arguments

CONFIG

Optional argument(s)

Examples:

1. Compute prediction of ST_subset (from EDF database) based on a pre-trained model:
sleepless predict stedf-filtered -w /path/to/trained_model -o "/path/to/output_folder"

preprocess

It is possible to pass one or several Python files (or names of sleepless.config entry points or module names) as CONFIG arguments to the command line which contain the parameters listed below as Python variables. The options through the command-line (see below) will override the values of configuration files. You can run this command with <COMMAND> -H example_config.py to create a template config file.

sleepless preprocess [OPTIONS] [CONFIG]...

Options

-d, --dataset <dataset>

Required A dictionary mapping string keys to a list of sleepless.data.sample.DelayedSample instances implementing datasets to be used for training and validating the model, possibly including all pre-processing pipelines required.

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

-H, --dump-config <dump_config>

Name of the config file to be generated

Arguments

CONFIG

Optional argument(s)

Examples:

1. Save dataset after preprocessing:
sleepless preprocess stedf-filtered

train

It is possible to pass one or several Python files (or names of sleepless.config entry points or module names) as CONFIG arguments to the command line which contain the parameters listed below as Python variables. The options through the command-line (see below) will override the values of configuration files. You can run this command with <COMMAND> -H example_config.py to create a template config file.

sleepless train [OPTIONS] [CONFIG]...

Options

-o, --output-folder <output_folder>

Required Path where to store the generated model (created if does not exist)

-d, --dataset <dataset>

Required A dictionary mapping string keys to a list of sleepless.data.sample.DelayedSample instances implementing datasets to be used for training and validating the model, possibly including all pre-processing pipelines required. At least one key named train must be available.

-m, --model <model>

Required An instance model to be trained

-mp, --model-parameters <model_parameters>

Required Parameters of model training

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

-H, --dump-config <dump_config>

Name of the config file to be generated

Arguments

CONFIG

Optional argument(s)

Examples:

1. Trains a random forest model with ST_subset (from EDF database):
sleepless train rf-gs-mne stedf-filtered -o "/path/to/output_folder"

train-analysis

Analyzes the training logs for loss evolution and resource

utilisation.

It is possible to pass one or several Python files (or names of sleepless.config entry points or module names) as CONFIG arguments to the command line which contain the parameters listed below as Python variables. The options through the command-line (see below) will override the values of configuration files. You can run this command with <COMMAND> -H example_config.py to create a template config file.

sleepless train-analysis [OPTIONS] LOG CONSTANTS [CONFIG]...

Options

-o, --output-folder <output_folder>

Required Path where to store the figures (created if does not exist)

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

-H, --dump-config <dump_config>

Name of the config file to be generated

Arguments

LOG

Required argument

CONSTANTS

Required argument

CONFIG

Optional argument(s)

Examples:

1. Analyzes a training log and produces various plots:
sleepless train-analysis -vv log.csv constants.csv

visualize

It is possible to pass one or several Python files (or names of sleepless.config entry points or module names) as CONFIG arguments to the command line which contain the parameters listed below as Python variables. The options through the command-line (see below) will override the values of configuration files. You can run this command with <COMMAND> -H example_config.py to create a template config file.

sleepless visualize [OPTIONS] [CONFIG]...

Options

-d, --dataset <dataset>

Required A dictionary mapping string keys to a list of sleepless.data.sample.DelayedSample instances implementing datasets to be used for training and validating the model, possibly including all pre-processing pipelines required.

-t, --type <type>

Required Type of data to visualize (e.g. raw, misclassified, wellclassified)

-s, --subset <subset>

Required Subset where the sample you want to visualize is located (e.g. train, test)

-n, --sample <sample>

Required Sample number, 0-index based

-p, --prediction-folder <prediction_folder>

Required folder where prediction have been saved

-v, --verbose

Increase the verbosity level from 0 (only error and critical) messages will be displayed, to 1 (like 0, but adds warnings), 2 (like 1, but adds info messages), and 3 (like 2, but also adds debugging messages) by adding the –verbose option as often as desired (e.g. ‘-vvv’ for debug).

Default:

0

-H, --dump-config <dump_config>

Name of the config file to be generated

Arguments

CONFIG

Optional argument(s)

Examples:

1. Transform and save ST_subset (from EDF database):
sleepless visualize stedf-filtered -t raw -s train -n 0 -p "/path/to/predictions"