# Copyright 2019-2022 The ASReview Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__all__ = ["NaiveBayesClassifier"]

from sklearn.naive_bayes import MultinomialNB

from asreview.models.classifiers.base import BaseTrainClassifier


class NaiveBayesClassifier(BaseTrainClassifier):
    """Naive Bayes classifier (``nb``).

    Naive Bayes classifier. Only works in combination with the
    :class:`asreview.models.feature_extraction.Tfidf` or the
    :class:`asreview.models.feature_extraction.OneHot` feature extraction model.
    Though relatively simplistic, seems to work quite well on a wide range of
    datasets.

    The naive Bayes classifier is an implementation based
    on the sklearn multinomial naive Bayes classifier.

    Parameters
    ----------
    alpha : float, default=3.822
        Additive (Laplace/Lidstone) smoothing parameter
        (0 for no smoothing).
    """

    name = "nb"
    label = "Naive Bayes"

    def __init__(self, alpha=3.822):
        super().__init__()
        self.alpha = alpha
        self._model = MultinomialNB(alpha=alpha)
