Interface Params

All Superinterfaces:
Identifiable, Serializable
All Known Subinterfaces:
AFTSurvivalRegressionParams, ALSModelParams, ALSParams, BisectingKMeansParams, BucketedRandomProjectionLSHParams, ClassifierParams, CountVectorizerParams, CrossValidatorParams, DecisionTreeClassifierParams, DecisionTreeParams, DecisionTreeRegressorParams, FactorizationMachines, FactorizationMachinesParams, FMClassifierParams, FMRegressorParams, FPGrowthParams, GaussianMixtureParams, GBTClassifierParams, GBTParams, GBTRegressorParams, GeneralizedLinearRegressionBase, HasAggregationDepth, HasBlockSize, HasCheckpointInterval, HasCollectSubModels, HasDistanceMeasure, HasElasticNetParam, HasFeaturesCol, HasFitIntercept, HasHandleInvalid, HasInputCol, HasInputCols, HasLabelCol, HasLoss, HasMaxBlockSizeInMB, HasMaxIter, HasNumFeatures, HasOutputCol, HasOutputCols, HasParallelism, HasPredictionCol, HasProbabilityCol, HasRawPredictionCol, HasRegParam, HasRelativeError, HasSeed, HasSolver, HasStandardization, HasStepSize, HasThreshold, HasThresholds, HasTol, HasValidationIndicatorCol, HasVarianceCol, HasVarianceImpurity, HasWeightCol, IDFBase, ImputerParams, IsotonicRegressionBase, KMeansParams, LDAParams, LinearRegressionParams, LinearSVCParams, LogisticRegressionParams, LSHParams, MaxAbsScalerParams, MinMaxScalerParams, MultilayerPerceptronParams, NaiveBayesParams, OneHotEncoderBase, OneVsRestParams, PCAParams, PowerIterationClusteringParams, PredictorParams, ProbabilisticClassifierParams, QuantileDiscretizerBase, RandomForestClassifierParams, RandomForestParams, RandomForestRegressorParams, RFormulaBase, RobustScalerParams, SelectorParams, StandardScalerParams, StringIndexerBase, TrainValidationSplitParams, TreeClassifierParams, TreeEnsembleClassifierParams, TreeEnsembleParams, TreeEnsembleRegressorParams, TreeRegressorParams, UnivariateFeatureSelectorParams, ValidatorParams, VarianceThresholdSelectorParams, VectorIndexerParams, Word2VecBase
All Known Implementing Classes:
AFTSurvivalRegression, AFTSurvivalRegressionModel, ALS, ALSModel, Binarizer, BinaryClassificationEvaluator, BisectingKMeans, BisectingKMeansModel, BucketedRandomProjectionLSH, BucketedRandomProjectionLSHModel, Bucketizer, ChiSqSelector, ChiSqSelectorModel, ClassificationModel, Classifier, ClusteringEvaluator, ColumnPruner, CountVectorizer, CountVectorizerModel, CrossValidator, CrossValidatorModel, DCT, DecisionTreeClassificationModel, DecisionTreeClassifier, DecisionTreeRegressionModel, DecisionTreeRegressor, DistributedLDAModel, ElementwiseProduct, Estimator, Evaluator, FeatureHasher, FMClassificationModel, FMClassifier, FMRegressionModel, FMRegressor, FPGrowth, FPGrowthModel, GaussianMixture, GaussianMixtureModel, GBTClassificationModel, GBTClassifier, GBTRegressionModel, GBTRegressor, GeneralizedLinearRegression, GeneralizedLinearRegressionModel, HashingTF, IDF, IDFModel, Imputer, ImputerModel, IndexToString, Interaction, IsotonicRegression, IsotonicRegressionModel, JavaParams, KMeans, KMeansModel, LDA, LDAModel, LinearRegression, LinearRegressionModel, LinearSVC, LinearSVCModel, LocalLDAModel, LogisticRegression, LogisticRegressionModel, MaxAbsScaler, MaxAbsScalerModel, MinHashLSH, MinHashLSHModel, MinMaxScaler, MinMaxScalerModel, Model, MulticlassClassificationEvaluator, MultilabelClassificationEvaluator, MultilayerPerceptronClassificationModel, MultilayerPerceptronClassifier, NaiveBayes, NaiveBayesModel, NGram, Normalizer, OneHotEncoder, OneHotEncoderModel, OneVsRest, OneVsRestModel, PCA, PCAModel, Pipeline, PipelineModel, PipelineStage, PolynomialExpansion, PowerIterationClustering, PredictionModel, Predictor, PrefixSpan, ProbabilisticClassificationModel, ProbabilisticClassifier, QuantileDiscretizer, RandomForestClassificationModel, RandomForestClassifier, RandomForestRegressionModel, RandomForestRegressor, RankingEvaluator, RegexTokenizer, RegressionEvaluator, RegressionModel, Regressor, RFormula, RFormulaModel, RobustScaler, RobustScalerModel, SQLTransformer, StandardScaler, StandardScalerModel, StopWordsRemover, StringIndexer, StringIndexerModel, Tokenizer, TrainValidationSplit, TrainValidationSplitModel, Transformer, UnaryTransformer, UnivariateFeatureSelector, UnivariateFeatureSelectorModel, VarianceThresholdSelector, VarianceThresholdSelectorModel, VectorAssembler, VectorAttributeRewriter, VectorIndexer, VectorIndexerModel, VectorSizeHint, VectorSlicer, Word2Vec, Word2VecModel

