Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 3005b60a authored by Alexis Brenon's avatar Alexis Brenon
Browse files

Add script to compute cross-val metrics

parent 3fdffc3a
#! /usr/bin/env bash
set -eu
function get_timestamp {
date -d "$( \
echo "$1" | \
sed -re 's/([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2})T([[:digit:]]{2})([[:digit:]]{2})([[:digit:]]{2})/\1-\2-\3T\4:\5:\6/'
)" \
+%s
}
function trap_exit() {
for I in $(echo "$TMPFILES" | tr ':' '\n')
do
rm -f "$I"
done
}
trap trap_exit SIGINT SIGTERM ERR
MINDATE=$(get_timestamp "$(basename "$1")")
MAXDATE=$(get_timestamp "$(basename "$2")")
METRIC_TYPE=${3:-Classification}
METRIC_FIELD=${4:-6}
TMPFILES=""
for F in ./outputs/*
do
FOLDER=$(basename "$F")
if [[ $FOLDER =~ ^[0-9]*T[0-9]*$ ]]
then
FDATE=$(get_timestamp "$FOLDER")
if [[ $MINDATE -le $FDATE && $FDATE -le $MAXDATE ]]
then
TMPFILE=$(mktemp)
TMPFILES=${TMPFILES#:}:$TMPFILE
grep "INFO ## .* value;" "$F"/output.log | awk -- "
BEGIN {
FS = \"##\"
ORS = \"\"
OFS = \"\"
IGNORECASE = 1
}
\$4 ~ /Generic metrics/ {
n = split(\$4, array, \";\");
print(array[2], \"\t\");
}
\$4 ~ /$METRIC_TYPE metrics/ {
n = split(\$4, array, \";\");
print(array[$METRIC_FIELD], \"\n\");
}
" > "$TMPFILE"
fi
fi
done
FIRST_FILE="$(echo "$TMPFILES" | tr ':' '\n' | head -1)"
FILES_LIST="$(echo "$TMPFILES" | tr ':' '\t' | cut -f2- | tr '\t' ' ')"
NBFILES=$(echo "$TMPFILES" | tr ':' '\n' | wc -l)
while IFS='' read -r LINE || [[ -n "$LINE" ]]
do
IT=$(echo "$LINE" | cut -f1)
VALUE=$(echo "$LINE" | cut -f2)
COMPUTATION="scale=2; (1/$NBFILES) * ($VALUE+"
SUM=$(\
grep -h "^${IT}$(printf '\t')" $FILES_LIST | \
cut -f2 | \
tr '\n' '+'
)
SUM=${SUM#+}; SUM=${SUM%+}
COMPUTATION="$COMPUTATION $SUM )"
echo "$IT $(echo "$COMPUTATION" | bc)"
done < "$FIRST_FILE"
trap_exit
#################################
# Example of gnuplot usage
#
# blue_000 = "#A9BDE6" # = rgb(169,189,230)
# blue_025 = "#7297E6" # = rgb(114,151,230)
# red_050 = "#E62B17" # = rgb(230,43,23)
# set pointsize "1"
# set border 31 lw 2 lc rgb "#222222"
#
# set term pngcairo size 1024,768
# set ylabel "F1-score"
# set yrange [0:100]
# set xlabel "Learning steps (x1000)"
# set xrange [0:500]
#
# set output './metric.png'
# plot 'data_file.dat' u ($1/1000):2 t '' w lines lw 0.5 lc rgbcolor blue_000, '' u ($1/1000):2 t '' w points ps 1 pt 7 lc rgbcolor blue_025, '' u ($1/1000):2 t '' smooth bezier w lines lw 4 lc rgbcolor red_050
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment