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

    https://github.com/apache/spark/pull/9180#discussion_r42923827
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/util/LinearDataGenerator.scala ---
    @@ -125,6 +124,58 @@ object LinearDataGenerator {
       }
     
       /**
    +   * @param intercept Data intercept
    +   * @param weights  Weights to be applied.
    +   * @param xMean the mean of the generated features. Lots of time, if the 
features are not properly
    +   *              standardized, the algorithm with poor implementation 
will have difficulty
    +   *              to converge.
    +   * @param xVariance the variance of the generated features.
    +   * @param nPoints Number of points in sample.
    +   * @param seed Random seed
    +   * @param eps Epsilon scaling factor.
    +   * @return Seq of LabeledPoint includes sparse vectors..
    +   */
    +  @Since("1.6.0")
    +  def generateLinearSparseInput(
    +      intercept: Double,
    +      weights: Array[Double],
    +      xMean: Array[Double],
    +      xVariance: Array[Double],
    +      nPoints: Int,
    +      seed: Int,
    +      eps: Double): Seq[LabeledPoint] = {
    +    val rnd = new Random(seed)
    +    val x = Array.fill[Array[Double]](nPoints)(
    +      Array.fill[Double](weights.length)(rnd.nextDouble()))
    +
    +    x.foreach { v =>
    --- End diff --
    
    You can also add the variance of sparsity such that the num of non zeros 
will not be constant. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to