Parcourir la source

Merge branch 'release/v0.0.8'

Jérôme BUISINE il y a 4 ans
Parent
commit
249da2dc15

+ 1 - 0
.gitignore

@@ -7,6 +7,7 @@ custom_norm
 learned_zones
 corr_indices
 metric_curves
+results
 .ipynb_checkpoints
 
 # simulate_models.csv

+ 20 - 42
data_processing/generateAndTrain_maxwell_custom.sh

@@ -10,65 +10,43 @@ fi
 if [ -z "$2" ]
   then
     echo "No argument supplied"
-    echo "Need of metric information"
+    echo "Need of feature information"
     exit 1
 fi
 
 result_filename="results/models_comparisons.csv"
 VECTOR_SIZE=200
 size=$1
-metric=$2
+feature=$2
 
 # selection of four scenes (only maxwell)
 scenes="A, D, G, H"
 
-half=$(($size/2))
-start=-$half
-for counter in {0..4}; do
-    end=$(($start+$size))
+start=0
+end=$size
 
-    if [ "$end" -gt "$VECTOR_SIZE" ]; then
-        start=$(($VECTOR_SIZE-$size))
-        end=$(($VECTOR_SIZE))
-    fi
+for nb_zones in {4,6,8,10,12}; do
 
-    if [ "$start" -lt "0" ]; then
-        start=$((0))
-        end=$(($size))
-    fi
+    for mode in {"svd","svdn","svdne"}; do
+        for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
 
-    for nb_zones in {4,6,8,10,12}; do
+            FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
+            MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
+            CUSTOM_MIN_MAX_FILENAME="N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}_min_max"
 
-        echo $start $end
+            echo $FILENAME
 
-        for mode in {"svd","svdn","svdne"}; do
-            for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
+            # only compute if necessary (perhaps server will fall.. Just in case)
+            if grep -q "${MODEL_NAME}" "${result_filename}"; then
 
-                FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                CUSTOM_MIN_MAX_FILENAME="N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}_min_max"
+                echo "${MODEL_NAME} results already generated..."
+            else
+                python generate/generate_data_model_random.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}
+                python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
 
-                echo $FILENAME
-
-                # only compute if necessary (perhaps server will fall.. Just in case)
-                if grep -q "${MODEL_NAME}" "${result_filename}"; then
-
-                    echo "${MODEL_NAME} results already generated..."
-                else
-                    python generate/generate_data_model_random.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 40 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
-                    python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
-
-                    #python prediction/predict_seuil_expe_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric} --limit_detection '2' --custom ${CUSTOM_MIN_MAX_FILENAME}
-                    python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric}
-                fi
-            done
+                #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}
+                python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --feature ${feature}
+            fi
         done
     done
-
-    if [ "$counter" -eq "0" ]; then
-        start=$(($start+50-$half))
-    else
-        start=$(($start+50))
-    fi
-
 done

+ 20 - 42
data_processing/generateAndTrain_maxwell_custom_center.sh

@@ -10,65 +10,43 @@ fi
 if [ -z "$2" ]
   then
     echo "No argument supplied"
-    echo "Need of metric information"
+    echo "Need of feature information"
     exit 1
 fi
 
 result_filename="results/models_comparisons.csv"
 VECTOR_SIZE=200
 size=$1
-metric=$2
+feature=$2
 
 # selection of four scenes (only maxwell)
 scenes="A, D, G, H"
 
-half=$(($size/2))
-start=-$half
-for counter in {0..4}; do
-    end=$(($start+$size))
+start=0
+end=$size
 
-    if [ "$end" -gt "$VECTOR_SIZE" ]; then
-        start=$(($VECTOR_SIZE-$size))
-        end=$(($VECTOR_SIZE))
-    fi
+for nb_zones in {4,6,8,10,12}; do
 
-    if [ "$start" -lt "0" ]; then
-        start=$((0))
-        end=$(($size))
-    fi
+    for mode in {"svd","svdn","svdne"}; do
+        for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
 
-    for nb_zones in {4,6,8,10,12}; do
+            FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
+            MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
+            CUSTOM_MIN_MAX_FILENAME="N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}_min_max"
 
-        echo $start $end
+            echo $FILENAME
 
-        for mode in {"svd","svdn","svdne"}; do
-            for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
+            # only compute if necessary (perhaps server will fall.. Just in case)
+            if grep -q "${MODEL_NAME}" "${result_filename}"; then
 
