generateAndTrain_maxwell_custom.sh 2.5 KB

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