Repository navigation
Expand file tree
/
Copy pathreplicate.sh
More file actions
executable file
·109 lines (101 loc) · 4.97 KB
/
Copy pathreplicate.sh
File metadata and controls
executable file
·109 lines (101 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# Replicates the benchmark of the README from nothing: environments, datasets, every
# method, the tables and the figures.
#
# benchmarks/replicate.sh <directory> [options]
#
# Everything is written under <directory>; finished jobs are skipped, so the script can
# be interrupted and started again, and several copies can run on disjoint --datasets.
#
# --tiers S|SM|SML datasets by size: S up to ~1M edges (default), M up to ~60M, L larger
# --datasets a,b,c these datasets instead of whole tiers
# --dim N embedding dimensionality of every method (default 1024)
# --threads N threads per embedding method (default: all cores)
#
# Parts that can be switched off:
#
# --no-setup environments and baseline checkouts already exist
# --no-baselines do not run the nine baseline methods
# --no-previous do not run the pycleora 3.2 default (whitening, 40 iterations)
# --no-tuned no iteration sweep and no "Cleora, tuned" rows
# --no-popularity no measurement of the exponents of the popularity prior
# --no-timing no separate time / memory measurement
# --no-figures no UMAP figures
# --no-report do not write benchmarks/RESULTS.md and the tables of the READMEs
#
# The time and memory measurement runs one method at a time and is only meaningful on a
# machine that does nothing else.
set -euo pipefail
[ $# -ge 1 ] || { sed -n '2,28p' "$0" | sed 's/^# \{0,1\}//'; exit 2; }
mkdir -p "$1"
data=$(cd "$1" && pwd)
shift
here=$(cd "$(dirname "$0")" && pwd)
tiers=S datasets="" dim=1024 threads=$(getconf _NPROCESSORS_ONLN)
setup=1 baselines=1 previous=1 tuned=1 popularity=1 timing=1 figures=1 report=1
while [ $# -gt 0 ]; do
case $1 in
--tiers) tiers=$2; shift ;;
--datasets) datasets=$2; shift ;;
--dim) dim=$2; shift ;;
--threads) threads=$2; shift ;;
--no-setup) setup=0 ;;
--no-baselines) baselines=0 ;;
--no-previous) previous=0 ;;
--no-tuned) tuned=0 ;;
--no-popularity) popularity=0 ;;
--no-timing) timing=0 ;;
--no-figures) figures=0 ;;
--no-report) report=0 ;;
*) echo "unknown option: $1" >&2; exit 2 ;;
esac
shift
done
[ $setup = 1 ] && "$here/setup.sh" "$data"
export CLEORA_BENCH_ENVS=$data/envs CLEORA_BENCH_BASELINES=$data/baselines
python=$data/envs/main/bin/python
configurations() { # names of a group of Cleora configurations
"$python" -c "import sys; sys.path.insert(0, '$here'); from cleora_bench import configurations as c; print(','.join($1))"
}
# Three seeds on tier S, one on the larger graphs.
for tier in $(echo "$tiers" | grep -o .); do
if [ -n "$datasets" ]; then selection=(--datasets "$datasets"); else selection=(--tiers "$tier"); fi
seeds=0,1,2; [ "$tier" = S ] || seeds=0
# hours a method may take on one graph
limit=6; [ "$tier" = L ] && limit=3
run() { "$python" "$here/run_benchmark.py" --data "$data" "${selection[@]}" --threads "$threads" --timeout "$limit" "$@"; }
"$python" "$here/prepare_datasets.py" --data "$data" "${selection[@]}"
# Cleora with the iterations the library suggests for the task, and the plain default for the figures
run --dim "$dim" --seeds "$seeds" --tasks nc --methods "$(configurations "c.automatic('classification')")"
run --dim "$dim" --seeds "$seeds" --tasks lp,viz --methods "$(configurations "c.automatic('similarity')")"
if [ $baselines = 1 ]; then
run --dim "$dim" --seeds "$seeds"
fi
if [ $previous = 1 ]; then
run --dim "$dim" --seeds "$seeds" --methods cleora_whiten40
fi
if [ $tuned = 1 ]; then
# one cheap pass over the iteration counts, then the counts that validated best in full
run --results sweep --dim "$dim" --seeds 0 --tasks nc,lp --node-probes logistic --pair-probes cosine,dot \
--methods "$(configurations "c.sweep('hyperedge') + c.sweep('pair')")"
"$python" "$here/select_iterations.py" --data "$data"
run --dim "$dim" --seeds "$seeds" --tasks nc,lp --methods cleora_tuned
fi
if [ $popularity = 1 ] && [ "$tier" != L ]; then
# how the exponent of the popularity prior was chosen: validation scores by exponent
"$python" "$here/popularity_exponent.py" --data "$data" "${selection[@]}" --threads "$threads"
fi
if [ $timing = 1 ]; then
run --results timing --dim "$dim" --seeds 0,1,2 --tasks time \
--methods "$(configurations "[c.AUTO[('hyperedge', 'left', 'general')], 'cleora_whiten40'] + list(c.DEFAULT)")"
fi
[ -n "$datasets" ] && break
done
if [ $figures = 1 ]; then
"$python" "$here/make_figures.py" --data "$data" --out "$here/figures" --dim "$dim"
[ $timing = 1 ] && "$python" "$here/make_summary_figure.py" --data "$data" --out "$here/figures"
fi
if [ $report = 1 ]; then
"$python" "$here/make_report.py" --data "$data" --out "$here/RESULTS.md" --dump "$here/results.csv.gz" \
--readme "$here/README.md" --readme "$here/../README.md"
fi