本文整理汇总了Python中sklearn.utils.validation.indexable方法的典型用法代码示例。如果您正苦于以下问题:Python validation.indexable方法的具体用法?Python validation.indexable怎么用?Python validation.indexable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.utils.validation
的用法示例。
在下文中一共展示了validation.indexable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: split
# 需要导入模块: from sklearn.utils import validation [as 别名]
# 或者: from sklearn.utils.validation import indexable [as 别名]
def split(self, y, exogenous=None):
"""Generate indices to split data into training and test sets
Parameters
----------
y : array-like or iterable, shape=(n_samples,)
The time-series array.
exogenous : array-like, shape=[n_obs, n_vars], optional (default=None)
An optional 2-d array of exogenous variables.
Yields
------
train : np.ndarray
The training set indices for the split
test : np.ndarray
The test set indices for the split
"""
y, exog = indexable(y, exogenous)
indices = np.arange(y.shape[0])
for train_index, test_index in self._iter_train_test_masks(y, exog):
train_index = indices[train_index]
test_index = indices[test_index]
yield train_index, test_index
示例2: to_indexable
# 需要导入模块: from sklearn.utils import validation [as 别名]
# 或者: from sklearn.utils.validation import indexable [as 别名]
def to_indexable(*args, **kwargs):
"""Ensure that all args are an indexable type.
Conversion runs lazily for dask objects, immediately otherwise.
Parameters
----------
args : array_like or scalar
allow_scalars : bool, optional
Whether to allow scalars in args. Default is False.
"""
if kwargs.get("allow_scalars", False):
indexable = _maybe_indexable
else:
indexable = _indexable
for x in args:
if x is None or isinstance(x, (da.Array, dd.DataFrame)):
yield x
elif is_dask_collection(x):
yield delayed(indexable, pure=True)(x)
else:
yield indexable(x)
示例3: _indexable
# 需要导入模块: from sklearn.utils import validation [as 别名]
# 或者: from sklearn.utils.validation import indexable [as 别名]
def _indexable(x):
return indexable(x)[0]
示例4: _maybe_indexable
# 需要导入模块: from sklearn.utils import validation [as 别名]
# 或者: from sklearn.utils.validation import indexable [as 别名]
def _maybe_indexable(x):
return indexable(x)[0] if _is_arraylike(x) else x