Examples of BoostingStrategy


Examples of org.apache.spark.mllib.tree.configuration.BoostingStrategy

    JavaRDD<LabeledPoint> data = MLUtils.loadLibSVMFile(sc.sc(), datapath).toJavaRDD().cache();

    // Set parameters.
    //  Note: All features are treated as continuous.
    BoostingStrategy boostingStrategy = BoostingStrategy.defaultParams(algo);
    boostingStrategy.setNumIterations(10);
    boostingStrategy.weakLearnerParams().setMaxDepth(5);

    if (algo.equals("Classification")) {
      // Compute the number of classes from the data.
      Integer numClasses = data.map(new Function<LabeledPoint, Double>() {
        @Override public Double call(LabeledPoint p) {
          return p.label();
        }
      }).countByValue().size();
      boostingStrategy.setNumClassesForClassification(numClasses); // ignored for Regression

      // Train a GradientBoosting model for classification.
      final WeightedEnsembleModel model = GradientBoosting.trainClassifier(data, boostingStrategy);

      // Evaluate model on training instances and compute training error
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.