当前位置: 首页>>代码示例>>Python>>正文


Python Pipeline.fit_predict方法代码示例

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


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

示例1: test_fit_predict_with_intermediate_fit_params

# 需要导入模块: from imblearn.pipeline import Pipeline [as 别名]
# 或者: from imblearn.pipeline.Pipeline import fit_predict [as 别名]
def test_fit_predict_with_intermediate_fit_params():
    # tests that Pipeline passes fit_params to intermediate steps
    # when fit_predict is invoked
    pipe = Pipeline([('transf', TransfFitParams()), ('clf', FitParamT())])
    pipe.fit_predict(
        X=None, y=None, transf__should_get_this=True, clf__should_succeed=True)
    assert pipe.named_steps['transf'].fit_params['should_get_this']
    assert pipe.named_steps['clf'].successful
    assert 'should_succeed' not in pipe.named_steps['transf'].fit_params
开发者ID:scikit-learn-contrib,项目名称:imbalanced-learn,代码行数:11,代码来源:test_pipeline.py

示例2: test_fit_predict_on_pipeline

# 需要导入模块: from imblearn.pipeline import Pipeline [as 别名]
# 或者: from imblearn.pipeline.Pipeline import fit_predict [as 别名]
def test_fit_predict_on_pipeline():
    # test that the fit_predict method is implemented on a pipeline
    # test that the fit_predict on pipeline yields same results as applying
    # transform and clustering steps separately
    iris = load_iris()
    scaler = StandardScaler()
    km = KMeans(random_state=0)

    # first compute the transform and clustering step separately
    scaled = scaler.fit_transform(iris.data)
    separate_pred = km.fit_predict(scaled)

    # use a pipeline to do the transform and clustering in one step
    pipe = Pipeline([('scaler', scaler), ('Kmeans', km)])
    pipeline_pred = pipe.fit_predict(iris.data)

    assert_array_almost_equal(pipeline_pred, separate_pred)
开发者ID:apyeh,项目名称:UnbalancedDataset,代码行数:19,代码来源:test_pipeline.py


注:本文中的imblearn.pipeline.Pipeline.fit_predict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。