This Python class implements the Gaussian Naive Bayes algorithm for classification tasks, assuming each feature follows a Gaussian (normal) distribution. It calculates class priors, means, and variances from the training data and predicts the class labels for new data based on these parameters.
Key Features:
Initialization: Initializes class attributes for class priors, means, and variances.
Fit Method: Trains the model using training data (X_train, y_train) to compute class priors (P(Y)), means (μ), and variances (σ^2).
Gaussian PDF Calculation: Computes the Gaussian probability density function (pdf) to estimate the likelihood of a feature value given a class.
Prediction Method: Predicts the class labels for new data (X_test) by calculating posteriors (P(Y|X)) and selecting the class with the highest posterior probability.
Technologies Used:
Python: Core programming language for implementing the classifier.
NumPy: Used for numerical computations, array operations, and statistical calculations.
Pandas: Utilized for handling and manipulating input data (X_test) as a DataFrame.