public class RFormulaModel extends Model<RFormulaModel> implements RFormulaBase, MLWritable
RFormula
. Fitting is required to determine the factor levels of
formula terms.
param: resolvedFormula the fitted R formula. param: pipelineModel the fitted feature model, including factor to index mappings.
Modifier and Type | Method and Description |
---|---|
RFormulaModel |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
Param<String> |
featuresCol()
Param for features column name.
|
BooleanParam |
forceIndexLabel()
Force to index label whether it is numeric or string type.
|
Param<String> |
formula()
R formula parameter.
|
Param<String> |
handleInvalid()
Param for how to handle invalid data (unseen or NULL values) in features and label column
of string type.
|
Param<String> |
labelCol()
Param for label column name.
|
static RFormulaModel |
load(String path) |
static MLReader<RFormulaModel> |
read() |
Param<String> |
stringIndexerOrderType()
Param for how to order categories of a string FEATURE column used by
StringIndexer . |
String |
toString() |
Dataset<Row> |
transform(Dataset<?> dataset)
Transforms the input dataset.
|
StructType |
transformSchema(StructType schema)
Check transform validity and derive the output schema from the input schema.
|
String |
uid()
An immutable unique ID for the object and its derivatives.
|
MLWriter |
write()
Returns an
MLWriter instance for this ML instance. |
transform, transform, transform
params
getForceIndexLabel, getFormula, getStringIndexerOrderType, hasLabelCol
getFeaturesCol
getLabelCol
getHandleInvalid
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
save
$init$, initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, initLock, isTraceEnabled, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning, org$apache$spark$internal$Logging$$log__$eq, org$apache$spark$internal$Logging$$log_, uninitialize
public static MLReader<RFormulaModel> read()
public static RFormulaModel load(String path)
public Param<String> formula()
RFormulaBase
formula
in interface RFormulaBase
public BooleanParam forceIndexLabel()
RFormulaBase
forceIndexLabel
in interface RFormulaBase
public Param<String> handleInvalid()
RFormulaBase
handleInvalid
in interface RFormulaBase
handleInvalid
in interface HasHandleInvalid
public final Param<String> stringIndexerOrderType()
RFormulaBase
StringIndexer
.
The last category after ordering is dropped when encoding strings.
Supported options: 'frequencyDesc', 'frequencyAsc', 'alphabetDesc', 'alphabetAsc'.
The default value is 'frequencyDesc'. When the ordering is set to 'alphabetDesc', RFormula
drops the same category as R when encoding strings.
The options are explained using an example 'b', 'a', 'b', 'a', 'c', 'b'
:
+-----------------+---------------------------------------+----------------------------------+
| Option | Category mapped to 0 by StringIndexer | Category dropped by RFormula |
+-----------------+---------------------------------------+----------------------------------+
| 'frequencyDesc' | most frequent category ('b') | least frequent category ('c') |
| 'frequencyAsc' | least frequent category ('c') | most frequent category ('b') |
| 'alphabetDesc' | last alphabetical category ('c') | first alphabetical category ('a')|
| 'alphabetAsc' | first alphabetical category ('a') | last alphabetical category ('c') |
+-----------------+---------------------------------------+----------------------------------+
Note that this ordering option is NOT used for the label column. When the label column is
indexed, it uses the default descending frequency ordering in StringIndexer
.
stringIndexerOrderType
in interface RFormulaBase
public final Param<String> labelCol()
HasLabelCol
labelCol
in interface HasLabelCol
public final Param<String> featuresCol()
HasFeaturesCol
featuresCol
in interface HasFeaturesCol
public String uid()
Identifiable
uid
in interface Identifiable
public Dataset<Row> transform(Dataset<?> dataset)
Transformer
transform
in class Transformer
dataset
- (undocumented)public StructType transformSchema(StructType schema)
PipelineStage
We check validity for interactions between parameters during transformSchema
and
raise an exception if any parameter value is invalid. Parameter value checks which
do not depend on other parameters are handled by Param.validate()
.
Typical implementation should first conduct verification on schema change and parameter validity, including complex parameter interaction checks.
transformSchema
in class PipelineStage
schema
- (undocumented)public RFormulaModel copy(ParamMap extra)
Params
defaultCopy()
.copy
in interface Params
copy
in class Model<RFormulaModel>
extra
- (undocumented)public String toString()
toString
in interface Identifiable
toString
in class Object
public MLWriter write()
MLWritable
MLWriter
instance for this ML instance.write
in interface MLWritable