test_ensemble_as_transformer.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mlens 作者: flennerhag 项目源码 文件源码
def run(cls, kls, proba, preprocessing, **kwargs):
    """Function for executing specified test."""
    model_selection = kwargs.pop('model_selection', None)
    if kls == 'subsemble':
        p = kwargs['partitions']
    else:
        p = 1

    ests = ESTS[(proba, preprocessing)]
    prep = PREPROCESSING if preprocessing else None

    data = Data(kls, proba, preprocessing, **kwargs)

    X, y = data.get_data((LEN, WIDTH), MOD)
    (F, wf), _ = data.ground_truth(X, y, p)

    with open(os.devnull, 'w') as f, redirect_stderr(f):
        ens = cls()
        ens.add(kls, ests, prep, proba=proba, dtype=np.float64, **kwargs)

        if model_selection:
            ens.model_selection = True

        ens.fit(X, y)

        pred, _ = ens.transform(X, y)

    np.testing.assert_array_equal(F, pred)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号