[译]sklearn.pipeline.Pipeline

本文详细介绍了sklearn库中的Pipeline模块,它允许用户串联一系列转换操作和最终的评估器,其中转换器需具备fit、transform方法,而评估器只需fit。Pipeline的主要用途是便于在交叉验证中设定和调整各步骤的参数。通过特殊的命名规则,可以方便地替换或移除流程中的组件。推荐阅读《sklearn 中的 Pipeline 机制》以获取更深入的理解。
摘要由CSDN通过智能技术生成

class sklearn.pipeline.Pipeline(steps, memory=None, verbose=False)

带有最终评估量的转换流程。

循序的运用一些列转换和一个最终评估量。Pipeline的中间步骤必须是’transforms’,就是说,他们必须实现fit、transform方法。最终评估量只需要执行fit。流程中的转换方法可以用memory参数暂存。

pipeline的目的是集成几个步骤,以便设定不同参数进行交叉验证。为了实现这个目标,设置不同步骤的参数和参数名用“_”分来。

一个步骤的评估量可通过设置参数成它的name来替换另一个评估量。或者一个转换步骤可以通过设置‘passthrough’ or None来取消掉。

  • Parameters

Parameters数据类型意义
stepslist一些列需要成链的过程,最后是评估量
memoryNone, str or object with the joblib.Memory interface, optional用于缓存流程中的待拟合转换过程
verboseboolean, optionalTrue:每步完成后消耗的时间会被print
  • Attributes

Attributes意义
named_steps查看步骤参数,keys是step name,values是step parameters
  • Methods

Methods意义
decision_function(self, X)Apply transforms, and decision_function of the final estimator
fit(self, X[, y])Fit the model
fit_predict(self, X[, y])Applies fit_predict of last step in pipeline after transforms.
fit_transform(self, X[, y])Fit the model and transform with the final estimator
get_params(self[, deep])Get parameters for this estimator.
predict(self, X, **predict_params)Apply transforms to the data, and predict with the final estimator
predict_log_proba(self, X)Apply transforms, and predict_log_proba of the final estimator
predict_proba(self, X)Apply transforms, and predict_proba of the final estimator
score(self, X[, y, sample_weight])Apply transforms, and score with the final estimator
set_params(self, **kwargs)Set the parameters of this estimator.

这篇翻译的更好:《sklearn 中的 Pipeline 机制

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值