public interface Params extends Identifiable, Serializable
Trait for components that take parameters. This also provides an internal param map to store parameter values attached to the instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    clear(Param<?> param)
    Clears the user-supplied value for the input param.
    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
    Default implementation of copy with extra params.
    Internal param map for default values.
    explainParam(Param<?> param)
    Explains a param.
    Explains all params of this instance.
    extractParamMap with no extra values.
    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 less than user-supplied values less than 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.
    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.
    void
    onParamChange(Param<?> param)
     
    Internal param map for user-supplied values.
    Param<?>[]
    Returns all params sorted by their names.
    set(String param, Object value)
    Sets a parameter (by name) in the embedded param map.
    <T> Params
    set(Param<T> param, T value)
    Sets a parameter in the embedded param map.
    set(ParamPair<?> paramPair)
    Sets a parameter in the embedded param map.
    <T> Params
    setDefault(Param<T> param, T value)
    Sets a default value for a param.
    setDefault(scala.collection.immutable.Seq<ParamPair<?>> paramPairs)
    Sets default values for a list of params.
    void
    shouldOwn(Param<?> param)
    Validates that the input param belongs to this instance.

    Methods inherited from interface org.apache.spark.ml.util.Identifiable

    toString, uid
  • Method Details

    • clear

      Params clear(Param<?> param)
      Clears the user-supplied value for the input param.
      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. See defaultCopy().
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • copyValues

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

      This handles default Params and explicitly set Params separately. Default Params are copied from and to defaultParamMap, and explicitly set Params are copied from and to paramMap. Warning: This implicitly assumes that this Params instance and the target instance share the same set of default Params.

      Parameters:
      to - the target instance, which should work with the same set of default Params as this source instance
      extra - extra params to be copied to the target's paramMap
      Returns:
      the target instance with param values copied
    • 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)
    • defaultParamMap

      ParamMap defaultParamMap()
      Internal param map for default values.
    • 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. See explainParam().
      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 less than user-supplied values less than extra.
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • extractParamMap

      ParamMap extractParamMap()
      extractParamMap with no extra values.
      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)
    • getDefault

      <T> scala.Option<T> getDefault(Param<T> param)
      Gets the default value of a parameter.
      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)
    • getParam

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

      <T> boolean hasDefault(Param<T> param)
      Tests whether the input param has a default value set.
      Parameters:
      param - (undocumented)
      Returns:
      (undocumented)
    • hasParam

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

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

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

      void onParamChange(Param<?> param)
    • paramMap

      ParamMap paramMap()
      Internal param map for user-supplied values.
    • 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.

      Returns:
      (undocumented)
      Note:
      Developer should not use this method in constructor because we cannot guarantee that this variable gets initialized before other params.
    • 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)
    • 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.immutable.Seq<ParamPair<?>> paramPairs)
      Sets default values for a list of params.

      Note: Java developers should use the single-parameter setDefault. Annotating this with varargs can cause compilation failures due to a Scala compiler bug. See SPARK-9268.

      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)
    • shouldOwn

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