spark MLlib的 pipeline方式

spark mllib的pipeline,是指将多个机器学习的算法串联到一个工作链中,依次执行各种算法。

在Pipeline中的每个算法被称为“PipelineStage”,表示其中的一个算法。PipelineStage分为两种类型, Estimator和Transformer, 其中
  • Transformer将数据转换为两一种形式(例如修改格式),以供后续的Estimator使用,统一的转换函数transform;
  • Estimator是由数据得到一个Mode(Mode也是继承于Transformer),有统一触发的函数fit。

然后一个“综合”的算法就可以通过pipeline封装起来。这样做的好处是可以很方便的替换算法。例如,我们在应用中往往只是笼统的期望一个“分类”、”拟合“这样的功能,但不知道是用分类或拟合的那个算法效果是最好的,有了这种pipeline机制后,很方便替换各种分类和拟合算法,从而得到最好的效果。

 
      
/**
* :: Experimental ::
* A simple pipeline, which acts as an estimator. A Pipeline consists of a sequence of stages, each
* of which is either an [[Estimator]] or a [[Transformer]]. When [[Pipeline#fit]] is called, the
* stages are executed in order. If a stage is an [[Estimator]], its [[Estimator#fit]] method will
* be called on the input dataset to fit a model. Then the model, which is a transformer, will be
* used to transform the dataset as the input to the next stage. If a stage is a [[Transformer]],
* its [[Transformer#transform]] method will be called to produce the dataset for the next stage.
* The fitted model from a [[Pipeline]] is an [[PipelineModel]], which consists of fitted models and
* transformers, corresponding to the pipeline stages. If there are no stages, the pipeline acts as
* an identity transformer.
*/
@Experimental
class Pipeline(override val uid: String) extends Estimator[PipelineModel] {





posted on 2015-07-09 17:24 过雁 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/zwCHAN/p/4633753.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spark MLlib中,Pipeline是一个用于构建和组织机器学习工作流程的概念和工具。它由多个Transformer和Estimator组成,用于处理和转换数据,并训练和应用机器学习模型。 引用提到了Pipeline是一个Estimator,这意味着它可以作为一个整体来进行训练和评估,产生一个PipelineModel。PipelineModel本身也是一个Transformer,可以用于在测试数据上进行预测。 引用提到了Pipeline的stages,这些stages被定义为一个顺序数组,用于指定数据处理和转换的顺序。目前给出的例子都是线性的Pipeline,即每个stage使用前一stage产生的数据。但如果Pipeline形成为DAG(有向无环图),则可以创建非线性的Pipelines。在这种情况下,stage必须按照拓扑顺序进行指定。 引用简要介绍了Pipeline的作用,它用于连接多个Transformers和Estimators,以确定整个机器学习工作流程。Pipeline可以帮助我们更好地组织和管理机器学习任务,使其更加灵活高效。 综上所述,在Spark MLlib中,Pipeline是一个用于构建和组织机器学习工作流程的工具,它由多个Transformer和Estimator组成,可以进行数据处理和转换,并训练和应用机器学习模型。它的stages可以按顺序指定,也可以形成非线性的DAG结构。Pipeline的主要作用是连接和管理整个机器学习任务的流程。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [SparkMl之pipeline](https://blog.csdn.net/lukabruce/article/details/126054328)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值