huaxingao commented on a change in pull request #28913:
URL: https://github.com/apache/spark/pull/28913#discussion_r444571654
##########
File path:
mllib/src/main/scala/org/apache/spark/ml/classification/RandomForestClassifier.scala
##########
@@ -166,7 +166,35 @@ class RandomForestClassifier @Since("1.4.0") (
val numFeatures = trees.head.numFeatures
instr.logNumClasses(numClasses)
instr.logNumFeatures(numFeatures)
- new RandomForestClassificationModel(uid, trees, numFeatures, numClasses)
+ createModel(dataset, trees, numFeatures, numClasses)
+ }
+
+ private def createModel(
+ dataset: Dataset[_],
+ trees: Array[DecisionTreeClassificationModel],
+ numFeatures: Int,
+ numClasses: Int): RandomForestClassificationModel = {
+ val model = copyValues(new RandomForestClassificationModel(uid, trees,
numFeatures, numClasses))
+ val weightColName = if (!isDefined(weightCol)) "weightCol" else
$(weightCol)
+
+ val (summaryModel, probabilityColName, predictionColName) =
model.findSummaryModel()
+ val rfSummary = if (numClasses <= 2) {
+ new BinaryRandomForestClassificationTrainingSummaryImpl(
+ summaryModel.transform(dataset),
+ probabilityColName,
+ predictionColName,
+ $(labelCol),
+ weightColName,
+ Array(0.0))
Review comment:
for non iterative algorithm, set objectiveHistory to Array(0.0).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]