neural_trees.NaiveBayesClassifier#

class neural_trees.NaiveBayesClassifier(likelihood: str = 'gaussian', alpha: float = 1.0, var_smoothing: float = 1e-09)[source]#

Bases: ClassifierMixin, BaseEstimator

Naive Bayes Classifier with selectable likelihood.

Parameters:
likelihoodstr, default=”gaussian”

Type of feature likelihood: “gaussian”, “bernoulli”, or “multinomial”.

alphafloat, default=1.0

Laplace smoothing parameter (for bernoulli/multinomial).

var_smoothingfloat, default=1e-9

Variance stabilizer for Gaussian likelihood.

References

Alpaydın, E. (2020). Introduction to Machine Learning, Chapter 3. MIT Press.

predict_log_proba(X) ndarray[source]#

Log of the posterior class probabilities, shape (n_samples, n_classes).

Normalized, so np.exp(predict_log_proba(X)) equals predict_proba(X) and each row of the exponential sums to 1. The unnormalized joint log-likelihood is available as _joint_log_likelihood.

predict_proba(X) ndarray[source]#

Posterior class probabilities, shape (n_samples, n_classes).

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') NaiveBayesClassifier#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.