I am working on a k-NN model, trying to compare different models and different distance measurements. I am trying to add 18 subplots into one plot. Unfortunately, it starts only from the second plot.
Picture for example:
I tried to change the position of the function call (plt.subplot), with no success:
types_of_data = ["separated", "mixed", "random"]
K_options = [1,3,9]
options_list = options_generator(types_of_data, K_options)
N = 70
graph_num = 1
rcParams['figure.figsize'] = 48, 30 # width, height
for option in options_list:
X_train, y_train = generate_data(N, option[0])
if option[2] == "L1":
knn = KNeighborsClassifier(n_neighbors = option[1], metric = "manhattan")
else:
knn = KNeighborsClassifier(n_neighbors = option[1])
knn.fit(X_train,y_train)
y_pred = knn.predict(X_test)
#plotting test and points:
for i in range(3):
a_trn = X_train[np.where(y_train ==i)][:,0] # grab X_train points for which label is i. grab the x coordinate
b_trn = X_train[np.where(y_train ==i)][:,1] # grab X_train points for which label is i. grab the y coordinate
a_tst = X_test[np.where(y_pred ==i)][:,0] # grab X_train points for which label is i. grab the x coordinate
b_tst = X_test[np.where(y_pred ==i)][:,1] # grab X_train points for which label is i. grab the y coordinate
plt.scatter(a_tst, b_tst, color=test_colors[i])
plt.scatter(a_trn, b_trn, color=train_colors[i], label = i)
tmp_title = "Graph #{0} \n Scatter type = {1}, K = {2}, Distance measure = {3}".format(graph_num, option[0], option[1], option[2])
plt.title(tmp_title)
plt.subplot(3,6,graph_num)
graph_num += 1
Any ideas on how to solve this issue?
Thanks a lot