-                FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                CUSTOM_MIN_MAX_FILENAME="N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}_min_max"
+                echo "${MODEL_NAME} results already generated..."
+            else
+                python generate/generate_data_model_random_center.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --feature ${feature} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
+                python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
 
-                echo $FILENAME
-
-                # only compute if necessary (perhaps server will fall.. Just in case)
-                if grep -q "${MODEL_NAME}" "${result_filename}"; then
-
-                    echo "${MODEL_NAME} results already generated..."
-                else
-                    python generate/generate_data_model_random_center.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
-                    python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
-
-                    #python prediction/predict_seuil_expe_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric} --limit_detection '2' --custom ${CUSTOM_MIN_MAX_FILENAME}
-                    python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric}
-                fi
-            done
+                #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}
+                python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --feature ${feature}
+            fi
         done
     done
-
-    if [ "$counter" -eq "0" ]; then
-        start=$(($start+50-$half))
-    else
-        start=$(($start+50))
-    fi
-
 done

+ 20 - 42
data_processing/generateAndTrain_maxwell_custom_split.sh

@@ -10,65 +10,43 @@ fi
 if [ -z "$2" ]
   then
     echo "No argument supplied"
-    echo "Need of metric information"
+    echo "Need of feature information"
     exit 1
 fi
 
 result_filename="results/models_comparisons.csv"
 VECTOR_SIZE=200
 size=$1
-metric=$2
+feature=$2
 
 # selection of four scenes (only maxwell)
 scenes="A, D, G, H"
 
-half=$(($size/2))
-start=-$half
-for counter in {0..4}; do
-    end=$(($start+$size))
+start=0
+end=$size
 
-    if [ "$end" -gt "$VECTOR_SIZE" ]; then
-        start=$(($VECTOR_SIZE-$size))
-        end=$(($VECTOR_SIZE))
-    fi
+for nb_zones in {4,6,8,10,12}; do
 
-    if [ "$start" -lt "0" ]; then
-        start=$((0))
-        end=$(($size))
-    fi
+    for mode in {"svd","svdn","svdne"}; do
+        for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
 
-    for nb_zones in {4,6,8,10,12}; do
+            FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
+            MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}"
+            CUSTOM_MIN_MAX_FILENAME="N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${feature}_${mode}_min_max"
 
-        echo $start $end
+            echo $FILENAME
 
-        for mode in {"svd","svdn","svdne"}; do
-            for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
+            # only compute if necessary (perhaps server will fall.. Just in case)
+            if grep -q "${MODEL_NAME}" "${result_filename}"; then
 
-                FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                CUSTOM_MIN_MAX_FILENAME="N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}_min_max"
+                echo "${MODEL_NAME} results already generated..."
+            else
+                python generate/generate_data_model_random_split.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --feature ${feature} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
+                python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
 
-                echo $FILENAME
-
-                # only compute if necessary (perhaps server will fall.. Just in case)
-                if grep -q "${MODEL_NAME}" "${result_filename}"; then
-
-                    echo "${MODEL_NAME} results already generated..."
-                else
-                    python generate/generate_data_model_random_split.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 10 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
-                    python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
-
-                    #python prediction/predict_seuil_expe_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric} --limit_detection '2' --custom ${CUSTOM_MIN_MAX_FILENAME}
-                    python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric}
-                fi
-            done
+                #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}
+                python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --feature ${feature}
+            fi
         done
     done
-
-    if [ "$counter" -eq "0" ]; then
-        start=$(($start+50-$half))
-    else
-        start=$(($start+50))
-    fi
-
 done

+ 1 - 2
generate/generate_data_model_random.py

@@ -286,8 +286,7 @@ def main():
         if not os.path.exists(custom_min_max_folder):
             os.makedirs(custom_min_max_folder)
 
-        min_max_folder_path = os.path.join(os.path.dirname(__file__), custom_min_max_folder)
-        min_max_filename_path = os.path.join(min_max_folder_path, p_custom)
+        min_max_filename_path = os.path.join(custom_min_max_folder, p_custom)
 
         with open(min_max_filename_path, 'w') as f:
             f.write(str(min_value_interval) + '\n')

+ 1 - 2
generate/generate_data_model_random_center.py

@@ -297,8 +297,7 @@ def main():
         if not os.path.exists(custom_min_max_folder):
             os.makedirs(custom_min_max_folder)
 
-        min_max_folder_path = os.path.join(os.path.dirname(__file__), custom_min_max_folder)
-        min_max_filename_path = os.path.join(min_max_folder_path, p_custom)
+        min_max_filename_path = os.path.join(custom_min_max_folder, p_custom)
 
         with open(min_max_filename_path, 'w') as f:
             f.write(str(min_value_interval) + '\n')

