Class GradientBoostedTreesModel
Object
org.apache.spark.mllib.tree.model.TreeEnsembleModel
org.apache.spark.mllib.tree.model.GradientBoostedTreesModel
- All Implemented Interfaces:
Serializable,Saveable
public class GradientBoostedTreesModel
extends org.apache.spark.mllib.tree.model.TreeEnsembleModel
implements Saveable
Represents a gradient boosted trees model.
param: algo algorithm for the ensemble model, either Classification or Regression param: trees tree ensembles param: treeWeights tree ensemble weights
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.spark.mllib.tree.model.TreeEnsembleModel
org.apache.spark.mllib.tree.model.TreeEnsembleModel.SaveLoadV1_0$ -
Constructor Summary
ConstructorsConstructorDescriptionGradientBoostedTreesModel(scala.Enumeration.Value algo, DecisionTreeModel[] trees, double[] treeWeights) -
Method Summary
Modifier and TypeMethodDescriptionscala.Enumeration.Valuealgo()computeInitialPredictionAndError(RDD<LabeledPoint> data, double initTreeWeight, DecisionTreeModel initTree, Loss loss) Compute the initial predictions and errors for a dataset for the first iteration of gradient boosting.double[]evaluateEachIteration(RDD<LabeledPoint> data, Loss loss) Method to compute error or loss for every iteration of gradient boosting.static GradientBoostedTreesModelload(SparkContext sc, String path) voidsave(SparkContext sc, String path) Save this model to the given path.trees()double[]updatePredictionError(RDD<LabeledPoint> data, RDD<scala.Tuple2<Object, Object>> predictionAndError, double treeWeight, DecisionTreeModel tree, Loss loss) Update a zipped predictionError RDD (as obtained with computeInitialPredictionAndError)Methods inherited from class org.apache.spark.mllib.tree.model.TreeEnsembleModel
combiningStrategy, LogStringContext, numTrees, predict, predict, predict, toDebugString, toString, totalNumNodes
-
Constructor Details
-
GradientBoostedTreesModel
public GradientBoostedTreesModel(scala.Enumeration.Value algo, DecisionTreeModel[] trees, double[] treeWeights)
-
-
Method Details
-
computeInitialPredictionAndError
public static RDD<scala.Tuple2<Object,Object>> computeInitialPredictionAndError(RDD<LabeledPoint> data, double initTreeWeight, DecisionTreeModel initTree, Loss loss) Compute the initial predictions and errors for a dataset for the first iteration of gradient boosting.- Parameters:
data- : training data.initTreeWeight- : learning rate assigned to the first tree.initTree- : first DecisionTreeModel.loss- : evaluation metric.- Returns:
- an RDD with each element being a zip of the prediction and error corresponding to every sample.
-
updatePredictionError
public static RDD<scala.Tuple2<Object,Object>> updatePredictionError(RDD<LabeledPoint> data, RDD<scala.Tuple2<Object, Object>> predictionAndError, double treeWeight, DecisionTreeModel tree, Loss loss) Update a zipped predictionError RDD (as obtained with computeInitialPredictionAndError)- Parameters:
data- : training data.predictionAndError- : predictionError RDDtreeWeight- : Learning rate.tree- : Tree using which the prediction and error should be updated.loss- : evaluation metric.- Returns:
- an RDD with each element being a zip of the prediction and error corresponding to each sample.
-
load
- Parameters:
sc- Spark context used for loading model files.path- Path specifying the directory to which the model was saved.- Returns:
- Model instance
-
algo
public scala.Enumeration.Value algo()- Overrides:
algoin classorg.apache.spark.mllib.tree.model.TreeEnsembleModel
-
trees
- Overrides:
treesin classorg.apache.spark.mllib.tree.model.TreeEnsembleModel
-
treeWeights
public double[] treeWeights()- Overrides:
treeWeightsin classorg.apache.spark.mllib.tree.model.TreeEnsembleModel
-
save
Description copied from interface:SaveableSave this model to the given path.This saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/
The model may be loaded using
Loader.load. -
evaluateEachIteration
Method to compute error or loss for every iteration of gradient boosting.- Parameters:
data- RDD ofLabeledPointloss- evaluation metric.- Returns:
- an array with index i having the losses or errors for the ensemble containing the first i+1 trees
-