Gaussian Naive Bayes is a classification algorithm based on Bayes' theorem with a "naive" assumption that features are conditionally independent given the class. Each feature's likelihood is modeled as a Gaussian distribution, making it fast and effective for many real-world problems.
Given labeled training data and unlabeled test data, predict the class for each test sample by computing the posterior probability for each class.
Input:
X_train = [[1], [2], [3], [10], [11], [12]], y_train = [0, 0, 0, 1, 1, 1], X_test = [[2], [11], [6]]
Output:
[0, 1, 0]
Class 0 has mean 2 and class 1 has mean 11. Test points near class 0's mean are classified as 0, near class 1's mean as 1. The midpoint sample x=6 is closer to class 0 in this Gaussian model.
Input:
X_train = [[0, 0], [1, 0], [0, 1], [10, 10], [11, 10], [10, 11]], y_train = [0, 0, 0, 1, 1, 1], X_test = [[0.5, 0.5], [10.5, 10.5]]
Output:
[0, 1]
With 2D features, each class has a cluster of points. The test points fall clearly within each cluster's distribution.
Group training data by class. For each class, compute the mean and variance for each feature. Then for each test point, compute log_prior + sum of log-likelihoods for each class, and pick the class with the highest total.
The Gaussian log-likelihood for feature j given class c is: -0.5 * log(2 * pi * var) - (x_j - mean)^2 / (2 * var). Remember to add epsilon to var before using it.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array
Gaussian Naive Bayes is a classification algorithm based on Bayes' theorem with a "naive" assumption that features are conditionally independent given the class. Each feature's likelihood is modeled as a Gaussian distribution, making it fast and effective for many real-world problems.
Given labeled training data and unlabeled test data, predict the class for each test sample by computing the posterior probability for each class.
Input:
X_train = [[1], [2], [3], [10], [11], [12]], y_train = [0, 0, 0, 1, 1, 1], X_test = [[2], [11], [6]]
Output:
[0, 1, 0]
Class 0 has mean 2 and class 1 has mean 11. Test points near class 0's mean are classified as 0, near class 1's mean as 1. The midpoint sample x=6 is closer to class 0 in this Gaussian model.
Input:
X_train = [[0, 0], [1, 0], [0, 1], [10, 10], [11, 10], [10, 11]], y_train = [0, 0, 0, 1, 1, 1], X_test = [[0.5, 0.5], [10.5, 10.5]]
Output:
[0, 1]
With 2D features, each class has a cluster of points. The test points fall clearly within each cluster's distribution.
Group training data by class. For each class, compute the mean and variance for each feature. Then for each test point, compute log_prior + sum of log-likelihoods for each class, and pick the class with the highest total.
The Gaussian log-likelihood for feature j given class c is: -0.5 * log(2 * pi * var) - (x_j - mean)^2 / (2 * var). Remember to add epsilon to var before using it.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: array