April 2017
Intermediate to advanced
532 pages
12h 39m
English
Random forests are known as ensembles of decision trees formed by combining many decision trees. Like decision trees, random forests can handle categorical features, support multiclass, and don't require feature scaling.
Let's train the bike sharing dataset by splitting it into 80 % training and 20% testing, use RandomForestRegressor with Regression Evaluator from Spark to build the model, and get evaluation metrics around the test data.
@transient lazy val logger = Logger.getLogger(getClass.getName) def randForestRegressionWithVectorFormat(vectorAssembler: VectorAssembler, vectorIndexer: VectorIndexer, dataFrame: DataFrame) = { val lr = new RandomForestRegressor() .setFeaturesCol("features") .setLabelCol("label") ...Read now
Unlock full access