org.apache.spark.ml
Class Pipeline

Object
  extended by org.apache.spark.ml.PipelineStage
      extended by org.apache.spark.ml.Estimator<PipelineModel>
          extended by org.apache.spark.ml.Pipeline
All Implemented Interfaces:
java.io.Serializable, Logging, Params

public class Pipeline
extends Estimator<PipelineModel>

:: 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 fit(org.apache.spark.sql.DataFrame) is called, the stages are executed in order. If a stage is an Estimator, its Estimator.fit(org.apache.spark.sql.DataFrame, org.apache.spark.ml.param.ParamPair, org.apache.spark.ml.param.ParamPair...) 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(org.apache.spark.sql.DataFrame, org.apache.spark.ml.param.ParamPair, org.apache.spark.ml.param.ParamPair...) 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.

See Also:
Serialized Form

Constructor Summary
Pipeline()
           
Pipeline(String uid)
           
 
Method Summary
 Pipeline copy(ParamMap extra)
          Creates a copy of this instance with the same UID and some extra params.
 PipelineModel fit(DataFrame dataset)
          Fits the pipeline to the input dataset with additional parameters.
 PipelineStage[] getStages()
           
 Pipeline setStages(PipelineStage[] value)
           
 Param<PipelineStage[]> stages()
          param for pipeline stages
 StructType transformSchema(StructType schema)
          :: DeveloperApi ::
 String uid()
           
 void validateParams()
          Validates parameter values stored internally.
 
Methods inherited from class org.apache.spark.ml.Estimator
fit, fit, fit, fit
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.spark.ml.param.Params
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, setDefault, shouldOwn
 
Methods inherited from interface org.apache.spark.Logging
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
 

Constructor Detail

Pipeline

public Pipeline(String uid)

Pipeline

public Pipeline()
Method Detail

uid

public String uid()

stages

public Param<PipelineStage[]> stages()
param for pipeline stages

Returns:
(undocumented)

setStages

public Pipeline setStages(PipelineStage[] value)

getStages

public PipelineStage[] getStages()

validateParams

public void validateParams()
Description copied from interface: Params
Validates parameter values stored internally. Raise an exception if any parameter value is invalid.

This only needs to check for interactions between parameters. Parameter value checks which do not depend on other parameters are handled by Param.validate(). This method does not handle input/output column parameters; those are checked during schema validation.


fit

public PipelineModel fit(DataFrame dataset)
Fits the pipeline to the input dataset with additional parameters. If a stage is an Estimator, its Estimator.fit(org.apache.spark.sql.DataFrame, org.apache.spark.ml.param.ParamPair, org.apache.spark.ml.param.ParamPair...) 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(org.apache.spark.sql.DataFrame, org.apache.spark.ml.param.ParamPair, org.apache.spark.ml.param.ParamPair...) 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 output model acts as an identity transformer.

Specified by:
fit in class Estimator<PipelineModel>
Parameters:
dataset - input dataset
Returns:
fitted pipeline

copy

public Pipeline copy(ParamMap extra)
Description copied from interface: Params
Creates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly.

Specified by:
copy in interface Params
Specified by:
copy in class Estimator<PipelineModel>
Parameters:
extra - (undocumented)
Returns:
(undocumented)
See Also:
defaultCopy()

transformSchema

public StructType transformSchema(StructType schema)
Description copied from class: PipelineStage
:: DeveloperApi ::

Derives the output schema from the input schema.

Specified by:
transformSchema in class PipelineStage
Parameters:
schema - (undocumented)
Returns:
(undocumented)