Skip to content

Commit

Permalink
put back in constructor for NaiveBayes
Browse files Browse the repository at this point in the history
  • Loading branch information
leahmcguire committed Mar 12, 2015
1 parent 01baad7 commit bea62af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class NaiveBayes private (
private var lambda: Double,
private var modelType: NaiveBayes.ModelType) extends Serializable with Logging {

private def this(lambda: Double) = this(lambda, NaiveBayes.Multinomial)

def this() = this(1.0, NaiveBayes.Multinomial)

/** Set the smoothing parameter. Default: 1.0. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,15 @@ class NaiveBayesSuite extends FunSuite with MLlibTestSparkContext {
).map(_.map(math.log))

val testData = NaiveBayesSuite.generateNaiveBayesInput(
pi,
theta,
nPoints,
45,
NaiveBayes.Bernoulli)
pi, theta, nPoints, 45, NaiveBayes.Bernoulli)
val testRDD = sc.parallelize(testData, 2)
testRDD.cache()

val model = NaiveBayes.train(testRDD, 1.0, "bernoulli")
validateModelFit(pi, theta, model)

val validationData = NaiveBayesSuite.generateNaiveBayesInput(
pi,
theta,
nPoints,
20,
NaiveBayes.Bernoulli)
pi, theta, nPoints, 20, NaiveBayes.Bernoulli)
val validationRDD = sc.parallelize(validationData, 2)

// Test prediction on RDD.
Expand Down

0 comments on commit bea62af

Please sign in to comment.