args_parser()
Anomalies in Tor Usage.
This program implements the method described in the paper at https://arxiv.org/abs/1507.05819.
It takes Tor usage data from https://metrics.torproject.org/userstats-relay-country.csv and outputs a ranking of countries according to the level of detected anomalous behaviour in a date interval, as well as a graph showing a greater date interval.
Source code in anomaly/args_parser.py
def args_parser() -> argparse.ArgumentParser:
"""Anomalies in Tor Usage.
This program implements the method described in the paper at
https://arxiv.org/abs/1507.05819.
It takes Tor usage data from
https://metrics.torproject.org/userstats-relay-country.csv and outputs a
ranking of countries according to the level of detected anomalous behaviour
in a date interval, as well as a graph showing a greater date interval.
"""
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description=__doc__,
)
parser.add_argument(
"-p",
"--path",
type=valid_file_path,
default=None,
help="Path to a data csv file, instead of downloading one.",
)
parser.add_argument(
"-s",
"--start-date",
type=valid_date,
default=default_start_date(),
help="Start date to find anomalies in YYYY-MM-DD format.",
)
parser.add_argument(
"-e",
"--end-date",
type=valid_date,
default=default_end_date(),
help="End date to find anomalies in YYYY-MM-DD format.",
)
parser.add_argument(
"-t",
"--train-start-date",
type=valid_date,
default=default_train_start_date(),
help="Train data start date in YYYY-MM-DD format.",
)
parser.add_argument(
"-u",
"--train-end-date",
type=valid_date,
default=default_end_date(),
help="Train data end date in YYYY-MM-DD format.",
)
parser.add_argument(
"-w",
"--write",
action="store_true",
default=False,
help="Write partial matrices to files.",
)
parser.add_argument(
"-r",
"--read",
action="store_true",
default=False,
help="Read partial matrices from files (if they exists).",
)
return parser