本文整理汇总了Python中mvpa2.mappers.base.Mapper类的典型用法代码示例。如果您正苦于以下问题:Python Mapper类的具体用法?Python Mapper怎么用?Python Mapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, selector=None, demean=True):
"""Initialize the ProjectionMapper
Parameters
----------
selector : None or list
Which components (i.e. columns of the projection matrix)
should be used for mapping. If `selector` is `None` all
components are used. If a list is provided, all list
elements are treated as component ids and the respective
components are selected (all others are discarded).
demean : bool
Either data should be demeaned while computing
projections and applied back while doing reverse()
"""
Mapper.__init__(self)
# by default we want to wipe the feature attributes out during mapping
self._fa_filter = []
self._selector = selector
self._proj = None
"""Forward projection matrix."""
self._recon = None
"""Reverse projection (reconstruction) matrix."""
self._demean = demean
"""Flag whether to demean the to be projected data, prior to projection.
"""
self._offset_in = None
"""Offset (most often just mean) in the input space"""
self._offset_out = None
"""Offset (most often just mean) in the output space"""
开发者ID:psederberg,项目名称:PyMVPA,代码行数:32,代码来源:projection.py
示例2: __init__
def __init__(self, fx, train_as_1st=True, **kwargs):
"""
Parameters
----------
fx : callable
Functor that is called with the two datasets upon forward-mapping.
train_as_1st : bool
If True, the training dataset is passed to the target callable as
the first argument and the other dataset as the second argument.
If False, it is vice versa.
Examples
--------
>>> from mvpa2.mappers.fxy import FxyMapper
>>> from mvpa2.datasets import Dataset
>>> callable = lambda x,y: len(x) > len(y)
>>> ds1 = Dataset(range(5))
>>> ds2 = Dataset(range(3))
>>> fxy = FxyMapper(callable)
>>> fxy.train(ds1)
>>> fxy(ds2).item()
True
>>> fxy = FxyMapper(callable, train_as_1st=False)
>>> fxy.train(ds1)
>>> fxy(ds2).item()
False
"""
Mapper.__init__(self, **kwargs)
self._fx = fx
self._train_as_1st = train_as_1st
self._ds_train = None
开发者ID:PepGardiola,项目名称:PyMVPA,代码行数:31,代码来源:fxy.py
示例3: __init__
def __init__(self, chunks_attr=None, k=8, init='k-means++', n_init=10, **kwargs):
"""
parameters
__________
chunks_attr : str or None
If provided, it specifies the name of a samples attribute in the
training data, unique values of which will be used to identify chunks of
samples, and to perform individual clustering within them.
k : int or ndarray
The number of clusters to form as well as the number of centroids to
generate. If init initialization string is matrix, or if a ndarray
is given instead, it is interpreted as initial cluster to use instead
init : {k-means++, random, points, matrix}
Method for initialization, defaults to k-means++:k-means++ :
selects initial cluster centers for k-mean clustering in a smart way
to speed up convergence. See section Notes in k_init for more details.
random: generate k centroids from a Gaussian with mean and variance
estimated from the data.points: choose k observations (rows) at
random from data for the initial centroids.matrix: interpret the k
parameter as a k by M (or length k array for one-dimensional data)
array of initial centroids.
n_init : int
Number of iterations of the k-means algrithm to run. Note that this
differs in meaning from the iters parameter to the kmeans function.
"""
Mapper.__init__(self, **kwargs)
self.__chunks_attr = chunks_attr
self.__k = k
self.__init = init
self.__n_init = n_init
开发者ID:BNUCNL,项目名称:FreeROI,代码行数:31,代码来源:kmeanmapper.py
示例4: __init__
def __init__(self, params=None, param_est=None, chunks_attr="chunks", dtype="float64", **kwargs):
"""
Parameters
----------
params : None or tuple(mean, std) or dict
Fixed Z-Scoring parameters (mean, standard deviation). If provided,
no parameters are estimated from the data. It is possible to specify
individual parameters for each chunk by passing a dictionary with the
chunk ids as keys and the parameter tuples as values. If None,
parameters will be estimated from the training data.
param_est : None or tuple(attrname, attrvalues)
Limits the choice of samples used for automatic parameter estimation
to a specific subset identified by a set of a given sample attribute
values. The tuple should have the name of that sample
attribute as the first element, and a sequence of attribute values
as the second element. If None, all samples will be used for parameter
estimation.
chunks_attr : str or None
If provided, it specifies the name of a samples attribute in the
training data, unique values of which will be used to identify chunks of
samples, and to perform individual Z-scoring within them.
dtype : Numpy dtype, optional
Target dtype that is used for upcasting, in case integer data is to be
Z-scored.
"""
Mapper.__init__(self, **kwargs)
self.__chunks_attr = chunks_attr
self.__params = params
self.__param_est = param_est
self.__params_dict = None
self.__dtype = dtype
# secret switch to perform in-place z-scoring
self._secret_inplace_zscore = False
开发者ID:psederberg,项目名称:PyMVPA,代码行数:35,代码来源:zscore.py
示例5: __init__
def __init__(self, polyord=1, chunks_attr=None, opt_regs=None, **kwargs):
"""
Parameters
----------
space : str or None
If not None, a samples attribute of the same name is added to the
mapped dataset that stores the coordinates of each sample in the
space that is spanned by the polynomials. If an attribute of that
name is already present in the input dataset its values are interpreted
as sample coordinates in the space that should be spanned by the
polynomials.
"""
# keep param init for historical reasons
self.params.chunks_attr = chunks_attr
self.params.polyord = polyord
self.params.opt_regs = opt_regs
# things that come from train()
self._polycoords = None
self._regs = None
# secret switch to perform in-place detrending
self._secret_inplace_detrend = False
# need to init last to prevent base class puking
Mapper.__init__(self, **kwargs)
开发者ID:Arthurkorn,项目名称:PyMVPA,代码行数:26,代码来源:detrend.py
示例6: __init__
def __init__(self, num, window=None, chunks_attr=None, position_attr=None,
attr_strategy='remove', **kwargs):
"""
Parameters
----------
num : int
Number of output samples. If operating on chunks, this is the number
of samples per chunk.
window : str or float or tuple
Passed to scipy.signal.resample
chunks_attr : str or None
If not None, this samples attribute defines chunks that will be
resampled individually.
position_attr : str
A samples attribute with positional information that is passed
to scipy.signal.resample. If not None, the output dataset will
also contain a sample attribute of this name, with updated
positional information (this is, however, only meaningful for
equally spaced samples).
attr_strategy : {'remove', 'sample', 'resample'}
Strategy to process sample attributes during mapping. 'remove' will
cause all sample attributes to be removed. 'sample' will pick orginal
attribute values matching the new resampling frequency (e.g. every
10th), and 'resample' will also apply the actual data resampling
procedure to the attributes as well (which might not be possible, e.g.
for literal attributes).
"""
Mapper.__init__(self, **kwargs)
self.__num = num
self.__window_args = window
self.__chunks_attr = chunks_attr
self.__position_attr = position_attr
self.__attr_strategy = attr_strategy
开发者ID:armaneshaghi,项目名称:PyMVPA,代码行数:34,代码来源:filters.py
示例7: __init__
def __init__(self, node, nodeargs=None, **kwargs):
"""
Parameters
----------
node : mdp.Node instance
This node instance is taken as the pristine source of which a
copy is made for actual processing upon each training attempt.
nodeargs : dict
Dictionary for additional arguments for all calls to the MDP
node. The dictionary key's meaning is as follows:
'train'
Arguments for calls to `Node.train()`
'stoptrain'
Arguments for calls to `Node.stop_training()`
'exec'
Arguments for calls to `Node.execute()`
'inv'
Arguments for calls to `Node.inverse()`
The value for each item is always a 2-tuple, consisting of a
tuple (for the arguments), and a dictionary (for keyword
arguments), i.e. ((), {}). Both, tuple and dictionary have to be
provided even if they are empty.
inspace : see base class
"""
# TODO: starting from MDP2.5 this check should become:
# TODO: if node.has_multiple_training_phases():
if not len(node._train_seq) == 1:
raise ValueError("MDPNodeMapper does not support MDP nodes with "
"multiple training phases.")
Mapper.__init__(self, **kwargs)
self.__pristine_node = None
self.node = node
self.nodeargs = nodeargs
开发者ID:psederberg,项目名称:PyMVPA,代码行数:35,代码来源:mdp_adaptor.py
示例8: __init__
def __init__(self, axis, fx, fxargs=None, uattrs=None, attrfx="merge"):
"""
Parameters
----------
axis : {'samples', 'features'}
fx : callable
fxargs : tuple
uattrs : list
List of attribute names to consider. All possible combinations
of unique elements of these attributes are used to determine the
sample groups to operate on.
attrfx : callable
Functor that is called with each sample attribute elements matching
the respective samples group. By default the unique value is
determined. If the content of the attribute is not uniform for a
samples group a unique string representation is created.
If `None`, attributes are not altered.
"""
Mapper.__init__(self)
if not axis in ["samples", "features"]:
raise ValueError("%s `axis` arguments can only be 'samples' or " "'features' (got: '%s')." % repr(axis))
self.__axis = axis
self.__uattrs = uattrs
self.__fx = fx
if not fxargs is None:
self.__fxargs = fxargs
else:
self.__fxargs = ()
if attrfx == "merge":
self.__attrfx = _uniquemerge2literal
else:
self.__attrfx = attrfx
开发者ID:schoeke,项目名称:PyMVPA,代码行数:33,代码来源:fx.py
示例9: __init__
def __init__(self, demean=True):
"""Initialize the ProjectionMapper
Parameters
----------
demean : bool
Either data should be demeaned while computing
projections and applied back while doing reverse()
"""
Mapper.__init__(self)
# by default we want to wipe the feature attributes out during mapping
self._fa_filter = []
self._proj = None
"""Forward projection matrix."""
self._recon = None
"""Reverse projection (reconstruction) matrix."""
self._demean = demean
"""Flag whether to demean the to be projected data, prior to projection.
"""
self._offset_in = None
"""Offset (most often just mean) in the input space"""
self._offset_out = None
"""Offset (most often just mean) in the output space"""
开发者ID:arnaudsj,项目名称:PyMVPA,代码行数:25,代码来源:projection.py
示例10: __init__
def __init__(self, chunks_attr=None, k=8, mode="arpack", random_state=None, n_init=10, **kwargs):
"""
parameters
__________
chunks_attr : str or None
If provided, it specifies the name of a samples attribute in the
training data, unique values of which will be used to identify chunks of
samples, and to perform individual clustering within them.
k : int or ndarray
The number of clusters to form as well as the number of centroids to
generate. If init initialization string is matrix, or if a ndarray
is given instead, it is interpreted as initial cluster to use instead
mode : {None, 'arpack' or 'amg'}
The eigenvalue decomposition strategy to use. AMG requires pyamg
to be installed. It can be faster on very large, sparse problems,
but may also lead to instabilities.
random_state: int seed, RandomState instance, or None (default)
A pseudo random number generator used for the initialization
of the lobpcg eigen vectors decomposition when mode == 'amg'
and by the K-Means initialization.
n_init : int
Number of iterations of the k-means algrithm to run. Note that this
differs in meaning from the iters parameter to the kmeans function.
"""
Mapper.__init__(self, **kwargs)
self.__chunks_attr = chunks_attr
self.__k = k
self.__mode = mode
self.__random_state = random_state
self.__n_init = n_init
开发者ID:zetyang,项目名称:FreeROI,代码行数:31,代码来源:spectralmapper.py
示例11: __init__
def __init__(self, kshape, niter, learning_rate=0.005,
iradius=None, distance_metric=None, initialization_func=None):
"""
Parameters
----------
kshape : (int, int)
Shape of the internal Kohonen layer. Currently, only 2D Kohonen
layers are supported, although the length of an axis might be set
to 1.
niter : int
Number of iteration during network training.
learning_rate : float
Initial learning rate, which will continuously decreased during
network training.
iradius : float or None
Initial radius of the Gaussian neighborhood kernel radius, which
will continuously decreased during network training. If `None`
(default) the radius is set equal to the longest edge of the
Kohonen layer.
distance_metric: callable or None
Kernel distance metric between elements in Kohonen layer. If None
then Euclidean distance is used. Otherwise it should be a
callable that accepts two input arguments x and y and returns
the distance d through d=distance_metric(x,y)
initialization_func: callable or None
Initialization function to set self._K, that should take one
argument with training samples and return an numpy array. If None,
then values in the returned array are taken from a standard normal
distribution.
"""
# init base class
Mapper.__init__(self)
self.kshape = np.array(kshape, dtype='int')
if iradius is None:
self.radius = self.kshape.max()
else:
self.radius = iradius
if distance_metric is None:
self.distance_metric = lambda x, y: (x ** 2 + y ** 2) ** 0.5
else:
self.distance_metric = distance_metric
# learning rate
self.lrate = learning_rate
# number of training iterations
self.niter = niter
# precompute whatever can be done
# scalar for decay of learning rate and radius across all iterations
self.iter_scale = self.niter / np.log(self.radius)
# the internal kohonen layer
self._K = None
self._dqd = None
self._initialization_func = initialization_func
开发者ID:Arthurkorn,项目名称:PyMVPA,代码行数:59,代码来源:som.py
示例12: __init__
def __init__(self, slicearg, **kwargs):
"""
Parameters
----------
slicearg
Argument for slicing
"""
Mapper.__init__(self, **kwargs)
self._safe_assign_slicearg(slicearg)
开发者ID:PepGardiola,项目名称:PyMVPA,代码行数:9,代码来源:slicing.py
示例13: __init__
def __init__(self, distmask=None, **kwargs):
"""
parameters
----------
distmask : ndarray-like matrix or sparse matrix, or a dataset.
The distmask of voxels to present their neighbors.
Usually we do not set it.
"""
Mapper.__init__(self, **kwargs)
self.__distmask = distmask
开发者ID:BNUCNL,项目名称:FreeROI,代码行数:11,代码来源:spatialdistancemapper.py
示例14: __init__
def __init__(self,neighbor_shape, outsparse=True, **kwargs):
"""
Parameters
----------
neighborhood : .
outsparse: bool
whether to output sparse matrix.
"""
Mapper.__init__(self, **kwargs)
self.__outsparse = outsparse
self.__neighbor_shape = neighbor_shape
开发者ID:BNUCNL,项目名称:FreeROI,代码行数:12,代码来源:neighbormapper.py
示例15: __init__
def __init__(self, pos, **kwargs):
"""
Parameters
----------
pos : int
Axis index to which the new axis is prepended. Negative indices are
supported as well, but the new axis will be placed behind the given
index. For example, a position of ``-1`` will cause an axis to be
added behind the last axis. If ``pos`` is larger than the number of
existing axes additional new axes will be created match the value of
``pos``.
"""
Mapper.__init__(self, **kwargs)
self._pos = pos
开发者ID:robbisg,项目名称:PyMVPA,代码行数:14,代码来源:shape.py
示例16: __init__
def __init__(self, metric='euclidean', **kwargs):
"""
parameters
__________
metric : string or function
The distance metric to use. The distance function can be 'braycurtis',
'canberra', 'chebyshev', 'cityblock', 'correlation', 'cosine', 'dice',
'euclidean', 'hamming', 'jaccard', 'kulsinski', 'mahalanobis',
'matching', 'minkowski', 'rogerstanimoto', 'russellrao', 'seuclidean',
'sokalmichener', 'sokalsneath', 'sqeuclidean', 'yule'.
"""
Mapper.__init__(self, **kwargs)
self.__metric = metric
开发者ID:BNUCNL,项目名称:FreeROI,代码行数:14,代码来源:featuredistancemapper.py
示例17: __init__
def __init__(self, axis, fx, fxargs=None, uattrs=None,
attrfx='merge', order='uattrs'):
"""
Parameters
----------
axis : {'samples', 'features'}
fx : callable
fxargs : tuple
Passed as *args to ``fx``
uattrs : list
List of attribute names to consider. All possible combinations
of unique elements of these attributes are used to determine the
sample groups to operate on.
attrfx : callable
Functor that is called with each sample attribute elements matching
the respective samples group. By default the unique value is
determined. If the content of the attribute is not uniform for a
samples group a unique string representation is created.
If `None`, attributes are not altered.
order : {'uattrs', 'occurrence', None}
If which order groups should be merged together. If `None` (default
before 2.3.1), the order is imposed only by the order of
`uattrs` as keys in the dictionary, thus can vary from run to run.
If `'occurrence'`, groups will be ordered by the first occurrence
of group samples in original dataset. If `'uattrs'`, groups will be
sorted by the values of uattrs with follow-up attr having higher
importance for ordering (e .g. `uattrs=['targets', 'chunks']` would
order groups first by `chunks` and then by `targets` within each
chunk).
"""
Mapper.__init__(self)
if not axis in ['samples', 'features']:
raise ValueError("%s `axis` arguments can only be 'samples' or "
"'features' (got: '%s')." % repr(axis))
self.__axis = axis
self.__uattrs = uattrs
self.__fx = fx
if not fxargs is None:
self.__fxargs = fxargs
else:
self.__fxargs = ()
if attrfx == 'merge':
self.__attrfx = _uniquemerge2literal
else:
self.__attrfx = attrfx
assert(order in (None, 'uattrs', 'occurrence'))
self.__order = order
开发者ID:Arthurkorn,项目名称:PyMVPA,代码行数:48,代码来源:fx.py
示例18: __init__
def __init__(self, polyord=1, chunks_attr=None, opt_regs=None, **kwargs):
"""
Parameters
----------
polyord : int or list, optional
Order of the Legendre polynomial to remove from the data. This
will remove every polynomial up to and including the provided
value. For example, 3 will remove 0th, 1st, 2nd, and 3rd order
polynomials from the data. np.B.: The 0th polynomial is the
baseline shift, the 1st is the linear trend.
If you specify a single int and `chunks_attr` is not None, then this value
is used for each chunk. You can also specify a different polyord
value for each chunk by providing a list or ndarray of polyord
values the length of the number of chunks.
chunks_attr : str or None
If None, the whole dataset is detrended at once. Otherwise, the given
samples attribute (given by its name) is used to define chunks of the
dataset that are processed individually. In that case, all the samples
within a chunk should be in contiguous order and the chunks should be
sorted in order from low to high -- unless the dataset provides
information about the coordinate of each sample in the space that
should be spanned be the polynomials (see `inspace` argument).
opt_regs : list or None
Optional list of sample attribute names that should be used as
additional regressors. One example would be to regress out motion
parameters.
space : str or None
If not None, a samples attribute of the same name is added to the
mapped dataset that stores the coordinates of each sample in the
space that is spanned by the polynomials. If an attribute of that
name is already present in the input dataset its values are interpreted
as sample coordinates in the space that should be spanned by the
polynomials.
"""
self.__chunks_attr = chunks_attr
self.__polyord = polyord
self.__opt_reg = opt_regs
# things that come from train()
self._polycoords = None
self._regs = None
# secret switch to perform in-place detrending
self._secret_inplace_detrend = False
# need to init last to prevent base class puking
Mapper.__init__(self, **kwargs)
开发者ID:arnaudsj,项目名称:PyMVPA,代码行数:47,代码来源:detrend.py
示例19: __init__
def __init__(self, transformer, **kwargs):
"""
Parameters
----------
transformer : sklearn.transformer instance
space : str or None, optional
If not None, a sample attribute of the given name will be extracted
from the training dataset and passed to the sklearn transformer's
``fit()`` method as ``y`` argument.
"""
# NOTE: trailing spaces in above docstring must not be pruned
# for correct parsing
Mapper.__init__(self, auto_train=False, **kwargs)
self._transformer = None
self._pristine_transformer = transformer
开发者ID:Guenx,项目名称:PyMVPA,代码行数:17,代码来源:skl_adaptor.py
示例20: __repr__
def __repr__(self):
s = Mapper.__repr__(self).rstrip(' )')
# beautify
if not s[-1] == '(':
s += ' '
s += 'kshape=%s, niter=%i, learning_rate=%f, iradius=%f)' \
% (str(tuple(self.kshape)), self.niter, self.lrate,
self.radius)
return s
开发者ID:PepGardiola,项目名称:PyMVPA,代码行数:9,代码来源:som.py
注:本文中的mvpa2.mappers.base.Mapper类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论