run.sh 1.24 KB
# Pour le moment, le run ne fait qu'executer
# quelques petites commandes que l'on souhaite
# tester.

OUTDIR="exp/kmeans_teacher_1/pvector-1"
DATADIR="data"

kmin=2
kmax=100

if [ ! -d "$OUTDIR" ];
then
    mkdir -p $OUTDIR
fi

for kfold in {1..4}
do
    #echo "kfold = ${kfold}"
    pvector_file="${DATADIR}/pvectors_1rst/pvectors_teacher_${kfold}.txt"
    lst_dir="${DATADIR}/pvectors_1rst/lst"
    output_kfold="${OUTDIR}/${kfold}"
    
    if [ ! -d "${output_kfold}" ];
    then
        mkdir -p ${output_kfold}
    fi

    
    # Train kmeans
    echo "Clustering - ${kfold}"
    python3 bin/cluster_kmeans.py "${pvector_file}" \
        "${lst_dir}/train_${kfold}.lst" \
        "${output_kfold}" --kmin ${kmin} --kmax ${kmax}

    for k in $(seq ${kmin} 1 ${kmax})
    do
        echo "Kmeans Measuring and extraction - ${k}"
        # Extract kmean values
        python3 bin/extract_kmeans.py "${output_kfold}/${k}/clustering_${k}.pkl" \
            "${pvector_file}" \
            --outfile "${output_kfold}/${k}/clustered_${k}.txt"
        python3 bin/measure_clustering.py "${output_kfold}/${k}/clustered_${k}.txt" "${pvector_file}" "${lst_dir}/train_${kfold}.lst" "${lst_dir}/val_${kfold}.lst" --outfile "${output_kfold}/${k}/measures.json"
    done
done