python iteritems函数_Python six.iteritems方法代码示例

本文整理汇总了Python中sklearn.externals.six.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python six.iteritems方法的具体用法?Python six.iteritems怎么用?Python six.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块sklearn.externals.six的用法示例。

在下文中一共展示了six.iteritems方法的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: fit

​点赞 6

# 需要导入模块: from sklearn.externals import six [as 别名]

# 或者: from sklearn.externals.six import iteritems [as 别名]

def fit(self, Z, **fit_params):

"""TODO: rewrite docstring

Fit all transformers using X.

Parameters

----------

X : array-like or sparse matrix, shape (n_samples, n_features)

Input data, used to fit transformers.

"""

fit_params_steps = dict((step, {})

for step, _ in self.transformer_list)

for pname, pval in six.iteritems(fit_params):

step, param = pname.split('__', 1)

fit_params_steps[step][param] = pval

transformers = Parallel(n_jobs=self.n_jobs, backend="threading")(

delayed(_fit_one_transformer)(trans, Z, **fit_params_steps[name])

for name, trans in self.transformer_list)

self._update_transformer_list(transformers)

return self

开发者ID:lensacom,项目名称:sparkit-learn,代码行数:22,

示例2: test_type_of_target

​点赞 6

# 需要导入模块: from sklearn.externals import six [as 别名]

# 或者: from sklearn.externals.six import iteritems [as 别名]

def test_type_of_target():

for group, group_examples in iteritems(EXAMPLES):

for example in group_examples:

assert_equal(type_of_target(example), group,

msg=('type_of_target(%r) should be %r, got %r'

% (example, group, type_of_target(example))))

for example in NON_ARRAY_LIKE_EXAMPLES:

msg_regex = 'Expected array-like \(array or non-string sequence\).*'

assert_raises_regex(ValueError, msg_regex, type_of_target, example)

for example in MULTILABEL_SEQUENCES:

msg = ('You appear to be using a legacy multi-label data '

'representation. Sequence of sequences are no longer supported;'

' use a binary array or sparse matrix instead.')

assert_raises_regex(ValueError, msg, type_of_target, example)

try:

from pandas import SparseSeries

except ImportError:

raise SkipTest("Pandas not found")

y = SparseSeries([1, 0, 0, 1, 0])

msg = "y cannot be class 'SparseSeries'."

assert_raises_regex(ValueError, msg, type_of_target, y)

开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:27,

示例3: get_params

​点赞 5

# 需要导入模块: from sklearn.externals import six [as 别名]

# 或者: from sklearn.externals.six import iteritems [as 别名]

def get_params(self, deep=True):

""" Get classifier parameter names for GridSearch"""

if not deep:

return super(MajorityVoteClassifier, self).get_params(deep=False)

else:

out = self.named_classifiers.copy()

for name, step in six.iteritems(self.named_classifiers):

for key, value in six.iteritems(step.get_params(deep=True)):

out['%s__%s' % (name, key)] = value

return out

开发者ID:rrlyman,项目名称:PythonMachineLearningExamples,代码行数:12,

示例4: _clone_h2o_obj

​点赞 5

# 需要导入模块: from sklearn.externals import six [as 别名]

# 或者: from sklearn.externals.six import iteritems [as 别名]

def _clone_h2o_obj(estimator, ignore=False, **kwargs):

# do initial clone

est = clone(estimator)

# set kwargs:

if kwargs:

for k, v in six.iteritems(kwargs):

setattr(est, k, v)

# check on h2o estimator

if isinstance(estimator, H2OPipeline):

# the last step from the original estimator

e = estimator.steps[-1][1]

if isinstance(e, H2OEstimator):

last_step = est.steps[-1][1]

# so it's the last step

for k, v in six.iteritems(e._parms):

k, v = _kv_str(k, v)

# if (not k in PARM_IGNORE) and (not v is None):

# e._parms[k] = v

last_step._parms[k] = v

# otherwise it's an BaseH2OFunctionWrapper

return est

开发者ID:tgsmith61591,项目名称:skutil,代码行数:28,

示例5: _new_base_estimator

​点赞 5

# 需要导入模块: from sklearn.externals import six [as 别名]

# 或者: from sklearn.externals.six import iteritems [as 别名]

def _new_base_estimator(est, clonable_kwargs):

"""When the grid searches are pickled, the estimator

has to be dropped out. When we load it back in, we have

to reinstate a new one, since the fit is predicated on

being able to clone a base estimator, we've got to have

an estimator to clone and fit.

Parameters

----------

est : str

The type of model to build

Returns

-------

estimator : H2OEstimator

The cloned base estimator

"""

est_map = {

'dl': H2ODeepLearningEstimator,

'gbm': H2OGradientBoostingEstimator,

'glm': H2OGeneralizedLinearEstimator,

# 'glrm': H2OGeneralizedLowRankEstimator,

# 'km' : H2OKMeansEstimator,

'nb': H2ONaiveBayesEstimator,

'rf': H2ORandomForestEstimator

}

estimator = est_map[

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值