With:
- A train and testing dataset with two features x1 and x2
- Two binary classes for classification (0 or 1)
- Training and prediction with the Naive Bayes algorithm for Gaussian classification
- Plot of decision regions following scikit-learn guide, with the axes being x1 and x2
How to calculate and plot the line equation that goes between the two decision regions?
The least squares regression method has already been tried, but the results never fit the decision boundary.
This is the code that has already been tried:
x_mean = np.mean(x)
y_mean = np.mean(y)
numer = 0
denom = 0
for i in range(len(x)):
numer += (x[i] - x_mean) * (y[i] - y_mean)
denom += (x[i] - x_mean) ** 2
m = -numer/denom
c = y_mean - (m * x_mean)
max_x = np.max(x)
min_x = np.min(y)
x_plt = np.linspace(min_x, max_x, 1000)
y_plt = c + m*x
plt.plot(x_plt, y_plt)