+ 1 - 2
generate/generate_data_model_random_split.py

@@ -296,8 +296,7 @@ def main():
         if not os.path.exists(custom_min_max_folder):
             os.makedirs(custom_min_max_folder)
 
-        min_max_folder_path = os.path.join(os.path.dirname(__file__), custom_min_max_folder)
-        min_max_filename_path = os.path.join(min_max_folder_path, p_custom)
+        min_max_filename_path = os.path.join(custom_min_max_folder, p_custom)
 
         with open(min_max_filename_path, 'w') as f:
             f.write(str(min_value_interval) + '\n')

+ 9 - 5
others/save_model_result_in_md_maxwell.py

@@ -53,21 +53,21 @@ def main():
 
     parser.add_argument('--interval', type=str, help='Interval value to keep from svd', default='"0, 200"')
     parser.add_argument('--model', type=str, help='.joblib or .json file (sklearn or keras model)')
-    parser.add_argument('--metric', type=str, help='Metric data choice', choices=cfg.metric_choices_labels)
+    parser.add_argument('--feature', type=str, help='feature data choice', choices=cfg.features_choices_labels)
     parser.add_argument('--mode', type=str, help='Kind of normalization level wished', choices=cfg.normalization_choices)
 
     args = parser.parse_args()
 
     p_interval   = list(map(int, args.interval.split(',')))
     p_model_file = args.model
-    p_metric     = args.metric
+    p_feature    = args.feature
     p_mode       = args.mode
 
 
     # call model and get global result in scenes
     begin, end = p_interval
 
-    bash_cmd = "bash others/testModelByScene_maxwell.sh '" + str(begin) + "' '" + str(end) + "' '" + p_model_file + "' '" + p_mode + "' '" + p_metric + "'"
+    bash_cmd = "bash others/testModelByScene_maxwell.sh '" + str(begin) + "' '" + str(end) + "' '" + p_model_file + "' '" + p_mode + "' '" + p_feature + "'"
 
     print(bash_cmd)
 
@@ -126,6 +126,10 @@ def main():
 
     # Prepare writing in .csv file into results folder
     output_final_file_path = os.path.join(cfg.results_information_folder, final_csv_model_comparisons)
+
+    if not os.path.exists(cfg.results_information_folder):
+        os.makedirs(cfg.results_information_folder)
+
     output_final_file = open(output_final_file_path, "a")
 
     print(current_model_name)
@@ -187,7 +191,7 @@ def main():
 
             model.compile(loss='binary_crossentropy',
                         optimizer='adam',
-                        metrics=['accuracy'])
+                        features=['accuracy'])
 
         # reshape all input data
         x_dataset_train = np.array(x_dataset_train).reshape(len(x_dataset_train), end, 1)
@@ -308,7 +312,7 @@ def main():
     # check if it's always the case...
     nb_zones = current_data_file_path.split('_')[7]
 
-    final_file_line = current_model_name + '; ' + str(end - begin) + '; ' + str(begin) + '; ' + str(end) + '; ' + str(nb_zones) + '; ' + p_metric + '; ' + p_mode
+    final_file_line = current_model_name + '; ' + str(end - begin) + '; ' + str(begin) + '; ' + str(end) + '; ' + str(nb_zones) + '; ' + p_feature + '; ' + p_mode
 
     for s in model_scores:
         final_file_line += '; ' + str(s)

+ 6 - 6
others/testModelByScene.sh

@@ -31,7 +31,7 @@ fi
 if [ -z "$5" ]
   then
     echo "No fifth argument supplied"
-    echo "Need of metric : 'lab', 'mscn'"
+    echo "Need of feature : 'lab', 'mscn'"
     exit 1
 fi
 
@@ -39,12 +39,12 @@ INPUT_BEGIN=$1
 INPUT_END=$2
 INPUT_MODEL=$3
 INPUT_MODE=$4
-INPUT_METRIC=$5
+INPUT_feature=$5
 
 zones="0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"
 
 echo "**Model :** ${INPUT_MODEL}"
-echo "**Metric :** ${INPUT_METRIC}"
+echo "**feature :** ${INPUT_feature}"
 echo "**Mode :** ${INPUT_MODE}"
 echo "**Vector range :** [${INPUT_BEGIN}, ${INPUT_END}]"
 echo ""
