From 1373e8e059c32ebc36b98f0fcbf0e791b0c4a950 Mon Sep 17 00:00:00 2001
From: Ludovic Moncla <ludovic.moncla@insa-lyon.fr>
Date: Mon, 7 Jun 2021 14:18:20 +0200
Subject: [PATCH] update

---
 evaluate_model.py                | 11 -------
 experimentsClassicClassifiers.py | 49 +++++++++++---------------------
 2 files changed, 16 insertions(+), 44 deletions(-)

diff --git a/evaluate_model.py b/evaluate_model.py
index 8abd2e9..f258ccd 100644
--- a/evaluate_model.py
+++ b/evaluate_model.py
@@ -57,14 +57,3 @@ def evaluate_model(clf, X_test, y_test, y_pred, valid_y, classes, classesName, p
     plt.savefig(pathSave)
     return df, accuracy, weighted_avg
 
-import seaborn as sns
-import matplotlib.pyplot as plt
-from sklearn.metrics import confusion_matrix
-
-
-#y_true = [2, 0, 2, 2, 0, 1]
-#y_pred = [0, 0, 2, 2, 0, 2]
-#cf_matrix = confusion_matrix(y_true, y_pred)
-#sns.heatmap(cf_matrix, annot=True)
-#import matplotlib.pyplot as plt
-#plt.show()
diff --git a/experimentsClassicClassifiers.py b/experimentsClassicClassifiers.py
index c6a9f72..3c69915 100644
--- a/experimentsClassicClassifiers.py
+++ b/experimentsClassicClassifiers.py
@@ -96,44 +96,27 @@ for columnInput in [columnText, 'firstParagraph']:
             grid_param_name, grid_param = tmp_grid_params
             print(clf_name, clf, grid_param_name, grid_param)
             model_file_name = columnInput + '_' +feature_technique_name + '_' + clf_name+ str(minOfInstancePerClass) + '_' + str(maxOfInstancePerClass) +".pkl"
-            if clf_name == 'bayes' :
-                if feature_technique_name == 'doc2vec':
-                    continue
-                else:
-                    t_begin = time.time()
-                    # if model exist
-                    if os.path.isfile(os.path.join('./model', model_file_name)):
-                        with open(model_file_name, 'rb') as file:
-                            clf = pickle.load(file)
-                    else:
-                        #if model not exists we save
-                        with open(Pkl_Filename, 'wb') as file:
-                            clf.fit(train_x, train_y)
-                            pickle.dump(clf, file)
-
-                    t_end =time.time()
-                    training_time = t_end - t_begin
-
-                    y_pred = clf.predict(test_x)
-
-            else :
-
+            
+            if clf_name != 'bayes' :
                 clf = GridSearchCV(clf, grid_param, refit = True, verbose = 3)
-                t_begin = time.time()
+            else if feature_technique_name == 'doc2vec':
+                    continue
+            
+            t_begin = time.time()
 
-                if os.path.isfile(os.path.join('./model', model_file_name)):
-                    with open(model_file_name, 'rb') as file:
-                        clf = pickle.load(file)
-                else:
-                    with open(Pkl_Filename, 'wb') as file:
-                        clf.fit(train_x, train_y)
-                        pickle.dump(clf, file)
+            if os.path.isfile(os.path.join('./model', model_file_name)):
+                with open(model_file_name, 'rb') as file:
+                    clf = pickle.load(file)
+            else:
+                with open(Pkl_Filename, 'wb') as file:
+                    clf.fit(train_x, train_y)
+                    pickle.dump(clf, file)
 
-                t_end =time.time()
+            t_end =time.time()
 
-                training_time = t_end - t_begin
+            training_time = t_end - t_begin
 
-                y_pred = clf.predict(test_x)
+            y_pred = clf.predict(test_x)
 
     #evaluate model
             file_name_report = columnInput + '_' +feature_technique_name + '_' + clf_name
-- 
GitLab