public class RandomForestRegressionModel extends PredictionModel<Vector,RandomForestRegressionModel> implements MLWritable, scala.Serializable
Random Forest
model for regression.
It supports both continuous and categorical features.
param: _trees Decision trees in the ensemble. param: numFeatures Number of features used by this model
Modifier and Type | Method and Description |
---|---|
protected static <T> T |
$(Param<T> param) |
static BooleanParam |
cacheNodeIds() |
static IntParam |
checkpointInterval() |
static Params |
clear(Param<?> param) |
RandomForestRegressionModel |
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() |
static ParamMap |
extractParamMap() |
static ParamMap |
extractParamMap(ParamMap extra) |
Vector |
featureImportances()
Estimate of the importance of each feature.
|
static Param<java.lang.String> |
featuresCol() |
Param<java.lang.String> |
featuresCol()
Param for features column name.
|
protected static DataType |
featuresDataType() |
static Param<java.lang.String> |
featureSubsetStrategy() |
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() |
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 long |
getSeed() |
static double |
getSubsamplingRate() |
static <T> boolean |
hasDefault(Param<T> param) |
static boolean |
hasParam(java.lang.String paramName) |
static boolean |
hasParent() |
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 RandomForestRegressionModel |
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() |
int |
numFeatures()
Returns the number of features the model was trained on.
|
int |
numTrees()
Deprecated.
Use
getNumTrees instead. This method will be removed in 2.1.0 |
static Param<?>[] |
params() |
static void |
parent_$eq(Estimator<M> x$1) |
static Estimator<M> |
parent() |
protected double |
predict(Vector features)
Predict label for the given features.
|
static Param<java.lang.String> |
predictionCol() |
Param<java.lang.String> |
predictionCol()
Param for prediction column name.
|
static MLReader<RandomForestRegressionModel> |
read() |
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) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setCacheNodeIds(boolean value) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setCheckpointInterval(int value) |
protected static <T> Params |
setDefault(Param<T> param,
T value) |
protected static Params |
setDefault(scala.collection.Seq<ParamPair<?>> paramPairs) |
static M |
setFeaturesCol(java.lang.String value) |
static org.apache.spark.ml.tree.HasFeatureSubsetStrategy |
setFeatureSubsetStrategy(java.lang.String value) |
static org.apache.spark.ml.tree.TreeRegressorParams |
setImpurity(java.lang.String value) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setMaxBins(int value) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setMaxDepth(int value) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setMaxMemoryInMB(int value) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setMinInfoGain(double value) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setMinInstancesPerNode(int value) |
static M |
setParent(Estimator<M> parent) |
static M |
setPredictionCol(java.lang.String value) |
static org.apache.spark.ml.tree.DecisionTreeParams |
setSeed(long value) |
static org.apache.spark.ml.tree.TreeEnsembleParams |
setSubsamplingRate(double value) |
static DoubleParam |
subsamplingRate() |
static java.lang.String |
toDebugString() |
java.lang.String |
toString() |
static int |
totalNumNodes() |
static Dataset<Row> |
transform(Dataset<?> dataset) |
static Dataset<Row> |
transform(Dataset<?> dataset,
ParamMap paramMap) |
static Dataset<Row> |
transform(Dataset<?> dataset,
ParamPair<?> firstParamPair,
ParamPair<?>... otherParamPairs) |
static Dataset<Row> |
transform(Dataset<?> dataset,
ParamPair<?> firstParamPair,
scala.collection.Seq<ParamPair<?>> otherParamPairs) |
protected Dataset<Row> |
transformImpl(Dataset<?> dataset) |
static StructType |
transformSchema(StructType schema) |
protected static StructType |
transformSchema(StructType schema,
boolean logging) |
DecisionTreeRegressionModel[] |
trees() |
double[] |
treeWeights() |
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)
Validates and transforms the input schema with the provided param map.
|
static void |
validateParams() |
MLWriter |
write()
Returns an
MLWriter instance for this ML instance. |
featuresDataType, setFeaturesCol, setPredictionCol, transform, transformSchema
transform, transform, transform
transformSchema
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
save
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
public static MLReader<RandomForestRegressionModel> read()
public static RandomForestRegressionModel load(java.lang.String path)
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 Dataset<Row> transform(Dataset<?> dataset, ParamPair<?> firstParamPair, scala.collection.Seq<ParamPair<?>> otherParamPairs)
public static Dataset<Row> transform(Dataset<?> dataset, ParamPair<?> firstParamPair, ParamPair<?>... otherParamPairs)
public static Estimator<M> parent()
public static void parent_$eq(Estimator<M> x$1)
public static M setParent(Estimator<M> parent)
public static boolean hasParent()
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()
protected static StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
public static M setFeaturesCol(java.lang.String value)
public static M setPredictionCol(java.lang.String value)
protected static DataType featuresDataType()
public static StructType transformSchema(StructType schema)
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 org.apache.spark.ml.tree.DecisionTreeParams setMaxDepth(int value)
public static final int getMaxDepth()
public static org.apache.spark.ml.tree.DecisionTreeParams setMaxBins(int value)
public static final int getMaxBins()
public static org.apache.spark.ml.tree.DecisionTreeParams setMinInstancesPerNode(int value)
public static final int getMinInstancesPerNode()
public static org.apache.spark.ml.tree.DecisionTreeParams setMinInfoGain(double value)
public static final double getMinInfoGain()
public static org.apache.spark.ml.tree.DecisionTreeParams setSeed(long value)
public static org.apache.spark.ml.tree.DecisionTreeParams setMaxMemoryInMB(int value)
public static final int getMaxMemoryInMB()
public static org.apache.spark.ml.tree.DecisionTreeParams setCacheNodeIds(boolean value)
public static final boolean getCacheNodeIds()
public static org.apache.spark.ml.tree.DecisionTreeParams setCheckpointInterval(int value)
public static final DoubleParam subsamplingRate()
public static org.apache.spark.ml.tree.TreeEnsembleParams setSubsamplingRate(double value)
public static final double getSubsamplingRate()
public static final Param<java.lang.String> featureSubsetStrategy()
public static org.apache.spark.ml.tree.HasFeatureSubsetStrategy setFeatureSubsetStrategy(java.lang.String value)
public static final java.lang.String getFeatureSubsetStrategy()
public static final Param<java.lang.String> impurity()
public static org.apache.spark.ml.tree.TreeRegressorParams setImpurity(java.lang.String value)
public static final java.lang.String getImpurity()
public static int getNumTrees()
public static java.lang.String toDebugString()
public static int totalNumNodes()
public static void save(java.lang.String path) throws java.io.IOException
java.io.IOException
public java.lang.String uid()
Identifiable
uid
in interface Identifiable
public int numFeatures()
PredictionModel
numFeatures
in class PredictionModel<Vector,RandomForestRegressionModel>
public DecisionTreeRegressionModel[] trees()
public double[] treeWeights()
protected Dataset<Row> transformImpl(Dataset<?> dataset)
transformImpl
in class PredictionModel<Vector,RandomForestRegressionModel>
protected double predict(Vector features)
PredictionModel
transform()
and output predictionCol
.predict
in class PredictionModel<Vector,RandomForestRegressionModel>
features
- (undocumented)public int numTrees()
getNumTrees
instead. This method will be removed in 2.1.0public RandomForestRegressionModel copy(ParamMap extra)
Params
copy
in interface Params
copy
in class Model<RandomForestRegressionModel>
extra
- (undocumented)defaultCopy()
public java.lang.String toString()
toString
in interface Identifiable
toString
in class java.lang.Object
public Vector featureImportances()
Each feature's importance is the average of its importance across all trees in the ensemble The importance vector is normalized to sum to 1. This method is suggested by Hastie et al. (Hastie, Tibshirani, Friedman. "The Elements of Statistical Learning, 2nd Edition." 2001.) and follows the implementation from scikit-learn.
DecisionTreeRegressionModel.featureImportances
public MLWriter write()
MLWritable
MLWriter
instance for this ML instance.write
in interface MLWritable
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()