@@ -53,10 +53,10 @@ echo "---|--------|-------|----------"
 
 for scene in {"A","B","C","D","E","F","G","H","I"}; do
 
-  FILENAME="data/data_${INPUT_MODE}_${INPUT_METRIC}_B${INPUT_BEGIN}_E${INPUT_END}_scene${scene}"
+  FILENAME="data/data_${INPUT_MODE}_${INPUT_feature}_B${INPUT_BEGIN}_E${INPUT_END}_scene${scene}"
 
-  python generate/generate_data_model.py --output ${FILENAME} --interval "${INPUT_BEGIN},${INPUT_END}" --kind ${INPUT_MODE} --metric ${INPUT_METRIC} --scenes "${scene}" --zones "${zones}" --percent 1 --sep ";" --rowindex "0"
+  python generate/generate_data_model.py --output ${FILENAME} --interval "${INPUT_BEGIN},${INPUT_END}" --kind ${INPUT_MODE} --feature ${INPUT_feature} --scenes "${scene}" --zones "${zones}" --percent 1 --sep ";" --rowindex "0"
 
-  python prediction/prediction_scene.py --data "$FILENAME.train" --model ${INPUT_MODEL} --output "${INPUT_MODEL}_Scene${scene}_mode_${INPUT_MODE}_metric_${INPUT_METRIC}.prediction" --scene ${scene}
+  python prediction/prediction_scene.py --data "$FILENAME.train" --model ${INPUT_MODEL} --output "${INPUT_MODEL}_Scene${scene}_mode_${INPUT_MODE}_feature_${INPUT_feature}.prediction" --scene ${scene}
 
 done

+ 6 - 6
others/testModelByScene_maxwell.sh

@@ -31,7 +31,7 @@ fi
 if [ -z "$5" ]
   then
     echo "No fifth argument supplied"
-    echo "Need of metric : 'lab', 'mscn'"
+    echo "Need of feature : 'lab', 'mscn'"
     exit 1
 fi
 
@@ -46,12 +46,12 @@ INPUT_BEGIN=$1
 INPUT_END=$2
 INPUT_MODEL=$3
 INPUT_MODE=$4
-INPUT_METRIC=$5
+INPUT_FEATURE=$5
 
 zones="0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"
 
 echo "**Model :** ${INPUT_MODEL}"
-echo "**Metric :** ${INPUT_METRIC}"
+echo "**feature :** ${INPUT_FEATURE}"
 echo "**Mode :** ${INPUT_MODE}"
 echo "**Vector range :** [${INPUT_BEGIN}, ${INPUT_END}]"
 echo ""
@@ -61,10 +61,10 @@ echo "---|--------|-------|----------"
 # only take maxwell scenes
 for scene in {"A","D","G","H"}; do
 
-  FILENAME="data/data_${INPUT_MODE}_${INPUT_METRIC}_B${INPUT_BEGIN}_E${INPUT_END}_scene${scene}"
+  FILENAME="data/data_${INPUT_MODE}_${INPUT_FEATURE}_B${INPUT_BEGIN}_E${INPUT_END}_scene${scene}"
 
-  python generate/generate_data_model.py --output ${FILENAME} --interval "${INPUT_BEGIN},${INPUT_END}" --kind ${INPUT_MODE} --metric ${INPUT_METRIC} --scenes "${scene}" --zones "${zones}" --percent 1
+  python generate/generate_data_model.py --output ${FILENAME} --interval "${INPUT_BEGIN},${INPUT_END}" --kind ${INPUT_MODE} --feature ${INPUT_FEATURE} --scenes "${scene}" --zones "${zones}" --percent 1
 
-  python prediction/prediction_scene.py --data "$FILENAME.train" --model ${INPUT_MODEL} --output "${INPUT_MODEL}_Scene${scene}_mode_${INPUT_MODE}_metric_${INPUT_METRIC}.prediction" --scene ${scene}
+  python prediction/prediction_scene.py --data "$FILENAME.train" --model ${INPUT_MODEL} --output "${INPUT_MODEL}_Scene${scene}_mode_${INPUT_MODE}_feature_${INPUT_FEATURE}.prediction" --scene ${scene}
 
 done

+ 4 - 6
run/runAll_maxwell_custom.sh

@@ -12,13 +12,11 @@ if [ "${erased}" == "Y" ]; then
     touch ${file_path}
 
     # add of header
-    echo 'model_name; vector_size; start; end; nb_zones; metric; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
+    echo 'model_name; vector_size; start; end; nb_zones; feature; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
 
 fi
 
