Browse Source

Merge branch 'release/v0.2.4'

Jérôme BUISINE 6 months ago
parent
commit
92c61709f5

+ 1 - 0
custom_config.py

@@ -16,6 +16,7 @@ optimization_filters_result_filename    = 'optimization_comparisons_filters.csv'
 optimization_attributes_result_filename = 'optimization_comparisons_attributes.csv'
 
 filter_reduction_choices                = ['attributes', 'filters']
+models_names_list                       = ["svm_model","ensemble_model","ensemble_model_v2","deep_keras"]
 
 ## models_names_list               = ["svm_model","ensemble_model","ensemble_model_v2","deep_keras"]
 ## normalization_choices           = ['svd', 'svdn', 'svdne']

+ 4 - 4
data_processing/generateAndTrain_maxwell_custom.sh

@@ -31,7 +31,7 @@ scenes="A, D, G, H"
 start=0
 end=$size
 
-for nb_zones in {4,6,8,10,12}; do
+for nb_zones in {4,6,8,10,11,12}; do
 
     for mode in {"svd","svdn","svdne"}; do
         for model in {"svm_model","ensemble_model","ensemble_model_v2"}; do
@@ -47,11 +47,11 @@ for nb_zones in {4,6,8,10,12}; do
 
                 echo "${MODEL_NAME} results already generated..."
             else
-                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}
-                python train_model.py --data ${FILENAME} --output ${MODEL_NAME} --choice ${model}
+                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 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}" --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}
+                #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

+ 1 - 1
data_processing/generateAndTrain_maxwell_custom_optimization.sh

@@ -61,7 +61,7 @@ for nb_zones in {10,12}; do
                 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}
                 
                 echo "Train ${MODEL_NAME}"
-                python find_best_${filter}.py --data ${FILENAME} --choice ${model} &
+                #python find_best_${filter}.py --data ${FILENAME} --choice ${model} &
             fi
         done
     done

+ 1 - 1
display/display_reconstructed_image_from_simulation.py

@@ -75,7 +75,7 @@ def reconstruct_image(folder_path, model_name, p_limit):
 
             row = np.asarray(row)
 
-            threshold = row[2]
+            #threshold = row[2]
             start_index = row[3]
             step_value = row[4]
             rendering_predictions = row[5:]

+ 3 - 0
models.py

@@ -4,6 +4,7 @@ from sklearn.linear_model import LogisticRegression
 from sklearn.ensemble import RandomForestClassifier, VotingClassifier
 from sklearn.neighbors import KNeighborsClassifier
 from sklearn.ensemble import GradientBoostingClassifier
+from sklearn.feature_selection import RFECV
 import sklearn.svm as svm
 
 
@@ -62,6 +63,8 @@ def ensemble_model_v2(X_train, y_train):
 
     return ensemble_model
 
+
+
 def get_trained_model(choice, X_train, y_train):
 
     if choice == 'svm_model':

+ 7 - 7
prediction/predict_noisy_image_svd.py

@@ -52,14 +52,14 @@ def main():
         kind_model = 'keras'
 
     if 'corr' in p_model_file:
-        corr_model = True
+        indices_model = True
 
         indices_corr_path = os.path.join(cfg.correlation_indices_folder, p_model_file.split('/')[1].replace('.json', '').replace('.joblib', '') + '.csv')
 
         with open(indices_corr_path, 'r') as f:
-            data_corr_indices = [int(x) for x in f.readline().split(';') if x != '']
+            selected_indices = [int(x) for x in f.readline().split(';') if x != '']
     else:
-        corr_model = False
+        indices_model = False
 
 
     if kind_model == 'sklearn':
@@ -87,8 +87,8 @@ def main():
     # check if custom min max file is used
     if p_custom:
 
-        if corr_model:
-            test_data = data[data_corr_indices]
+        if indices_model:
+            test_data = data[selected_indices]
         else:
             test_data = data[begin:end]
 
@@ -127,8 +127,8 @@ def main():
         else:
             l_values = data
 
-        if corr_model:
-            test_data = data[data_corr_indices]
+        if indices_model:
+            test_data = data[selected_indices]
         else:
             test_data = data[begin:end]
 

+ 1 - 5
prediction/predict_seuil_expe_curve_opti_scene.py

@@ -144,10 +144,6 @@ def main():
 
                 print(str(id_block) + " : " + str(current_quality_image) + "/" + str(threshold_expes[id_block]) + " => " + str(prediction))
 
-        print("------------------------")
-        print("Scene " + str(id_scene + 1) + "/" + str(len(scenes)))
-        print("------------------------")
-
     # end of scene => display of results
 
     # construct path using model name for saving threshold map folder
@@ -157,7 +153,7 @@ def main():
     if not os.path.exists(model_threshold_path):
         os.makedirs(model_threshold_path)
 
-    map_filename = os.path.join(model_threshold_path, simulation_curves_zones + folder_scene)
+    map_filename = os.path.join(model_threshold_path, simulation_curves_zones + scene_name)
     f_map = open(map_filename, 'w')
 
     for line in block_predictions_str:

+ 1 - 6
prediction/predict_seuil_expe_curve_scene.py

@@ -142,11 +142,6 @@ def main():
 
                 print(str(id_block) + " : " + str(current_quality_image) + "/" + str(threshold_expes[id_block]) + " => " + str(prediction))
 
-        print("------------------------")
-        print("Scene " + str(id_scene + 1) + "/" + str(len(scenes)))
-        print("------------------------")
-
-    # end of scene => display of results
 
     # construct path using model name for saving threshold map folder
     model_threshold_path = os.path.join(threshold_map_folder, p_model_file.split('/')[-1].replace('.joblib', ''))
@@ -155,7 +150,7 @@ def main():
     if not os.path.exists(model_threshold_path):
         os.makedirs(model_threshold_path)
 
-    map_filename = os.path.join(model_threshold_path, simulation_curves_zones + folder_scene)
+    map_filename = os.path.join(model_threshold_path, simulation_curves_zones + scene_name)
     f_map = open(map_filename, 'w')
 
     for line in block_predictions_str:

+ 1 - 0
train_model.py

@@ -88,6 +88,7 @@ def main():
 
     print("-------------------------------------------")
     print("Train dataset size: ", final_df_train_size)
+
     model = mdl.get_trained_model(p_choice, x_dataset_train, y_dataset_train)
 
     #######################