def __init__(self, cellmap_df, normalizedsource_df, projectpath, paramlist, type, normalize = True ,plot=False, log=False): self.cellmap_df = cellmap_df self.source_df = normalizedsource_df self.projectpath = projectpath self.paramlist = paramlist if type not in ['euclidean','cityblock', 'correlation', 'chebyshev', 'cosine', 'canberra', 'braycurtis', 'mahalanobis']: raise Exception('Unknown mapping type: %s' % type) else: self.trainingtype = type if plot: self.plot = True self.draw_func = draw.draw() self.drawingdir = os.path.join(projectpath, 'mapcountour') if not os.path.exists(self.drawingdir): os.mkdir(self.drawingdir) else: self.plot = False self.normalize = normalize if normalize is True: self.dfutil_func = dfutil.dfutil() if log: self.log = log else: self.log = False
def __init__(self, samplevec_df, cellmap_df, radius_list, learningconstant_list, paramlist,project_dir, normalize=True, log=False, plot=False,cpucount=-1, type = 'cossim', logcycle = False): self.irr_list = range(len(radius_list)) self.samplevec_df = samplevec_df self.cellmap_df = cellmap_df self.radius_list = radius_list self.learningconst_list = learningconstant_list self.log = log self.draw_func = draw.draw() self.project_dir = project_dir self.normalize = normalize if normalize is True: self.dfutil_func = dfutil.dfutil() if type not in ['euclidean','cityblock', 'correlation', 'chebyshev', 'cosine', 'canberra', 'braycurtis', 'mahalanobis']: raise Exception('Unknown training type: %s' % type) else: self.traintype = type if cpucount == -1: self.cpucount = multiprocessing.cpu_count()-1 elif cpucount == 1: raise Exception('Single core processing is not implemented yet') else: self.cpucount = cpucount-1 self.param_list = paramlist if not logcycle is False: if isinstance(logcycle, int): self.logcylce = logcycle else: raise Exception('ERROR: logcycle should be int') if plot is True: self.plot = True pertubplotdir = os.path.join(self.project_dir, 'mappertub') if os.path.exists(pertubplotdir): raise IOError('ERROR: Plot directory already exist:%s' % pertubplotdir) os.mkdir(pertubplotdir) self.pertubplotdir = pertubplotdir else: self.plot = False