def loadResources(self): #THE GREAT MONOLITH!!! if self.resource_pool.has_key(data_sources.KMATRIX): self.svdad = PreloadedKernelMatrixSvdAdapter.createAdapter( **self.resource_pool) else: if not self.resource_pool.has_key(data_sources.KERNEL_OBJ): if not self.resource_pool.has_key("kernel"): self.resource_pool["kernel"] = "LinearKernel" self.resource_pool[ data_sources. KERNEL_OBJ] = creators.createKernelByModuleName( **self.resource_pool) if isinstance(self.resource_pool[data_sources.KERNEL_OBJ], LinearKernel): self.svdad = LinearSvdAdapter.createAdapter( **self.resource_pool) else: self.svdad = SvdAdapter.createAdapter(**self.resource_pool) self.svals = self.svdad.svals self.svecs = self.svdad.rsvecs if not self.resource_pool.has_key( data_sources.TIKHONOV_REGULARIZATION_PARAMETER): self.resource_pool[ data_sources.TIKHONOV_REGULARIZATION_PARAMETER] = 1.
def createSVDAdapter(X, kernel="LinearKernel", **kwargs): kwargs[KERNEL_NAME] = kernel if kernel == "PrecomputedKernel": kwargs["kernel_matrix"] = X svdad = PreloadedKernelMatrixSvdAdapter.createAdapter(**kwargs) else: kwargs['X'] = X kwargs['kernel_obj'] = createKernelByModuleName(**kwargs) if isinstance(kwargs['kernel_obj'], LinearKernel): svdad = LinearSvdAdapter.createAdapter(**kwargs) else: svdad = SvdAdapter.createAdapter(**kwargs) return svdad
def createSVDAdapter(**kwargs): if kwargs.has_key(KERNEL_NAME): kernel = createKernelByModuleName(**kwargs) kwargs[data_sources.KERNEL_OBJ] = kernel if kwargs.has_key(data_sources.KMATRIX): svdad = PreloadedKernelMatrixSvdAdapter.createAdapter(**kwargs) else: if not kwargs.has_key(data_sources.KERNEL_OBJ): if not kwargs.has_key("kernel"): kwargs["kernel"] = "LinearKernel" kwargs[data_sources.KERNEL_OBJ] = createKernelByModuleName(**kwargs) if isinstance(kwargs[data_sources.KERNEL_OBJ], LinearKernel): svdad = LinearSvdAdapter.createAdapter(**kwargs) else: svdad = SvdAdapter.createAdapter(**kwargs) return svdad
def createSVDAdapter(**kwargs): if kwargs.has_key(KERNEL_NAME): kernel = createKernelByModuleName(**kwargs) kwargs['kernel_obj'] = kernel if kwargs.has_key('kernel_matrix'): svdad = PreloadedKernelMatrixSvdAdapter.createAdapter(**kwargs) else: if not kwargs.has_key('kernel_obj'): if not kwargs.has_key("kernel"): kwargs["kernel"] = "LinearKernel" kwargs['kernel_obj'] = createKernelByModuleName(**kwargs) if isinstance(kwargs['kernel_obj'], LinearKernel): svdad = LinearSvdAdapter.createAdapter(**kwargs) else: svdad = SvdAdapter.createAdapter(**kwargs) return svdad
def loadResources(self): # THE GREAT MONOLITH!!! if self.resource_pool.has_key(data_sources.KMATRIX): self.svdad = PreloadedKernelMatrixSvdAdapter.createAdapter(**self.resource_pool) else: if not self.resource_pool.has_key(data_sources.KERNEL_OBJ): if not self.resource_pool.has_key("kernel"): self.resource_pool["kernel"] = "LinearKernel" self.resource_pool[data_sources.KERNEL_OBJ] = creators.createKernelByModuleName(**self.resource_pool) if isinstance(self.resource_pool[data_sources.KERNEL_OBJ], LinearKernel): self.svdad = LinearSvdAdapter.createAdapter(**self.resource_pool) else: self.svdad = SvdAdapter.createAdapter(**self.resource_pool) self.svals = self.svdad.svals self.svecs = self.svdad.rsvecs if not self.resource_pool.has_key(data_sources.TIKHONOV_REGULARIZATION_PARAMETER): self.resource_pool[data_sources.TIKHONOV_REGULARIZATION_PARAMETER] = 1.0
def createSVDAdapter(**kwargs): if kwargs.has_key(KERNEL_NAME): kernel = createKernelByModuleName(**kwargs) kwargs[data_sources.KERNEL_OBJ] = kernel if kwargs.has_key(data_sources.KMATRIX): svdad = PreloadedKernelMatrixSvdAdapter.createAdapter(**kwargs) else: if not kwargs.has_key(data_sources.KERNEL_OBJ): if not kwargs.has_key("kernel"): kwargs["kernel"] = "LinearKernel" kwargs[data_sources.KERNEL_OBJ] = createKernelByModuleName( **kwargs) if isinstance(kwargs[data_sources.KERNEL_OBJ], LinearKernel): svdad = LinearSvdAdapter.createAdapter(**kwargs) else: svdad = SvdAdapter.createAdapter(**kwargs) return svdad
def __init__(self, **kwargs): super(AbstractSvdLearner, self).__init__(**kwargs) #THE GREAT SVD MONOLITH!!! if kwargs.has_key('kernel_matrix'): self.svdad = PreloadedKernelMatrixSvdAdapter.createAdapter(**kwargs) else: if not kwargs.has_key('kernel_obj'): if not kwargs.has_key("kernel"): kwargs["kernel"] = "LinearKernel" kwargs['kernel_obj'] = creators.createKernelByModuleName(**kwargs) if isinstance(kwargs['kernel_obj'], LinearKernel): self.svdad = LinearSvdAdapter.createAdapter(**kwargs) else: self.svdad = SvdAdapter.createAdapter(**kwargs) self.svals = self.svdad.svals self.svecs = self.svdad.rsvecs #if not kwargs.has_key('regparam'): # kwargs['regparam'] = 1. self.size = self.svecs.shape[0]
def __init__(self, **kwargs): super(AbstractSvdLearner, self).__init__(**kwargs) #THE GREAT SVD MONOLITH!!! if kwargs.has_key('kernel_matrix'): self.svdad = PreloadedKernelMatrixSvdAdapter.createAdapter( **kwargs) else: if not kwargs.has_key('kernel_obj'): if not kwargs.has_key("kernel"): kwargs["kernel"] = "LinearKernel" kwargs['kernel_obj'] = creators.createKernelByModuleName( **kwargs) if isinstance(kwargs['kernel_obj'], LinearKernel): self.svdad = LinearSvdAdapter.createAdapter(**kwargs) else: self.svdad = SvdAdapter.createAdapter(**kwargs) self.svals = self.svdad.svals self.svecs = self.svdad.rsvecs #if not kwargs.has_key('regparam'): # kwargs['regparam'] = 1. self.size = self.svecs.shape[0]