public class RandomForestClassifier extends ProbabilisticClassifier<Vector,RandomForestClassifier,RandomForestClassificationModel>
Random Forest
learning algorithm for
classification.
It supports both binary and multiclass labels, as well as both continuous and categorical
features.Constructor and Description |
---|
RandomForestClassifier() |
RandomForestClassifier(java.lang.String uid) |
Modifier and Type | Method and Description |
---|---|
protected static <T> T |
$(Param<T> param) |
static BooleanParam |
cacheNodeIds() |
static IntParam |
checkpointInterval() |
static Params |
clear(Param<?> param) |
RandomForestClassifier |
copy(ParamMap extra)
Creates a copy of this instance with the same UID and some extra params.
|
protected static <T extends Params> |
copyValues(T to,
ParamMap extra) |
protected static <T extends Params> |
copyValues$default$2() |
protected static <T extends Params> |
defaultCopy(ParamMap extra) |
static java.lang.String |
explainParam(Param<?> param) |
static java.lang.String |
explainParams() |
protected static RDD<LabeledPoint> |
extractLabeledPoints(Dataset<?> dataset) |
protected static RDD<LabeledPoint> |
extractLabeledPoints(Dataset<?> dataset,
int numClasses) |
static ParamMap |
extractParamMap() |
static ParamMap |
extractParamMap(ParamMap extra) |
static Param<java.lang.String> |
featuresCol() |
Param<java.lang.String> |
featuresCol()
Param for features column name.
|
static Param<java.lang.String> |
featureSubsetStrategy() |
static M |
fit(Dataset<?> dataset) |
static M |
fit(Dataset<?> dataset,
ParamMap paramMap) |
static scala.collection.Seq<M> |
fit(Dataset<?> dataset,
ParamMap[] paramMaps) |
static M |
fit(Dataset<?> dataset,
ParamPair<?> firstParamPair,
ParamPair<?>... otherParamPairs) |
static M |
fit(Dataset<?> dataset,
ParamPair<?> firstParamPair,
scala.collection.Seq<ParamPair<?>> otherParamPairs) |
static <T> scala.Option<T> |
get(Param<T> param) |
static boolean |
getCacheNodeIds() |
static int |
getCheckpointInterval() |
static <T> scala.Option<T> |
getDefault(Param<T> param) |
static java.lang.String |
getFeaturesCol() |
java.lang.String |
getFeaturesCol() |
static java.lang.String |
getFeatureSubsetStrategy() |
static java.lang.String |
getImpurity() |
static java.lang.String |
getLabelCol() |
java.lang.String |
getLabelCol() |
static int |
getMaxBins() |
static int |
getMaxDepth() |
static int |
getMaxMemoryInMB() |
static double |
getMinInfoGain() |
static int |
getMinInstancesPerNode() |
protected static int |
getNumClasses(Dataset<?> dataset,
int maxNumClasses) |
protected static int |
getNumClasses$default$2() |
static int |
getNumTrees() |
static <T> T |
getOrDefault(Param<T> param) |
static Param<java.lang.Object> |
getParam(java.lang.String paramName) |
static java.lang.String |
getPredictionCol() |
java.lang.String |
getPredictionCol() |
static java.lang.String |
getProbabilityCol() |
static java.lang.String |
getRawPredictionCol() |
java.lang.String |
getRawPredictionCol() |
static long |
getSeed() |
static double |
getSubsamplingRate() |
static double[] |
getThresholds() |
static <T> boolean |
hasDefault(Param<T> param) |
static boolean |
hasParam(java.lang.String paramName) |
static Param<java.lang.String> |
impurity() |
protected static void |
initializeLogIfNecessary(boolean isInterpreter) |
static boolean |
isDefined(Param<?> param) |
static boolean |
isSet(Param<?> param) |
protected static boolean |
isTraceEnabled() |
static Param<java.lang.String> |
labelCol() |
Param<java.lang.String> |
labelCol()
Param for label column name.
|
static RandomForestClassifier |
load(java.lang.String path) |
protected static org.slf4j.Logger |
log() |
protected static void |
logDebug(scala.Function0<java.lang.String> msg) |
protected static void |
logDebug(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static void |
logError(scala.Function0<java.lang.String> msg) |
protected static void |
logError(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static void |
logInfo(scala.Function0<java.lang.String> msg) |
protected static void |
logInfo(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static java.lang.String |
logName() |
protected static void |
logTrace(scala.Function0<java.lang.String> msg) |
protected static void |
logTrace(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
protected static void |
logWarning(scala.Function0<java.lang.String> msg) |
protected static void |
logWarning(scala.Function0<java.lang.String> msg,
java.lang.Throwable throwable) |
static IntParam |
maxBins() |
static IntParam |
maxDepth() |
static IntParam |
maxMemoryInMB() |
static DoubleParam |
minInfoGain() |
static IntParam |
minInstancesPerNode() |
static IntParam |
numTrees() |
static Param<?>[] |
params() |
static Param<java.lang.String> |
predictionCol() |
Param<java.lang.String> |
predictionCol()
Param for prediction column name.
|
static Param<java.lang.String> |
probabilityCol() |
static Param<java.lang.String> |
rawPredictionCol() |
Param<java.lang.String> |
rawPredictionCol()
Param for raw prediction (a.k.a.
|
static void |
save(java.lang.String path) |
static LongParam |
seed() |
static <T> Params |
set(Param<T> param,
T value) |
protected static Params |
set(ParamPair<?> paramPair) |
protected static Params |
set(java.lang.String param,
java.lang.Object value) |
RandomForestClassifier |
setCacheNodeIds(boolean value) |
RandomForestClassifier |
setCheckpointInterval(int value) |
protected static <T> Params |
setDefault(Param<T> param,
T value) |
protected static Params |
setDefault(scala.collection.Seq<ParamPair<?>> paramPairs) |
static Learner |
setFeaturesCol(java.lang.String value) |
RandomForestClassifier |
setFeatureSubsetStrategy(java.lang.String value) |
RandomForestClassifier |
setImpurity(java.lang.String value) |
static Learner |
setLabelCol(java.lang.String value) |
RandomForestClassifier |
setMaxBins(int value) |
RandomForestClassifier |
setMaxDepth(int value) |
RandomForestClassifier |
setMaxMemoryInMB(int value) |
RandomForestClassifier |
setMinInfoGain(double value) |
RandomForestClassifier |
setMinInstancesPerNode(int value) |
RandomForestClassifier |
setNumTrees(int value) |
static Learner |
setPredictionCol(java.lang.String value) |
static E |
setProbabilityCol(java.lang.String value) |
static E |
setRawPredictionCol(java.lang.String value) |
RandomForestClassifier |
setSeed(long value) |
RandomForestClassifier |
setSubsamplingRate(double value) |
static E |
setThresholds(double[] value) |
static DoubleParam |
subsamplingRate() |
static java.lang.String[] |
supportedFeatureSubsetStrategies()
Accessor for supported featureSubsetStrategy settings: auto, all, onethird, sqrt, log2
|
static java.lang.String[] |
supportedImpurities()
Accessor for supported impurity settings: entropy, gini
|
static DoubleArrayParam |
thresholds() |
static java.lang.String |
toString() |
protected RandomForestClassificationModel |
train(Dataset<?> dataset)
Train a model using the given dataset and parameters.
|
static StructType |
transformSchema(StructType schema) |
protected static StructType |
transformSchema(StructType schema,
boolean logging) |
java.lang.String |
uid()
An immutable unique ID for the object and its derivatives.
|
protected static StructType |
validateAndTransformSchema(StructType schema,
boolean fitting,
DataType featuresDataType) |
StructType |
validateAndTransformSchema(StructType schema,
boolean fitting,
DataType featuresDataType) |
StructType |
validateAndTransformSchema(StructType schema,
boolean fitting,
DataType featuresDataType)
Validates and transforms the input schema with the provided param map.
|
static void |
validateParams() |
static MLWriter |
write() |
setProbabilityCol, setThresholds
extractLabeledPoints, getNumClasses, setRawPredictionCol
extractLabeledPoints, fit, setFeaturesCol, setLabelCol, setPredictionCol, transformSchema
transformSchema
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn, validateParams
toString
public RandomForestClassifier(java.lang.String uid)
public RandomForestClassifier()
public static final java.lang.String[] supportedImpurities()
public static final java.lang.String[] supportedFeatureSubsetStrategies()
public static RandomForestClassifier load(java.lang.String path)
public static java.lang.String toString()
public static Param<?>[] params()
public static void validateParams()
public static java.lang.String explainParam(Param<?> param)
public static java.lang.String explainParams()
public static final boolean isSet(Param<?> param)
public static final boolean isDefined(Param<?> param)
public static boolean hasParam(java.lang.String paramName)
public static Param<java.lang.Object> getParam(java.lang.String paramName)
protected static final Params set(java.lang.String param, java.lang.Object value)
public static final <T> scala.Option<T> get(Param<T> param)
public static final <T> T getOrDefault(Param<T> param)
protected static final <T> T $(Param<T> param)
public static final <T> scala.Option<T> getDefault(Param<T> param)
public static final <T> boolean hasDefault(Param<T> param)
public static final ParamMap extractParamMap()
protected static java.lang.String logName()
protected static org.slf4j.Logger log()
protected static void logInfo(scala.Function0<java.lang.String> msg)
protected static void logDebug(scala.Function0<java.lang.String> msg)
protected static void logTrace(scala.Function0<java.lang.String> msg)
protected static void logWarning(scala.Function0<java.lang.String> msg)
protected static void logError(scala.Function0<java.lang.String> msg)
protected static void logInfo(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logDebug(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logTrace(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logWarning(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static void logError(scala.Function0<java.lang.String> msg, java.lang.Throwable throwable)
protected static boolean isTraceEnabled()
protected static void initializeLogIfNecessary(boolean isInterpreter)
protected static StructType transformSchema(StructType schema, boolean logging)
public static M fit(Dataset<?> dataset, ParamPair<?> firstParamPair, scala.collection.Seq<ParamPair<?>> otherParamPairs)
public static M fit(Dataset<?> dataset, ParamPair<?> firstParamPair, ParamPair<?>... otherParamPairs)
public static final Param<java.lang.String> labelCol()
public static final java.lang.String getLabelCol()
public static final Param<java.lang.String> featuresCol()
public static final java.lang.String getFeaturesCol()
public static final Param<java.lang.String> predictionCol()
public static final java.lang.String getPredictionCol()
public static Learner setLabelCol(java.lang.String value)
public static Learner setFeaturesCol(java.lang.String value)
public static Learner setPredictionCol(java.lang.String value)
public static M fit(Dataset<?> dataset)
public static StructType transformSchema(StructType schema)
protected static RDD<LabeledPoint> extractLabeledPoints(Dataset<?> dataset)
public static final Param<java.lang.String> rawPredictionCol()
public static final java.lang.String getRawPredictionCol()
public static E setRawPredictionCol(java.lang.String value)
protected static RDD<LabeledPoint> extractLabeledPoints(Dataset<?> dataset, int numClasses)
protected static int getNumClasses(Dataset<?> dataset, int maxNumClasses)
protected static int getNumClasses$default$2()
public static final Param<java.lang.String> probabilityCol()
public static final java.lang.String getProbabilityCol()
public static final DoubleArrayParam thresholds()
public static double[] getThresholds()
protected static StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
public static E setProbabilityCol(java.lang.String value)
public static E setThresholds(double[] value)
public static final IntParam checkpointInterval()
public static final int getCheckpointInterval()
public static final LongParam seed()
public static final long getSeed()
public static final IntParam maxDepth()
public static final IntParam maxBins()
public static final IntParam minInstancesPerNode()
public static final DoubleParam minInfoGain()
public static final IntParam maxMemoryInMB()
public static final BooleanParam cacheNodeIds()
public static final int getMaxDepth()
public static final int getMaxBins()
public static final int getMinInstancesPerNode()
public static final double getMinInfoGain()
public static final int getMaxMemoryInMB()
public static final boolean getCacheNodeIds()
public static final DoubleParam subsamplingRate()
public static final double getSubsamplingRate()
public static final Param<java.lang.String> featureSubsetStrategy()
public static final java.lang.String getFeatureSubsetStrategy()
public static final IntParam numTrees()
public static final int getNumTrees()
public static final Param<java.lang.String> impurity()
public static final java.lang.String getImpurity()
public static void save(java.lang.String path) throws java.io.IOException
java.io.IOException
public static MLWriter write()
public java.lang.String uid()
Identifiable
public RandomForestClassifier setMaxDepth(int value)
public RandomForestClassifier setMaxBins(int value)
public RandomForestClassifier setMinInstancesPerNode(int value)
public RandomForestClassifier setMinInfoGain(double value)
public RandomForestClassifier setMaxMemoryInMB(int value)
public RandomForestClassifier setCacheNodeIds(boolean value)
public RandomForestClassifier setCheckpointInterval(int value)
public RandomForestClassifier setImpurity(java.lang.String value)
public RandomForestClassifier setSubsamplingRate(double value)
public RandomForestClassifier setSeed(long value)
public RandomForestClassifier setNumTrees(int value)
public RandomForestClassifier setFeatureSubsetStrategy(java.lang.String value)
protected RandomForestClassificationModel train(Dataset<?> dataset)
Predictor
fit()
to avoid dealing with schema validation
and copying parameters into the model.
train
in class Predictor<Vector,RandomForestClassifier,RandomForestClassificationModel>
dataset
- Training datasetpublic RandomForestClassifier copy(ParamMap extra)
Params
copy
in interface Params
copy
in class Predictor<Vector,RandomForestClassifier,RandomForestClassificationModel>
extra
- (undocumented)defaultCopy()
public StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
public Param<java.lang.String> rawPredictionCol()
public java.lang.String getRawPredictionCol()
public StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
schema
- input schemafitting
- whether this is in fittingfeaturesDataType
- SQL DataType for FeaturesType.
E.g., VectorUDT
for vector features.public Param<java.lang.String> labelCol()
public java.lang.String getLabelCol()
public Param<java.lang.String> featuresCol()
public java.lang.String getFeaturesCol()
public Param<java.lang.String> predictionCol()
public java.lang.String getPredictionCol()