示例#1
0
 def setOutFile(self):
     if '\\' in self.__currentdataset__:
         datasetName = self.__currentdataset__.split("\\")[-1].split('-')[0]
     else:
         datasetName = self.__currentdataset__.split("/")[-1].split('-')[0]
     fpath = os.path.join(self.__root__, 'a_s' + Configs.version)
     fpath = os.path.join(fpath, 'a_Column')
     check_folder(fpath)
     self.__currentoutfile__ = os.path.join(fpath, datasetName)
     del_dir_tree(self.__currentoutfile__)
示例#2
0
 def save_prediction_valid(self, prediction):
     filepath = os.path.join(self.root_path, "_cache_",
                             "_cache_prediction_valid", self.dataname,
                             self.classifier_name, self.getfilename())
     if not os.path.exists(filepath):
         dirtools.check_folder(
             os.path.join(self.root_path, "_cache_",
                          "_cache_prediction_valid", self.dataname,
                          self.classifier_name))
         with open(filepath, 'w') as f:  # open file with write-mode
             pickle.dump(prediction, f)  # serialize and save object
示例#3
0
 def save_estimator_test(self, estimator):
     filepath = os.path.join(self.root_path, "_cache_",
                             "_cache_classifier_test", self.dataname,
                             self.classifier_name, self.getfilename())
     if not os.path.exists(filepath):
         dirtools.check_folder(
             os.path.join(self.root_path, "_cache_",
                          "_cache_classifier_test", self.dataname,
                          self.classifier_name))
         with open(filepath, 'w') as f:  # open file with write-mode
             pickle.dump(estimator, f)  # serialize and save object
示例#4
0
def logMiddle(genid, fitness, filename):
    filedir = gol.get_val("root_path")
    filedir = os.path.join(filedir, 'Results/' + gol.get_val("version"))
    filedir = os.path.join(filedir, gol.get_val("dataName")+"-v"+gol.get_val("version"))
    filedir = os.path.join(filedir, gol.get_val("aimFolder"))
    check_folder(filedir)
    filedir = os.path.join(filedir, filename)
    
    f = file(filedir, 'a')
    i = genid+1
    f.write(str(i))
    f.write(":")
    f.write('\n')
    f.write("fitness:")
    f.write(str(fitness))
    f.write('\n')
    f.write('\n')
    f.close()
示例#5
0
def logPopulations( genid, pop):
    filedir = gol.get_val("root_path")
    filedir = os.path.join(filedir, 'Results/' + gol.get_val("version"))
    filedir = os.path.join(filedir, gol.get_val("dataName")+"-v"+gol.get_val("version"))
    filedir = os.path.join(filedir, gol.get_val("aimFolder"))
    check_folder(filedir)
    filedir = os.path.join(filedir, "Gen."+str(genid)+".gpecoc")

    f = file(filedir, 'w+')
    i = 1
    for ind in pop:
        Matrix , feature_list = getMatrixDirectly_and_feature(ind)
        feature_method_index = gol.get_val("feature_method_index")
        feature_index_list = list( feature_method_index[method] for method in feature_list)
        Matrix = np.ndarray.tolist(Matrix)
        Matrix.insert(0,feature_index_list)
        Matrix = np.array(Matrix)
        
        f.write(str(i))
        f.write(":")
        f.write('\n')
        f.write(str(Matrix))
        f.write('\n')
        f.write("f-score:")
        f.write(str(ind.fscore))
        f.write('\n')
        f.write("accuracy:")
        f.write(str(ind.accuracy))
        f.write('\n')
        f.write('--------------------------------------------------------------------------------------------\n')
        
        for text in ind.infos_evaluation:
            f.write(str(text))
            f.write('\n')
        f.write('\n\n\n\n\n')
        i=i+1
    f.close()
示例#6
0
def _agp_main_runner(dataName, aimFolder):
    std = sys.stdout
    try:
        Configs.dataName = dataName
        Configs.aimFolder = aimFolder
        _rootp = Configs.root_path
        _rootp = os.path.join(_rootp, 'Results/' + Configs.version)
        _rootp = os.path.join(_rootp,
                              Configs.dataName + "-v" + Configs.version)
        _rootp = os.path.join(_rootp, Configs.aimFolder)
        del_dir_tree(_rootp)  # delete former results
        check_folder(_rootp)
        _res = "/Result"
        out = open(_rootp + _res, 'w+')
        sys.stdout = out
        sys.stderr = out
        AGpEcocStart.main_run()
    except Exception as e:
        _err = "/Error"
        err = open(_rootp + _err, 'w+')
        err.write(e.message)
        err.flush()
    finally:
        sys.stdout = std