generateAndTrain_maxwell.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #! bin/bash
  2. if [ -z "$1" ]
  3. then
  4. echo "No argument supplied"
  5. echo "Need of vector size"
  6. exit 1
  7. fi
  8. if [ -z "$2" ]
  9. then
  10. echo "No argument supplied"
  11. echo "Need of feature information"
  12. exit 1
  13. fi
  14. result_filename="results/models_comparisons.csv"
  15. VECTOR_SIZE=200
  16. size=$1
  17. feature=$2
  18. # selection of four scenes (only maxwell)
  19. scenes="A, D, G, H"
  20. half=$(($size/2))
  21. start=-$half
  22. for counter in {0..4}; do
  23. end=$(($start+$size))
  24. if [ "$end" -gt "$VECTOR_SIZE" ]; then
  25. start=$(($VECTOR_SIZE-$size))
  26. end=$(($VECTOR_SIZE))
  27. fi
  28. if [ "$start" -lt "0" ]; then
  29. start=$((0))
  30. end=$(($size))
  31. fi
  32. for nb_zones in {4,6,8,10,12}; do
  33. echo $start $end
  34. for mode in {"svd","svdn","svdne"}; do
  35. for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
  36. FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
  37. MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
  38. echo $FILENAME
  39. # only compute if necessary (perhaps server will fall.. Just in case)
  40. if grep -q "${MODEL_NAME}" "${result_filename}"; then
  41. echo "${MODEL_NAME} results already generated..."
  42. else
  43. python generate/generate_data_model_random.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --feature ${feature} --scenes "${scenes}" --nb_zones "${nb_zones}" --renderer "maxwell" --step 40 --random 1 --percent 1
  44. python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
  45. #python prediction/predict_seuil_expe_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --feature ${feature} --limit_detection '2'
  46. python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --feature ${feature}
  47. fi
  48. done
  49. done
  50. done
  51. if [ "$counter" -eq "0" ]; then
  52. start=$(($start+50-$half))
  53. else
  54. start=$(($start+50))
  55. fi
  56. done