Home | Trees | Indices | Help |
|
---|
|
Naive Bayes classifier for multinomial models This node has been automatically generated by wrapping the ``sklearn.naive_bayes.MultinomialNB`` class from the ``sklearn`` library. The wrapped instance can be accessed through the ``scikits_alg`` attribute. The multinomial Naive Bayes classifier is suitable for classification with discrete features (e.g., word counts for text classification). The multinomial distribution normally requires integer feature counts. However, in practice, fractional counts such as tf-idf may also work. Read more in the :ref:`User Guide <multinomial_naive_bayes>`. **Parameters** alpha : float, optional (default=1.0) Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing). fit_prior : boolean Whether to learn class prior probabilities or not. If false, a uniform prior will be used. class_prior : array-like, size (n_classes,) Prior probabilities of the classes. If specified the priors are not adjusted according to the data. **Attributes** ``class_log_prior_`` : array, shape (n_classes, ) Smoothed empirical log probability for each class. ``intercept_`` : property Mirrors ``class_log_prior_`` for interpreting MultinomialNB as a linear model. ``feature_log_prob_`` : array, shape (n_classes, n_features) Empirical log probability of features given a class, ``P(x_i|y)``. ``coef_`` : property Mirrors ``feature_log_prob_`` for interpreting MultinomialNB as a linear model. ``class_count_`` : array, shape (n_classes,) Number of samples encountered for each class during fitting. This value is weighted by the sample weight when provided. ``feature_count_`` : array, shape (n_classes, n_features) Number of samples encountered for each (class, feature) during fitting. This value is weighted by the sample weight when provided. **Examples** >>> import numpy as np >>> X = np.random.randint(5, size=(6, 100)) >>> y = np.array([1, 2, 3, 4, 5, 6]) >>> from sklearn.naive_bayes import MultinomialNB >>> clf = MultinomialNB() >>> clf.fit(X, y) MultinomialNB(alpha=1.0, class_prior=None, fit_prior=True) >>> print(clf.predict(X[2:3])) [3] **Notes** For the rationale behind the names `coef_` and `intercept_`, i.e. naive Bayes as a linear classifier, see J. Rennie et al. (2003), Tackling the poor assumptions of naive Bayes text classifiers, ICML. **References** C.D. Manning, P. Raghavan and H. Schuetze (2008). Introduction to Information Retrieval. Cambridge University Press, pp. 234-265. http://nlp.stanford.edu/IR-book/html/htmledition/naive-bayes-text-classification-1.html
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from |
|||
Inherited from ClassifierCumulator | |||
---|---|---|---|
|
|||
|
|||
|
|||
Inherited from ClassifierNode | |||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Node | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
|
|||
|
|
|||
Inherited from |
|||
Inherited from Node | |||
---|---|---|---|
_train_seq List of tuples: |
|||
dtype dtype |
|||
input_dim Input dimensions |
|||
output_dim Output dimensions |
|||
supported_dtypes Supported dtypes |
|
Naive Bayes classifier for multinomial models This node has been automatically generated by wrapping the ``sklearn.naive_bayes.MultinomialNB`` class from the ``sklearn`` library. The wrapped instance can be accessed through the ``scikits_alg`` attribute. The multinomial Naive Bayes classifier is suitable for classification with discrete features (e.g., word counts for text classification). The multinomial distribution normally requires integer feature counts. However, in practice, fractional counts such as tf-idf may also work. Read more in the :ref:`User Guide <multinomial_naive_bayes>`. **Parameters** alpha : float, optional (default=1.0) Additive (Laplace/Lidstone) smoothing parameter (0 for no smoothing). fit_prior : boolean Whether to learn class prior probabilities or not. If false, a uniform prior will be used. class_prior : array-like, size (n_classes,) Prior probabilities of the classes. If specified the priors are not adjusted according to the data. **Attributes** ``class_log_prior_`` : array, shape (n_classes, ) Smoothed empirical log probability for each class. ``intercept_`` : property Mirrors ``class_log_prior_`` for interpreting MultinomialNB as a linear model. ``feature_log_prob_`` : array, shape (n_classes, n_features) Empirical log probability of features given a class, ``P(x_i|y)``. ``coef_`` : property Mirrors ``feature_log_prob_`` for interpreting MultinomialNB as a linear model. ``class_count_`` : array, shape (n_classes,) Number of samples encountered for each class during fitting. This value is weighted by the sample weight when provided. ``feature_count_`` : array, shape (n_classes, n_features) Number of samples encountered for each (class, feature) during fitting. This value is weighted by the sample weight when provided. **Examples** >>> import numpy as np >>> X = np.random.randint(5, size=(6, 100)) >>> y = np.array([1, 2, 3, 4, 5, 6]) >>> from sklearn.naive_bayes import MultinomialNB >>> clf = MultinomialNB() >>> clf.fit(X, y) MultinomialNB(alpha=1.0, class_prior=None, fit_prior=True) >>> print(clf.predict(X[2:3])) [3] **Notes** For the rationale behind the names `coef_` and `intercept_`, i.e. naive Bayes as a linear classifier, see J. Rennie et al. (2003), Tackling the poor assumptions of naive Bayes text classifiers, ICML. **References** C.D. Manning, P. Raghavan and H. Schuetze (2008). Introduction to Information Retrieval. Cambridge University Press, pp. 234-265. http://nlp.stanford.edu/IR-book/html/htmledition/naive-bayes-text-classification-1.html
|
|
|
Transform the data and labels lists to array objects and reshape them.
|
|
|
Perform classification on an array of test vectors X. This node has been automatically generated by wrapping the sklearn.naive_bayes.MultinomialNB class from the sklearn library. The wrapped instance can be accessed through the scikits_alg attribute. Parameters X : array-like, shape = [n_samples, n_features] Returns
|
Fit Naive Bayes classifier according to X, y This node has been automatically generated by wrapping the sklearn.naive_bayes.MultinomialNB class from the sklearn library. The wrapped instance can be accessed through the scikits_alg attribute. Parameters
Returns
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Mar 8 12:39:48 2016 | http://epydoc.sourceforge.net |