Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20632#discussion_r168956144
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/tree/impl/RandomForestSuite.scala ---
    @@ -640,4 +740,55 @@ private object RandomForestSuite {
         val (indices, values) = map.toSeq.sortBy(_._1).unzip
         Vectors.sparse(size, indices.toArray, values.toArray)
       }
    +
    +  /** Generate a label. */
    +  private def generateLabel(rnd: Random, numClasses: Int): Double = {
    +    rnd.nextInt(numClasses)
    +  }
    +
    +  /** Generate a numeric value in the range [numericMin, numericMax]. */
    +  private def generateNumericValue(rnd: Random, numericMin: Double, 
numericMax: Double) : Double = {
    +    rnd.nextDouble() * (numericMax- numericMin) + numericMin
    +  }
    +
    +  /** Generate a binary value. */
    +  private def generateBinaryValue(rnd: Random) : Double = if 
(rnd.nextBoolean()) 1 else 0
    --- End diff --
    
    These 1-line single-use methods strike me as overhead you don't need; I 
don't feel strongly about it but inlining it would be at least as readable 
IMHO. This could also be `rnd.nextInt(2)`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to