Przeglądaj źródła

update kolmogorov attributes

Jérôme BUISINE 4 lat temu
rodzic
commit
a4119a186e
3 zmienionych plików z 19 dodań i 17 usunięć
  1. 3 1
      data_attributes.py
  2. 6 7
      find_best_attributes.py
  3. 10 9
      models.py

+ 3 - 1
data_attributes.py

@@ -99,7 +99,9 @@ def get_image_features(data_type, block):
         bytes_data = np.array(block).tobytes()
         compress_data = gzip.compress(bytes_data)
 
-        data = np.append(data, sys.getsizeof(compress_data))
+        mo_size = sys.getsizeof(compress_data) / 1024.
+        go_size = mo_size / 1024.
+        data = np.append(data, go_size)
 
         lab_img = transform.get_LAB_L(block)
         arr = np.array(lab_img)

+ 6 - 7
find_best_attributes.py

@@ -39,8 +39,8 @@ from optimization.checkpoints.BasicCheckpoint import BasicCheckpoint
 # variables and parameters
 models_list         = cfg.models_names_list
 number_of_values    = 26
-ils_iteration       = 10
-ls_iteration        = 5
+ils_iteration       = 2000
+ls_iteration        = 10
 
 # default validator
 def validator(solution):
@@ -116,6 +116,10 @@ def main():
 
     logging.basicConfig(format='%(asctime)s %(message)s', filename='data/logs/%s.log' % p_data_file.split('/')[-1], level=logging.DEBUG)
 
+    # init solution (`n` attributes)
+    def init():
+        return BinarySolution([], number_of_values).random(validator)
+
     # define evaluate function here (need of data information)
     def evaluate(solution):
 
@@ -146,11 +150,6 @@ def main():
 
         return test_roc_auc
 
-    # init solution (`n` attributes)
-    def init():
-        global number_of_values
-        return BinarySolution([], number_of_values).random(validator)
-
     if not os.path.exists(cfg.output_backup_folder):
         os.makedirs(cfg.output_backup_folder)
 

+ 10 - 9
models.py

@@ -7,7 +7,7 @@ from sklearn.ensemble import GradientBoostingClassifier
 from sklearn.feature_selection import RFECV
 import sklearn.svm as svm
 from sklearn.metrics import accuracy_score
-from thundersvm import SVC
+#from thundersvm import SVC
 
 # variables and parameters
 n_predict = 0
@@ -41,18 +41,19 @@ def svm_model(X_train, y_train):
 
 def _get_best_gpu_model(X_train, y_train):
 
-    Cs = [0.001, 0.01, 0.1, 1, 2, 5, 10, 100, 1000]
-    gammas = [0.001, 0.01, 0.1, 1, 2, 5, 10, 100]
-    param_grid = {'kernel':['rbf'], 'C': Cs, 'gamma' : gammas}
+    # Cs = [0.001, 0.01, 0.1, 1, 2, 5, 10, 100, 1000]
+    # gammas = [0.001, 0.01, 0.1, 1, 2, 5, 10, 100]
+    # param_grid = {'kernel':['rbf'], 'C': Cs, 'gamma' : gammas}
 
-    svc = SVC(probability=True, class_weight='balanced')
-    clf = GridSearchCV(svc, param_grid, cv=10, verbose=1, scoring=my_accuracy_scorer, n_jobs=-1)
+    # svc = SVC(probability=True, class_weight='balanced')
+    # clf = GridSearchCV(svc, param_grid, cv=10, verbose=1, scoring=my_accuracy_scorer, n_jobs=-1)
 
-    clf.fit(X_train, y_train)
+    # clf.fit(X_train, y_train)
 
-    model = clf.best_estimator_
+    # model = clf.best_estimator_
 
-    return model
+    # return model
+    pass
 
 def svm_gpu(X_train, y_train):