-for size in {"4","8","16","26","32","40"}; do
+size=26
+feature="filters_statistics"
 
-    for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff","svd_reconstruct"}; do
-        bash data_processing/generateAndTrain_maxwell_custom.sh ${size} ${metric}
-    done
-done
+bash data_processing/generateAndTrain_maxwell_custom.sh ${size} ${feature}

+ 4 - 6
run/runAll_maxwell_custom_center.sh

@@ -12,13 +12,11 @@ if [ "${erased}" == "Y" ]; then
     touch ${file_path}
 
     # add of header
-    echo 'model_name; vector_size; start; end; nb_zones; metric; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
+    echo 'model_name; vector_size; start; end; nb_zones; feature; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
 
 fi
 
-for size in {"4","8","16","26","32","40"}; do
+size=26
+feature="filters_statistics"
 
-    for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff","svd_reconstruct"}; do
-        bash data_processing/generateAndTrain_maxwell_custom_center.sh ${size} ${metric}
-    done
-done
+bash data_processing/generateAndTrain_maxwell_custom_center.sh ${size} ${feature}

+ 4 - 6
run/runAll_maxwell_custom_split.sh

@@ -12,13 +12,11 @@ if [ "${erased}" == "Y" ]; then
     touch ${file_path}
 
     # add of header
-    echo 'model_name; vector_size; start; end; nb_zones; metric; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
+    echo 'model_name; vector_size; start; end; nb_zones; feature; mode; tran_size; val_size; test_size; train_pct_size; val_pct_size; test_pct_size; train_acc; val_acc; test_acc; all_acc; F1_train; recall_train; roc_auc_train; F1_val; recall_val; roc_auc_val; F1_test; recall_test; roc_auc_test; F1_all; recall_all; roc_auc_all;' >> ${file_path}
 
 fi
 
-for size in {"4","8","16","26","32","40"}; do
+size=26
+feature="filters_statistics"
 
-    for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff","svd_reconstruct"}; do
-        bash data_processing/generateAndTrain_maxwell_custom_split.sh ${size} ${metric}
-    done
-done
+bash data_processing/generateAndTrain_maxwell_custom_split.sh ${size} ${feature}

+ 0 - 62
simulation/run_maxwell_simulation.sh

@@ -1,62 +0,0 @@
-#! bin/bash
-
-# file which contains model names we want to use for simulation
-simulate_models="simulate_models.csv"
-
-# selection of four scenes (only maxwell)
-scenes="A, D, G, H"
-VECTOR_SIZE=200
-
-for size in {"4","8","16","26","32","40"}; do
-    for metric in {"lab","mscn","mscn_revisited","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2"}; do
-
-        half=$(($size/2))
-        start=-$half
-
-        for counter in {0..4}; do
-             end=$(($start+$size))
-
-             if [ "$end" -gt "$VECTOR_SIZE" ]; then
-                 start=$(($VECTOR_SIZE-$size))
-                 end=$(($VECTOR_SIZE))
-             fi
-
-             if [ "$start" -lt "0" ]; then
-                 start=$((0))
-                 end=$(($size))
-             fi
-
-             for nb_zones in {4,6,8,10,12,14}; do
-
-                 for mode in {"svd","svdn","svdne"}; do
-                     for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
-
-                        FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                        MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-
-                        if grep -xq "${MODEL_NAME}" "${simulate_models}"; then
-                            echo "Run simulation for model ${MODEL_NAME}"
-
-                            # by default regenerate model
-                            python generate/generate_data_model_random.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 40 --random 1
-
-                            python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
-
-                            python prediction/predict_seuil_expe_maxwell_curve.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric} --limit_detection '2'
-
-                            python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric}
-
-                        fi
-                    done
-                done
-            done
-
-            if [ "$counter" -eq "0" ]; then
-                start=$(($start+50-$half))
-            else
-                start=$(($start+50))
-            fi
-
-        done
-    done
-done

+ 0 - 63
simulation/run_maxwell_simulation_custom.sh

