Class GBTClassificationModel
Object
org.apache.spark.ml.PipelineStage
org.apache.spark.ml.Transformer
org.apache.spark.ml.Model<M>
org.apache.spark.ml.PredictionModel<FeaturesType,M>
org.apache.spark.ml.classification.ClassificationModel<FeaturesType,M>
org.apache.spark.ml.classification.ProbabilisticClassificationModel<Vector,GBTClassificationModel>
org.apache.spark.ml.classification.GBTClassificationModel
- All Implemented Interfaces:
Serializable,org.apache.spark.internal.Logging,org.apache.spark.ml.classification.ClassifierParams,org.apache.spark.ml.classification.ProbabilisticClassifierParams,Params,HasCheckpointInterval,HasFeaturesCol,HasLabelCol,HasMaxIter,HasPredictionCol,HasProbabilityCol,HasRawPredictionCol,HasSeed,HasStepSize,HasThresholds,HasValidationIndicatorCol,HasWeightCol,org.apache.spark.ml.PredictorParams,org.apache.spark.ml.tree.DecisionTreeParams,org.apache.spark.ml.tree.GBTClassifierParams,org.apache.spark.ml.tree.GBTParams,org.apache.spark.ml.tree.HasVarianceImpurity,org.apache.spark.ml.tree.TreeEnsembleClassifierParams,org.apache.spark.ml.tree.TreeEnsembleModel<DecisionTreeRegressionModel>,org.apache.spark.ml.tree.TreeEnsembleParams,Identifiable,MLWritable
public class GBTClassificationModel
extends ProbabilisticClassificationModel<Vector,GBTClassificationModel>
implements org.apache.spark.ml.tree.GBTClassifierParams, org.apache.spark.ml.tree.TreeEnsembleModel<DecisionTreeRegressionModel>, MLWritable, Serializable
Gradient-Boosted Trees (GBTs) (http://en.wikipedia.org/wiki/Gradient_boosting)
model for classification.
It supports binary labels, as well as both continuous and categorical features.
param: _trees Decision trees in the ensemble. param: _treeWeights Weights for the decision trees in the ensemble.
- See Also:
- Note:
- Multiclass labels are not currently supported.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.spark.internal.Logging
org.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter -
Constructor Summary
ConstructorsConstructorDescriptionGBTClassificationModel(String uid, DecisionTreeRegressionModel[] _trees, double[] _treeWeights) Construct a GBTClassificationModel -
Method Summary
Modifier and TypeMethodDescriptionfinal BooleanParamfinal IntParamParam for set checkpoint interval (>= 1) or disable checkpoint (-1).Creates a copy of this instance with the same UID and some extra params.double[]evaluateEachIteration(Dataset<?> dataset) Method to compute error or loss for every iteration of gradient boosting.intNumber of trees in ensembleimpurity()leafCol()static GBTClassificationModellossType()final IntParammaxBins()final IntParammaxDepth()final IntParammaxIter()Param for maximum number of iterations (>= 0).final IntParamfinal DoubleParamfinal IntParamfinal DoubleParamintNumber of classes (values which the label can take).intReturns the number of features the model was trained on.doublePredict label for the given features.predictRaw(Vector features) Raw prediction for each possible label.static MLReader<GBTClassificationModel>read()final LongParamseed()Param for random seed.final DoubleParamstepSize()Param for Step size to be used for each iteration of optimization (> 0).final DoubleParamtoString()intTransforms dataset by reading fromPredictionModel.featuresCol(), and appending new columns as specified by parameters: - predicted labels asPredictionModel.predictionCol()of typeDouble- raw predictions (confidences) asClassificationModel.rawPredictionCol()of typeVector- probability of each class asProbabilisticClassificationModel.probabilityCol()of typeVector.transformSchema(StructType schema) Check transform validity and derive the output schema from the input schema.trees()double[]uid()An immutable unique ID for the object and its derivatives.Param for name of the column that indicates whether each row is for training or for validation.final DoubleParamParam for weight column name.write()Returns anMLWriterinstance for this ML instance.Methods inherited from class org.apache.spark.ml.classification.ProbabilisticClassificationModel
normalizeToProbabilitiesInPlace, predictProbability, probabilityCol, setProbabilityCol, setThresholds, thresholdsMethods inherited from class org.apache.spark.ml.classification.ClassificationModel
rawPredictionCol, setRawPredictionCol, transformImplMethods inherited from class org.apache.spark.ml.PredictionModel
featuresCol, labelCol, predictionCol, setFeaturesCol, setPredictionColMethods inherited from class org.apache.spark.ml.Transformer
transform, transform, transformMethods inherited from class org.apache.spark.ml.PipelineStage
paramsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.spark.ml.tree.DecisionTreeParams
getCacheNodeIds, getLeafCol, getMaxBins, getMaxDepth, getMaxMemoryInMB, getMinInfoGain, getMinInstancesPerNode, getMinWeightFractionPerNode, getOldStrategy, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$cacheNodeIds_$eq, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$leafCol_$eq, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$maxBins_$eq, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$maxDepth_$eq, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$maxMemoryInMB_$eq, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$minInfoGain_$eq, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$minInstancesPerNode_$eq, org$apache$spark$ml$tree$DecisionTreeParams$_setter_$minWeightFractionPerNode_$eq, setLeafColMethods inherited from interface org.apache.spark.ml.tree.GBTClassifierParams
getLossType, getOldLossType, org$apache$spark$ml$tree$GBTClassifierParams$_setter_$lossType_$eqMethods inherited from interface org.apache.spark.ml.tree.GBTParams
getOldBoostingStrategy, getValidationTol, org$apache$spark$ml$tree$GBTParams$_setter_$stepSize_$eq, org$apache$spark$ml$tree$GBTParams$_setter_$validationTol_$eqMethods inherited from interface org.apache.spark.ml.param.shared.HasCheckpointInterval
getCheckpointIntervalMethods inherited from interface org.apache.spark.ml.param.shared.HasFeaturesCol
featuresCol, getFeaturesColMethods inherited from interface org.apache.spark.ml.param.shared.HasLabelCol
getLabelCol, labelColMethods inherited from interface org.apache.spark.ml.param.shared.HasMaxIter
getMaxIterMethods inherited from interface org.apache.spark.ml.param.shared.HasPredictionCol
getPredictionCol, predictionColMethods inherited from interface org.apache.spark.ml.param.shared.HasProbabilityCol
getProbabilityCol, probabilityColMethods inherited from interface org.apache.spark.ml.param.shared.HasRawPredictionCol
getRawPredictionCol, rawPredictionColMethods inherited from interface org.apache.spark.ml.param.shared.HasStepSize
getStepSizeMethods inherited from interface org.apache.spark.ml.param.shared.HasThresholds
getThresholds, thresholdsMethods inherited from interface org.apache.spark.ml.param.shared.HasValidationIndicatorCol
getValidationIndicatorColMethods inherited from interface org.apache.spark.ml.tree.HasVarianceImpurity
getImpurity, getOldImpurity, org$apache$spark$ml$tree$HasVarianceImpurity$_setter_$impurity_$eqMethods inherited from interface org.apache.spark.ml.param.shared.HasWeightCol
getWeightColMethods inherited from interface org.apache.spark.internal.Logging
initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logBasedOnLevel, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, MDC, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContextMethods inherited from interface org.apache.spark.ml.util.MLWritable
saveMethods inherited from interface org.apache.spark.ml.param.Params
clear, copyValues, defaultCopy, defaultParamMap, estimateMatadataSize, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwnMethods inherited from interface org.apache.spark.ml.tree.TreeEnsembleClassifierParams
validateAndTransformSchemaMethods inherited from interface org.apache.spark.ml.tree.TreeEnsembleModel
getEstimatedSize, getLeafField, getTree, javaTreeWeights, predictLeaf, toDebugStringMethods inherited from interface org.apache.spark.ml.tree.TreeEnsembleParams
getFeatureSubsetStrategy, getOldStrategy, getSubsamplingRate, org$apache$spark$ml$tree$TreeEnsembleParams$_setter_$featureSubsetStrategy_$eq, org$apache$spark$ml$tree$TreeEnsembleParams$_setter_$subsamplingRate_$eq
-
Constructor Details
-
GBTClassificationModel
public GBTClassificationModel(String uid, DecisionTreeRegressionModel[] _trees, double[] _treeWeights) Construct a GBTClassificationModel- Parameters:
_trees- Decision trees in the ensemble._treeWeights- Weights for the decision trees in the ensemble.uid- (undocumented)
-
-
Method Details
-
read
-
load
-
totalNumNodes
public int totalNumNodes()- Specified by:
totalNumNodesin interfaceorg.apache.spark.ml.tree.TreeEnsembleModel<DecisionTreeRegressionModel>
-
lossType
- Specified by:
lossTypein interfaceorg.apache.spark.ml.tree.GBTClassifierParams
-
impurity
- Specified by:
impurityin interfaceorg.apache.spark.ml.tree.HasVarianceImpurity
-
validationTol
- Specified by:
validationTolin interfaceorg.apache.spark.ml.tree.GBTParams
-
stepSize
Description copied from interface:HasStepSizeParam for Step size to be used for each iteration of optimization (> 0).- Specified by:
stepSizein interfaceorg.apache.spark.ml.tree.GBTParams- Specified by:
stepSizein interfaceHasStepSize- Returns:
- (undocumented)
-
validationIndicatorCol
Description copied from interface:HasValidationIndicatorColParam for name of the column that indicates whether each row is for training or for validation. False indicates training; true indicates validation..- Specified by:
validationIndicatorColin interfaceHasValidationIndicatorCol- Returns:
- (undocumented)
-
maxIter
Description copied from interface:HasMaxIterParam for maximum number of iterations (>= 0).- Specified by:
maxIterin interfaceHasMaxIter- Returns:
- (undocumented)
-
subsamplingRate
- Specified by:
subsamplingRatein interfaceorg.apache.spark.ml.tree.TreeEnsembleParams
-
featureSubsetStrategy
- Specified by:
featureSubsetStrategyin interfaceorg.apache.spark.ml.tree.TreeEnsembleParams
-
leafCol
- Specified by:
leafColin interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
maxDepth
- Specified by:
maxDepthin interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
maxBins
- Specified by:
maxBinsin interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
minInstancesPerNode
- Specified by:
minInstancesPerNodein interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
minWeightFractionPerNode
- Specified by:
minWeightFractionPerNodein interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
minInfoGain
- Specified by:
minInfoGainin interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
maxMemoryInMB
- Specified by:
maxMemoryInMBin interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
cacheNodeIds
- Specified by:
cacheNodeIdsin interfaceorg.apache.spark.ml.tree.DecisionTreeParams
-
weightCol
Description copied from interface:HasWeightColParam for weight column name. If this is not set or empty, we treat all instance weights as 1.0.- Specified by:
weightColin interfaceHasWeightCol- Returns:
- (undocumented)
-
seed
Description copied from interface:HasSeedParam for random seed. -
checkpointInterval
Description copied from interface:HasCheckpointIntervalParam for set checkpoint interval (>= 1) or disable checkpoint (-1). E.g. 10 means that the cache will get checkpointed every 10 iterations. Note: this setting will be ignored if the checkpoint directory is not set in the SparkContext.- Specified by:
checkpointIntervalin interfaceHasCheckpointInterval- Returns:
- (undocumented)
-
uid
Description copied from interface:IdentifiableAn immutable unique ID for the object and its derivatives.- Specified by:
uidin interfaceIdentifiable- Returns:
- (undocumented)
-
numFeatures
public int numFeatures()Description copied from class:PredictionModelReturns the number of features the model was trained on. If unknown, returns -1- Overrides:
numFeaturesin classPredictionModel<Vector,GBTClassificationModel>
-
numClasses
public int numClasses()Description copied from class:ClassificationModelNumber of classes (values which the label can take).- Specified by:
numClassesin classClassificationModel<Vector,GBTClassificationModel>
-
trees
- Specified by:
treesin interfaceorg.apache.spark.ml.tree.TreeEnsembleModel<DecisionTreeRegressionModel>
-
getNumTrees
public int getNumTrees()Number of trees in ensemble- Returns:
- (undocumented)
-
treeWeights
public double[] treeWeights()- Specified by:
treeWeightsin interfaceorg.apache.spark.ml.tree.TreeEnsembleModel<DecisionTreeRegressionModel>
-
transformSchema
Description copied from class:PipelineStageCheck transform validity and derive the output schema from the input schema.We check validity for interactions between parameters during
transformSchemaand raise an exception if any parameter value is invalid. Parameter value checks which do not depend on other parameters are handled byParam.validate().Typical implementation should first conduct verification on schema change and parameter validity, including complex parameter interaction checks.
- Overrides:
transformSchemain classProbabilisticClassificationModel<Vector,GBTClassificationModel> - Parameters:
schema- (undocumented)- Returns:
- (undocumented)
-
transform
Description copied from class:ProbabilisticClassificationModelTransforms dataset by reading fromPredictionModel.featuresCol(), and appending new columns as specified by parameters: - predicted labels asPredictionModel.predictionCol()of typeDouble- raw predictions (confidences) asClassificationModel.rawPredictionCol()of typeVector- probability of each class asProbabilisticClassificationModel.probabilityCol()of typeVector.- Overrides:
transformin classProbabilisticClassificationModel<Vector,GBTClassificationModel> - Parameters:
dataset- input dataset- Returns:
- transformed dataset
-
predict
Description copied from class:ClassificationModelPredict label for the given features. This method is used to implementtransform()and outputPredictionModel.predictionCol().This default implementation for classification predicts the index of the maximum value from
predictRaw().- Overrides:
predictin classClassificationModel<Vector,GBTClassificationModel> - Parameters:
features- (undocumented)- Returns:
- (undocumented)
-
predictRaw
Description copied from class:ClassificationModelRaw prediction for each possible label. The meaning of a "raw" prediction may vary between algorithms, but it intuitively gives a measure of confidence in each possible label (where larger = more confident). This internal method is used to implementtransform()and outputClassificationModel.rawPredictionCol().- Specified by:
predictRawin classClassificationModel<Vector,GBTClassificationModel> - Parameters:
features- (undocumented)- Returns:
- vector where element i is the raw prediction for label i. This raw prediction may be any real number, where a larger value indicates greater confidence for that label.
-
copy
Description copied from interface:ParamsCreates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly. SeedefaultCopy().- Specified by:
copyin interfaceParams- Specified by:
copyin classModel<GBTClassificationModel>- Parameters:
extra- (undocumented)- Returns:
- (undocumented)
-
toString
- Specified by:
toStringin interfaceIdentifiable- Specified by:
toStringin interfaceorg.apache.spark.ml.tree.TreeEnsembleModel<DecisionTreeRegressionModel>- Overrides:
toStringin classObject
-
featureImportances
-
evaluateEachIteration
Method to compute error or loss for every iteration of gradient boosting.- Parameters:
dataset- Dataset for validation.- Returns:
- (undocumented)
-
write
Description copied from interface:MLWritableReturns anMLWriterinstance for this ML instance.- Specified by:
writein interfaceMLWritable- Returns:
- (undocumented)
-