spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkbradley <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-7545][mllib] Added check in Bernoulli N...
Date Wed, 13 May 2015 18:59:01 GMT
Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6073#discussion_r30263953
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala
---
    @@ -293,12 +298,26 @@ class NaiveBayes private (
           }
         }
     
    +    val requireZeroOneBernoulliValues: Vector => Unit = (v: Vector) => {
    +      val values = v match {
    +        case SparseVector(size, indices, values) =>
    +          values
    +        case DenseVector(values) =>
    +          values
    +      }
    +      if (!values.forall(v => v == 0.0 || v == 1.0)) {
    +        throw new SparkException(
    +          s"Bernoulli Naive Bayes requires 0 or 1 feature values but found $v.")
    +      }
    +    }
    +
         // Aggregates term frequencies per label.
         // TODO: Calling combineByKey and collect creates two stages, we can implement something
         // TODO: similar to reduceByKeyLocally to save one stage.
         val aggregated = data.map(p => (p.label, p.features)).combineByKey[(Long, BDV[Double])](
           createCombiner = (v: Vector) => {
             requireNonnegativeValues(v)
    --- End diff --
    
    Sorry!  I meant "does not" but clearly you understood


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message