@@ -1,63 +0,0 @@
-#! bin/bash
-
-# file which contains model names we want to use for simulation
-simulate_models="simulate_models.csv"
-
-# selection of four scenes (only maxwell)
-scenes="A, D, G, H"
-VECTOR_SIZE=200
-
-for size in {"4","8","16","26","32","40"}; do
-    for metric in {"lab","mscn","mscn_revisited","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","ipca_diff","svd_trunc_diff","svd_reconstruct"}; do
-
-        half=$(($size/2))
-        start=-$half
-
-        for counter in {0..4}; do
-             end=$(($start+$size))
-
-             if [ "$end" -gt "$VECTOR_SIZE" ]; then
-                 start=$(($VECTOR_SIZE-$size))
-                 end=$(($VECTOR_SIZE))
-             fi
-
-             if [ "$start" -lt "0" ]; then
-                 start=$((0))
-                 end=$(($size))
-             fi
-
-             for nb_zones in {4,6,8,10,12,14}; do
-
-                 for mode in {"svd","svdn","svdne"}; do
-                     for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
-
-                        FILENAME="data/${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                        MODEL_NAME="${model}_N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}"
-                        CUSTOM_MIN_MAX_FILENAME="N${size}_B${start}_E${end}_nb_zones_${nb_zones}_${metric}_${mode}_min_max"
-
-                        if grep -xq "${MODEL_NAME}" "${simulate_models}"; then
-                            echo "Run simulation for model ${MODEL_NAME}"
-
-                            # by default regenerate model
-                            python generate/generate_data_model_random.py --output ${FILENAME} --interval "${start},${end}" --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 40 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
-
-                            python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
-
-                            python prediction/predict_seuil_expe_maxwell_curve.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric} --limit_detection '2' --custom ${CUSTOM_MIN_MAX_FILENAME}
-
-                            python others/save_model_result_in_md_maxwell.py --interval "${start},${end}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric}
-
-                        fi
-                    done
-                done
-            done
-
-            if [ "$counter" -eq "0" ]; then
-                start=$(($start+50-$half))
-            else
-                start=$(($start+50))
-            fi
-
-        done
-    done
-done

+ 8 - 8
simulation/run_maxwell_simulation_filters_statistics.sh

@@ -8,16 +8,16 @@ scenes="A, D, G, H"
 
 size="26"
 
-# for metric in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff","svd_reconstruct"}; do
-metric="filters_statistics"
+# for feature in {"lab","mscn","low_bits_2","low_bits_3","low_bits_4","low_bits_5","low_bits_6","low_bits_4_shifted_2","ica_diff","svd_trunc_diff","ipca_diff","svd_reconstruct"}; do
+feature="filters_statistics"
 
 for nb_zones in {4,6,8,10,12}; do
     for mode in {"svd","svdn","svdne"}; do
         for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
 
-            FILENAME="data/${model}_N${size}_B0_E${size}_nb_zones_${nb_zones}_${metric}_${mode}"
-            MODEL_NAME="${model}_N${size}_B0_E${size}_nb_zones_${nb_zones}_${metric}_${mode}"
-            CUSTOM_MIN_MAX_FILENAME="N${size}_B0_E${size}_nb_zones_${nb_zones}_${metric}_${mode}_min_max"
+            FILENAME="data/${model}_N${size}_B0_E${size}_nb_zones_${nb_zones}_${feature}_${mode}"
+            MODEL_NAME="${model}_N${size}_B0_E${size}_nb_zones_${nb_zones}_${feature}_${mode}"
+            CUSTOM_MIN_MAX_FILENAME="N${size}_B0_E${size}_nb_zones_${nb_zones}_${feature}_${mode}_min_max"
 
             echo $MODEL_NAME
 
@@ -27,12 +27,12 @@ for nb_zones in {4,6,8,10,12}; do
                 echo "${MODEL_NAME} results already generated..."
             else
                 # Use of already generated model
-                # python generate/generate_data_model_random.py --output ${FILENAME} --interval "0,${size}" --kind ${mode} --metric ${metric} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 40 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
+                # python generate/generate_data_model_random.py --output ${FILENAME} --interval "0,${size}" --kind ${mode} --feature ${feature} --scenes "${scenes}" --nb_zones "${nb_zones}" --percent 1 --renderer "maxwell" --step 40 --random 1 --custom ${CUSTOM_MIN_MAX_FILENAME}
                 # python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
 
-                python prediction/predict_seuil_expe_maxwell_curve.py --interval "0,${size}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric} --custom ${CUSTOM_MIN_MAX_FILENAME}
+                python prediction/predict_seuil_expe_maxwell_curve.py --interval "0,${size}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --feature ${feature} --custom ${CUSTOM_MIN_MAX_FILENAME}
 
-                python others/save_model_result_in_md_maxwell.py --interval "0,${size}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --metric ${metric}
+                python others/save_model_result_in_md_maxwell.py --interval "0,${size}" --model "saved_models/${MODEL_NAME}.joblib" --mode "${mode}" --feature ${feature}
             fi
         done
     done