org.apache.spark.ml.param
Interface Params

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
ALS, ALSModel, Binarizer, BinaryClassificationEvaluator, Bucketizer, ClassificationModel, Classifier, CrossValidator, CrossValidatorModel, DecisionTreeClassificationModel, DecisionTreeClassifier, DecisionTreeRegressionModel, DecisionTreeRegressor, ElementwiseProduct, Estimator, Evaluator, GBTClassificationModel, GBTClassifier, GBTRegressionModel, GBTRegressor, HashingTF, IDF, IDFModel, JavaParams, LinearRegression, LinearRegressionModel, LogisticRegression, LogisticRegressionModel, Model, Normalizer, OneHotEncoder, OneVsRest, OneVsRestModel, Pipeline, PipelineModel, PipelineStage, PolynomialExpansion, PredictionModel, Predictor, RandomForestClassificationModel, RandomForestClassifier, RandomForestRegressionModel, RandomForestRegressor, RegexTokenizer, RegressionEvaluator, RegressionModel, StandardScaler, StandardScalerModel, StringIndexer, StringIndexerModel, Tokenizer, Transformer, UnaryTransformer, VectorAssembler, VectorIndexer, VectorIndexerModel, Word2Vec, Word2VecModel

public interface Params
extends scala.Serializable

:: DeveloperApi :: Trait for components that take parameters. This also provides an internal param map to store parameter values attached to the instance.


Method Summary
 Params clear(Param<?> param)
          Clears the user-supplied value for the input param.
 Params copy(ParamMap extra)
          Creates a copy of this instance with the same UID and some extra params.
<T extends Params>
T
copyValues(T to, ParamMap extra)
          Copies param values from this instance to another instance for params shared by them.
<T extends Params>
T
defaultCopy(ParamMap extra)
          Default implementation of copy with extra params.
 ParamMap defaultParamMap()
          Internal param map for default values.
 String explainParam(Param<?> param)
          Explains a param.
 String explainParams()
          Explains all params of this instance.
 ParamMap extractParamMap()
          extractParamMap with no extra values.
 ParamMap extractParamMap(ParamMap extra)
          Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.
<T> scala.Option<T>
get(Param<T> param)
          Optionally returns the user-supplied value of a param.
<T> scala.Option<T>
getDefault(Param<T> param)
          Gets the default value of a parameter.
<T> T
getOrDefault(Param<T> param)
          Gets the value of a param in the embedded param map or its default value.
 Param<Object> getParam(String paramName)
          Gets a param by its name.
<T> boolean
hasDefault(Param<T> param)
          Tests whether the input param has a default value set.
 boolean hasParam(String paramName)
          Tests whether this instance contains a param with a given name.
 boolean isDefined(Param<?> param)
          Checks whether a param is explicitly set or has a default value.
 boolean isSet(Param<?> param)
          Checks whether a param is explicitly set.
 ParamMap paramMap()
          Internal param map for user-supplied values.
 Param<?>[] params()
          Returns all params sorted by their names.
<T> Params
set(Param<T> param, T value)
          Sets a parameter in the embedded param map.
 Params set(ParamPair<?> paramPair)
          Sets a parameter in the embedded param map.
 Params set(String param, Object value)
          Sets a parameter (by name) in the embedded param map.
<T> Params
setDefault(Param<T> param, T value)
          Sets a default value for a param.
 Params setDefault(ParamPair<?>... paramPairs)
          Sets default values for a list of params.
 Params setDefault(scala.collection.Seq<ParamPair<?>> paramPairs)
          Sets default values for a list of params.
 void shouldOwn(Param<?> param)
          Validates that the input param belongs to this instance.
 void validateParams()
          Validates parameter values stored internally.
 

Method Detail

setDefault

Params setDefault(ParamPair<?>... paramPairs)
Sets default values for a list of params.

Parameters:
paramPairs - a list of param pairs that specify params and their default values to set respectively. Make sure that the params are initialized before this method gets called.
Returns:
(undocumented)

params

