Github user leahmcguire commented on a diff in the pull request:
https://github.com/apache/spark/pull/4087#discussion_r26258688
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala ---
@@ -262,4 +303,58 @@ object NaiveBayes {
def train(input: RDD[LabeledPoint], lambda: Double): NaiveBayesModel = {
new NaiveBayes(lambda).run(input)
}
+
+
+ /**
+ * Trains a Naive Bayes model given an RDD of `(label, features)` pairs.
+ *
+ * The model type can be set to either Multinomial NB
([[http://tinyurl.com/lsdw6p]])
+ * or Bernoulli NB ([[http://tinyurl.com/p7c96j6]]). The Multinomial NB
can handle
+ * discrete count data and can be called by setting the model type to
"multinomial".
+ * For example, it can be used with word counts or TF_IDF vectors of
documents.
+ * The Bernoulli model fits presence or absence (0-1) counts. By making
every vector a
+ * 0-1 vector and setting the model type to "bernoulli", the fits and
predicts as
+ * Bernoulli NB.
+ *
+ * @param input RDD of `(label, array of features)` pairs. Every vector
should be a frequency
+ * vector or a count vector.
+ * @param lambda The smoothing parameter
+ *
+ * @param modelType The type of NB model to fit from the enumeration
NaiveBayesModels, can be
+ * multinomial or bernoulli
+ */
+ def train(input: RDD[LabeledPoint], lambda: Double, modelType: String):
NaiveBayesModel = {
--- End diff --
If we remove this static train method should we also remove the static
train method that just includes lambda (line 326). Otherwise the train calls
are inconsistent for setting different model parameters (lambda and modelType).
---
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]