Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/4087#discussion_r26169287
--- Diff:
mllib/src/test/scala/org/apache/spark/mllib/classification/NaiveBayesSuite.scala
---
@@ -41,37 +44,39 @@ object NaiveBayesSuite {
// Generate input of the form Y = (theta * x).argmax()
def generateNaiveBayesInput(
- pi: Array[Double], // 1XC
- theta: Array[Array[Double]], // CXD
- nPoints: Int,
- seed: Int): Seq[LabeledPoint] = {
+ pi: Array[Double], // 1XC
+ theta: Array[Array[Double]], // CXD
+ nPoints: Int,
+ seed: Int,
+ dataModel: NaiveBayes.ModelType = NaiveBayes.Multinomial,
+ sample: Int = 10): Seq[LabeledPoint] = {
val D = theta(0).length
val rnd = new Random(seed)
-
val _pi = pi.map(math.pow(math.E, _))
val _theta = theta.map(row => row.map(math.pow(math.E, _)))
for (i <- 0 until nPoints) yield {
val y = calcLabel(rnd.nextDouble(), _pi)
- val xi = Array.tabulate[Double](D) { j =>
- if (rnd.nextDouble() < _theta(y)(j)) 1 else 0
+ val xi = dataModel match {
+ case NaiveBayes.Bernoulli => Array.tabulate[Double] (D) {j =>
--- End diff --
space before "j"
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]