This is a naive Bayes classifier whose probability distribution follows a Gaussian distribution.
Gaussian naive Bayes finds the Gaussian distribution of data belonging to the same label, and determines which distribution new data is closer to.
■A concrete example of the GaussianNB function
In the graph below, the label values of the test data are classified from the feature data.
The program is as follows. To install various libraries such as scikit-learn, click here.
from sklearn.naive_bayes import GaussianNB
import numpy as np
import matplotlib.pyplot as plt
X = np.array([[5,10],[8,50],[10,20]]) # Feature data
Y = np.array([1, 2, 3]) # Feature data labels
t = np.array([[9,20]]) # test data
clf = GaussianNB() # Definition of Gaussian Naive Bayes
clf.fit(X, Y) # Fitting to feature data
print(clf.predict(t)) # Classify the test data
plt.plot([5,8,10],[10,50,20],'o') # Plotting feature data
plt.plot([9],[20],'^') # Plotting the test data
plt.grid(True)
plt.show()
The result should have returned a value of 3. This is certainly close to the value of 3 in the feature data, so the result seems reasonable.