Param<?>[] params()
Returns all params sorted by their names. The default implementation uses Java reflection to list all public methods that have no arguments and return Param.

Note: Developer should not use this method in constructor because we cannot guarantee that this variable gets initialized before other params.

Returns:
(undocumented)

validateParams

void validateParams()
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.


explainParam

String explainParam(Param<?> param)
Explains a param.

Parameters:
param - input param, must belong to this instance.
Returns:
a string that contains the input param name, doc, and optionally its default value and the user-supplied value

explainParams

String explainParams()
Explains all params of this instance.

Returns:
(undocumented)
See Also:
explainParam()

isSet

boolean isSet(Param<?> param)
Checks whether a param is explicitly set.


isDefined

boolean isDefined(Param<?> param)
Checks whether a param is explicitly set or has a default value.


hasParam

boolean hasParam(String paramName)
Tests whether this instance contains a param with a given name.


getParam

Param<Object> getParam(String paramName)
Gets a param by its name.


set

<T> Params set(Param<T> param,
               T value)
Sets a parameter in the embedded param map.

Parameters:
param - (undocumented)
value - (undocumented)
Returns:
(undocumented)

set

Params set(String param,
           Object value)
Sets a parameter (by name) in the embedded param map.

Parameters:
param - (undocumented)
value - (undocumented)
Returns:
(undocumented)

set

Params set(ParamPair<?> paramPair)
Sets a parameter in the embedded param map.

Parameters:
paramPair - (undocumented)
Returns:
(undocumented)

get

<T> scala.Option<T> get(Param<T> param)
Optionally returns the user-supplied value of a param.

Parameters:
param - (undocumented)
Returns:
(undocumented)

clear

Params clear(Param<?> param)
Clears the user-supplied value for the input param.

Parameters:
param - (undocumented)
Returns:
(undocumented)

getOrDefault

<T> T getOrDefault(Param<T> param)
Gets the value of a param in the embedded param map or its default value. Throws an exception if neither is set.

Parameters:
param - (undocumented)
Returns:
(undocumented)

setDefault

<T> Params setDefault(Param<T> param,
                      T value)
Sets a default value for a param.

Parameters:
param - param to set the default value. Make sure that this param is initialized before this method gets called.
value - the default value
Returns:
(undocumented)

setDefault

Params setDefault(scala.collection.Seq<ParamPair<?>> paramPairs)
Sets default values for a list of params.

Parameters:
paramPairs - a list of param pairs that specify params and their default values to set respectively. Make sure that the params are initialized before this method gets called.
Returns:
(undocumented)

getDefault

<T> scala.Option<T> getDefault(Param<T> param)
Gets the default value of a parameter.

Parameters:
param - (undocumented)
Returns:
(undocumented)

hasDefault

<T> boolean hasDefault(Param<T> param)
Tests whether the input param has a default value set.

Parameters:
param - (undocumented)
Returns:
(undocumented)

copy

Params copy(ParamMap extra)
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.

Parameters:
extra - (undocumented)
Returns:
(undocumented)
See Also:
defaultCopy()

defaultCopy

<T extends Params> T defaultCopy(ParamMap extra)
Default implementation of copy with extra params. It tries to create a new instance with the same UID. Then it copies the embedded and extra parameters over and returns the new instance.

Parameters:
extra - (undocumented)
Returns:
(undocumented)

extractParamMap

ParamMap extractParamMap(ParamMap extra)
Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.

Parameters:
extra - (undocumented)
Returns:
(undocumented)

extractParamMap

ParamMap extractParamMap()
extractParamMap with no extra values.

Returns:
(undocumented)

paramMap

ParamMap paramMap()
Internal param map for user-supplied values.


defaultParamMap

ParamMap defaultParamMap()
Internal param map for default values.


shouldOwn

void shouldOwn(Param<?> param)
Validates that the input param belongs to this instance.


copyValues

<T extends Params> T copyValues(T to,
                                ParamMap extra)
Copies param values from this instance to another instance for params shared by them.

Parameters:
to - the target instance
extra - extra params to be copied
Returns:
the target instance with param values copied