def __init__(self, generator, queryengine, errorfx=mean_mismatch_error, indexsum=None, reuse_neighbors=False, splitter=None, **kwargs): """Initialize the base class for "naive" searchlight classifiers Parameters ---------- generator : `Generator` Some `Generator` to prepare partitions for cross-validation. It must not change "targets", thus e.g. no AttributePermutator's errorfx : func, optional Functor that computes a scalar error value from the vectors of desired and predicted values (e.g. subclass of `ErrorFunction`). indexsum : ('sparse', 'fancy'), optional What use to compute sums over arbitrary columns. 'fancy' corresponds to regular fancy indexing over columns, whenever in 'sparse', product of sparse matrices is used (usually faster, so is default if `scipy` is available). reuse_neighbors : bool, optional Compute neighbors information only once, thus allowing for efficient reuse on subsequent calls where dataset's feature attributes remain the same (e.g. during permutation testing) splitter : Splitter, optional Which will be used to split partitioned datasets. If None specified then standard one operating on partitions will be used """ # init base class first BaseSearchlight.__init__(self, queryengine, **kwargs) self._errorfx = errorfx self._generator = generator self._splitter = splitter # TODO: move into _call since resetting over default None # obscures __repr__ if indexsum is None: if externals.exists('scipy'): indexsum = 'sparse' else: indexsum = 'fancy' else: if indexsum == 'sparse' and not externals.exists('scipy'): warning("Scipy.sparse isn't available so taking 'fancy' as " "'indexsum' method.") indexsum = 'fancy' self._indexsum = indexsum if not self.nproc in (None, 1): raise NotImplementedError, "For now only nproc=1 (or None for " \ "autodetection) is supported by GNBSearchlight" self.__pb = None # statistics per each block/label self.__reuse_neighbors = reuse_neighbors # Storage to be used for neighborhood information self.__roi_fids = None
def __init__(self, generator, queryengine, errorfx=mean_mismatch_error, indexsum=None, reuse_neighbors=False, **kwargs): """Initialize the base class for "naive" searchlight classifiers Parameters ---------- generator : `Generator` Some `Generator` to prepare partitions for cross-validation. It must not change "targets", thus e.g. no AttributePermutator's errorfx : func, optional Functor that computes a scalar error value from the vectors of desired and predicted values (e.g. subclass of `ErrorFunction`). indexsum : ('sparse', 'fancy'), optional What use to compute sums over arbitrary columns. 'fancy' corresponds to regular fancy indexing over columns, whenever in 'sparse', product of sparse matrices is used (usually faster, so is default if `scipy` is available). reuse_neighbors : bool, optional Compute neighbors information only once, thus allowing for efficient reuse on subsequent calls where dataset's feature attributes remain the same (e.g. during permutation testing) """ # init base class first BaseSearchlight.__init__(self, queryengine, **kwargs) self._errorfx = errorfx self._generator = generator # TODO: move into _call since resetting over default None # obscures __repr__ if indexsum is None: if externals.exists('scipy'): indexsum = 'sparse' else: indexsum = 'fancy' else: if indexsum == 'sparse' and not externals.exists('scipy'): warning("Scipy.sparse isn't available so taking 'fancy' as " "'indexsum' method.") indexsum = 'fancy' self._indexsum = indexsum if not self.nproc in (None, 1): raise NotImplementedError, "For now only nproc=1 (or None for " \ "autodetection) is supported by GNBSearchlight" self.__pb = None # statistics per each block/label self.__reuse_neighbors = reuse_neighbors # Storage to be used for neighborhood information self.__roi_fids = None
def __init__(self, gnb, generator, qe, errorfx=mean_mismatch_error, indexsum=None, **kwargs): """Initialize a GNBSearchlight Parameters ---------- gnb : `GNB` `GNB` classifier as the specification of what GNB parameters to use. Instance itself isn't used. generator : `Generator` Some `Generator` to prepare partitions for cross-validation. errorfx : func, optional Functor that computes a scalar error value from the vectors of desired and predicted values (e.g. subclass of `ErrorFunction`). indexsum : ('sparse', 'fancy'), optional What use to compute sums over arbitrary columns. 'fancy' corresponds to regular fancy indexing over columns, whenever in 'sparse', produce of sparse matrices is used (usually faster, so is default if `scipy` is available. """ # init base class first BaseSearchlight.__init__(self, qe, **kwargs) self._errorfx = errorfx self._generator = generator self._gnb = gnb if indexsum is None: if externals.exists('scipy'): indexsum = 'sparse' else: indexsum = 'fancy' else: if indexsum == 'sparse' and not externals.exists('scipy'): warning("Scipy.sparse isn't available so taking 'fancy' as " "'indexsum' method.") indexsum = 'fancy' self._indexsum = indexsum if not self.nproc in (None, 1): raise NotImplementedError, "For now only nproc=1 (or None for " \ "autodetection) is supported by GNBSearchlight"