Ejemplo n.º 1
0
 def __init__(self,
              paramSet,
              scorerBuilder,
              ltopics,
              posClass,
              folder,
              verbose=True,
              cache=False):
     '''
     :param paramSet: list-like of paramsets passed to scorerBuilder
             each 'paramset' is a dict of parameters
     :param scorerBuilder: callable building scoring functions from a paramset
     :param ltopics: list of (topic, labels) - topic is (modelId, topicId),
             labels is a string or dict of 'label':{0 or 1}
     :param posClass: string or a list of strings defining which label is positive class
     :param verbose: if true, print results during experiment runtime
     :param cache: if True, force scorerBuilder to cache function results
     '''
     self.setOfParams = paramSet
     self.scorerBuilder = scorerBuilder.__name__
     self.__builder = scorerBuilder
     self.ltopics = ltopics
     self.posClass = posClass
     IdComposer.__init__(self, class_='TSE')
     self.verbose = verbose
     self.__log = createLogger(fullClassName(self), INFO)
     self.baseFolder = folder
     self.folder = path.join(folder, self.id)
     if not path.exists(self.folder): os.mkdir(self.folder)
     self.cache = cache
     if cache:
         self.cacheFolder = path.join(self.baseFolder, 'function_cache')
         if not path.exists(self.cacheFolder): os.mkdir(self.cacheFolder)
     self.__rSetUp = False
Ejemplo n.º 2
0
 def __init__(self, builder, folder, id=None, memCache=True):
     '''
     :param memCache: if True, also cache built/loaded object in memory
     '''
     self.__builder = builder
     self.__folder = folder
     self.__log = createLogger(fullClassName(self), INFO)
     self.id = id
     self.__memCache = memCache
     if memCache: self.__cache = {}
Ejemplo n.º 3
0
 def __init__(self,
              builder,
              folder,
              id=None,
              memCache=True,
              dummyHash=False):
     '''
     :param memCache: if True, also cache built/loaded object in memory
     :param dummyHash: if True, hash function will be very simple and cause frequent
             hash-crashes, used only for testing this eventuality
     '''
     self._builder = builder
     self._folder = folder
     self._log = createLogger(fullClassName(self), INFO)
     self.id = id
     self._memCache = memCache
     self._dummyHash = dummyHash
     if memCache: self._cache = {}
Ejemplo n.º 4
0
 def _logger(self):
     if not hasattr(self, '_log'):
         self._log = createLogger(fullClassName(self), INFO)
     return self._log
Ejemplo n.º 5
0
 def __init__(self, builder):
     self.__builder = builder
     self.__log = createLogger(fullClassName(builder), INFO)