Created
April 19, 2015 15:13
-
-
Save nivdul/f380586bfefc39b05f0c to your computer and use it in GitHub Desktop.
Decision Tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<Integer, Integer> categoricalFeaturesInfo = new HashMap<>(); | |
int numClasses = 4; | |
String impurity = "gini"; | |
int maxDepth = 9; | |
int maxBins = 32; | |
// create model | |
final DecisionTreeModel model = DecisionTree.trainClassifier(trainingData, numClasses, categoricalFeaturesInfo, impurity, maxDepth, maxBins); | |
// Evaluate model on training instances and compute training error | |
JavaPairRDD<Double, Double> predictionAndLabel = testData.mapToPair(p -> new Tuple2<>(model.predict(p.features()), p.label())); | |
Double testErrDT = 1.0 * predictionAndLabel.filter(pl -> !pl._1().equals(pl._2())).count() / testData.count(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment